How can I prepend all filenames on the list with a common path prefix automatically? For instance having a list of files in CMakeLists.txt:
SET(SRC_FILES foo
CMake 3.12 added list transformers - one of these transformers is PREPEND
. Thus, the following can be used inline to prepend all entries in a list:
list(TRANSFORM FILES_TO_TRANSLATE PREPEND ${CMAKE_CURRENT_SOURCE_DIR})
...where FILES_TO_TRANSLATE
is the variable name of the list.
More information can be found in the CMake documentation.