[CMake] How to generate a source file with unpredictable dependency
jlh
jlh at gmx.ch
Tue May 13 17:58:28 EDT 2008
Hello!
Alexander Neundorf wrote:
> ADD_CUSTOM_TARGET(make_version_target ${CMAKE_CURRENT_SOURCE_DIR}/makeversion
> COMMENT "Checking version.cpp" VERBATIM)
> SET_SOURCE_FILES_PROPERTIES(version.cpp PROPERTIES GENERATED TRUE)
>
> create your target...
>
> ADD_EXECUTABLE(foo main.cpp version.cpp)
> ADD_DEPENDENCIES(foo make_version_target)
This seems to work, thanks. It also helps with my concept that
version.cpp is not a target. :) Just there's an additional line
of output saying "Built target make_version_target", but I guess
if I can find a nicer name for the target that will be ok.
> You can skip the following line:
>> SET_SOURCE_FILES_PROPERTIES(version.cpp PROPERTIES GENERATED TRUE)
No, I can't. cmake will error if the file doesn't exist yet:
CMake Error: Cannot find source file "/path/to/project/version.cpp"
for target "project"
Thanks again,
jlh
More information about the CMake
mailing list