[Cmake] SET_SOURCE_FILE_PROPERTIES not working?
Brad King
brad.king at kitware.com
Mon Jul 26 09:15:00 EDT 2004
Christopher Baus wrote:
> SVNVersion.cpp is generated by the svnversion command.
>
> I need to build it, and the executable is dependant on it. So I added it
> to Sources. The problem is I need to force it to be built every time make
> is executed. In qmake you can make the target dependant on FORCE. With
> out the full documentation of the book, I can't figure this out.
>
> Currently I get an error saying the dependencies can not determined since
> there is no rule to build SVNVersion.cpp. I added the ADD_CUSTOM_TARGET
> rule, so I'm not sure what the problem is.
>
> Here's my CMakeLists.txt:
> SET( APP_SRCS a.cpp b.cpp c.cpp SVNVersion.cpp )
> SET_SOURCE_FILES_PROPERTIES(SVNVersion.cpp PROPERTIES GENERATED 1)
> ADD_CUSTOM_TARGET(SVNVersion.cpp ./gensvnversion.sh)
> ADD_EXECUTABLE(ssvs ${APP_SRCS})
> TARGET_LINK_LIBRARIES(ssvs util)
> LINK_LIBRARIES(lib1 lib2 lib3)
The ADD_CUSTOM_TARGET command is meant to create customized top-level
make targets like "RunMySpecialTests" or "NightlySubmit". To add custom
rules for building/generating sources used in another target, use the
ADD_CUSTOM_COMMAND command.
As far as getting it to run every time make is executed, there is no
supported way to do this right now. I'm guessing you are trying to
generate some kind of build timestamp. From experience, I've found that
having a source-tree timestamp or version number compiled into the
targets is more important than the actual time the build was done.
What's to stop someone from checking out a source tree from 2 years ago
and building it with a present-day build stamp? Build timestamps do not
tell you anything about what code was compiled.
-Brad
More information about the Cmake
mailing list