How to prepend all filenames on the list with common path?

后端 未结 6 1816
孤城傲影
孤城傲影 2020-12-16 09:05

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         


        
6条回答
  •  粉色の甜心
    2020-12-16 09:36

    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.

提交回复
热议问题