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

后端 未结 6 1814
孤城傲影
孤城傲影 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:32

    Following function may be what you want.

    FUNCTION(PREPEND var prefix)
       SET(listVar "")
       FOREACH(f ${ARGN})
          LIST(APPEND listVar "${prefix}/${f}")
       ENDFOREACH(f)
       SET(${var} "${listVar}" PARENT_SCOPE)
    ENDFUNCTION(PREPEND)
    

    To use it,

    PREPEND(FILES_TO_TRANSLATE ${CMAKE_CURRENT_SOURCE_DIR} ${SRC_FILES})
    

提交回复
热议问题