[CMake] Dependencies

William A. Hoffman billlist at nycap.rr.com
Wed Oct 20 15:39:48 EDT 2004


What is project_target?
The POST_BUILD custom command is used for adding commands onto an
existing target (library, executable, custom target).  If there is
no target called project_target then it will do nothing.

If you added a 

ADD_CUSTOM_TARGET(project_target ALL 
DEPENDS ${MODEL_FILES})

Then did the FOREACH loop I think it would work.

-Bill

At 02:24 PM 10/20/2004, Chris Scharver wrote:

>project
>project/models
>project/src
>
>The top-level CMakeLists.txt lists the models and src directories as SUBDIRS. The models should only be copied if the source target was built. Here's the relevant portion from models/CMakeLists.txt:
>
># Use GLOB to grab all the model files
>FILE(GLOB MODEL_FILES *.iv *.jpg)
>
># Copy each model file to the build directory.
>MAKE_DIRECTORY(${EXECUTABLE_OUTPUT_PATH}/models)
>FOREACH(modelfile ${MODEL_FILES})
>  ADD_CUSTOM_COMMAND(TARGET project_target POST_BUILD
>    COMMAND ${CMAKE_COMMAND}
>    ARGS -E copy_if_different ${modelfile}
>    ${EXECUTABLE_OUTPUT_PATH}/models/
>    )
>ENDFOREACH(modelfile)
>
>The generated Makefile doesn't contain anything for copying files. Is this due to the fact that the models directory cannot properly detect the dependency on the project_target specified in the src directory? Or does TARGET and POST_BUILD not work for Makefiles? If I instead use:
>
>  ADD_CUSTOM_COMMAND(OUTPUT "${modelfile}"
>    COMMAND ${CMAKE_COMMAND}
>    ARGS -E copy ${modelfile}
>    ${EXECUTABLE_OUTPUT_PATH}/models/
>    MAIN_DEPENDENCY ${EXECUTABLE_OUTPUT_PATH}/targetedreaching
>    )
>
>I see the commands in the generated Makefiles, but they never execute. I'm always running make from the project root build directory.
>
>Chris
>--
>Chris Scharver
>Electronic Visualization Laboratory
>The University of Illinois at Chicago
>Ph: 312-996-3002   FAX: 312-413-7585
><http://www.evl.uic.edu/scharver/>
>
>_______________________________________________
>CMake mailing list
>CMake at www.cmake.org
>http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list