[CMake] How to copy files to the directory of executable file.
cmake.org › pipermail › cmakeMar 19, 2009 · The copy_directory has a guard against copying CVS metadata. MACRO(COPY_FILE_IF_CHANGED in_file out_file target) IF(${in_file} IS_NEWER_THAN ${out_file}) # message("COpying file: ${in_file} to: ${out_file}") ADD_CUSTOM_COMMAND ( TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${in_file} ${out_file} ) ENDIF(${in_file} IS_NEWER_THAN ${out_file}) ENDMACRO(COPY_FILE_IF_CHANGED) MACRO(COPY_FILE_INTO_DIRECTORY_IF_CHANGED in_file out_dir target) GET_FILENAME_COMPONENT(file_name ...
file — CMake 3.23.0-rc3 Documentation
cmake.org › cmake › helpFor a simple file copying operation, the file(COPY_FILE) sub-command just above may be easier to use. The COPY signature copies files, directories, and symlinks to a destination folder. Relative input paths are evaluated with respect to the current source directory, and a relative destination is evaluated with respect to the current build directory.
CMake: How to have a target for copying files - Stack Overflow
stackoverflow.com › questions › 14474659Jan 23, 2013 · I am using the following command to copy config files into the build directory after each compile. # 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 ()