.xml
およびファイルのみをコピーするには、次のコマンド.conf
を使用できます。file(GLOB ...)
# Gather list of all .xml and .conf files in "/config"
file(GLOB ConfigFiles ${CMAKE_SOURCE_DIR}/config/*.xml
${CMAKE_SOURCE_DIR}/config/*.conf)
foreach(ConfigFile ${ConfigFiles})
add_custom_command(TARGET MyTarget PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy ${ConfigFile} $<TARGET_FILE_DIR:MyTarget>)
endforeach()
.svn
サブディレクトリにないすべてのファイルを取得するのも同様のプロセスです。
# Gather list of all files in "/config"
file(GLOB ConfigFiles RELATIVE ${CMAKE_SOURCE_DIR}/config
${CMAKE_SOURCE_DIR}/config/*)
# Gather list of all files in "/config/.svn"
file(GLOB SvnConfigFiles RELATIVE ${CMAKE_SOURCE_DIR}/config
${CMAKE_SOURCE_DIR}/config/.svn/*)
# Remove ".svn" and its contents from the list
list(REMOVE_ITEM ConfigFiles .svn ${SvnConfigFiles})
foreach(ConfigFile ${ConfigFiles})
add_custom_command(TARGET MyTarget PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy ${CMAKE_SOURCE_DIR}/config/${ConfigFile}
$<TARGET_FILE_DIR:MyTarget>)
endforeach()