I need to copy resource files from the source directory to the binary directory with the creation of my executable. I want CMake's dependency tracking to handle (re)copying these files whenever the source has been touched.
Looking at other similar questions like: http://stackoverflow.com/questions/17018477/cmake-adding-custom-resources-to-build-directory and the CMake FAQ: How can I add a dependency to a source file which is generated in a subdirectory? http://www.cmake.org/Wiki/CMake_FAQ I expected the following (simplified) code to work, but it doesn't. I see the add_custom_target processed in the make chain, but the add_custom_command never triggers. project(foo) cmake_minimum_required(VERSION 2.8) add_executable(fooexe ${CMAKE_SOURCE_DIR}/foo.c ${CMAKE_SOURCE_DIR}/asset1.lua # ${CMAKE_SOURCE_DIR}/subdir/subasset1.lua ) add_custom_command( OUTPUT "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INT}/asset1.lua" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/asset1.lua" "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INT}/" DEPENDS "${CMAKE_SOURCE_DIR}/asset1.lua" COMMENT "Copying asset1.lua" ) # files are only copied if a target depends on them add_custom_target(fooresources ALL DEPENDS "${CMAKE_SOURCE_DIR}/asset1.lua" COMMENT "fooresources custom target" ) ADD_DEPENDENCIES(fooexe fooresources) Would somebody explain to me the correct way to handle this? Thanks, Eric -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake