[CMake] Dependencies
Chris Scharver
scharver at evl.uic.edu
Wed Oct 20 16:24:19 EDT 2004
The project_target is the application executable defined within
project/src. I would like to copy the models only if the target
executable has been built. Consider:
project
SUBDIRS(lib src models)
project/lib
ADD_LIBRARY(someLib ...)
project/models
ADD_CUSTOM_TARGET(TARGET app POST_BUILD ...)
project/src
ADD_EXECUTABLE(app ...)
TARGET_LINK_LIBRARIES(app someLib ...)
In this case, someLib is properly tracked as a project_target
dependencies. I'm hoping that specifying a target for ADD_CUSTOM_TARGET
can behave the same way. If not, can I somehow use GLOB to obtain the
base filename (something like basename())? Then I could use
ADD_CUSTOM_TARGET and manually set the OUTPUT dependency to the
destination file name.
Chris
On Oct 20, 2004, at 2:39 PM, William A. Hoffman wrote:
> 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/>
More information about the CMake
mailing list