[CMake] Question about add_custom_command
David Aldrich
David.Aldrich at EU.NEC.COM
Thu Sep 9 12:53:57 EDT 2010
Hi
As mentioned before, I am replacing a manually built gnu makefile (for Linux) that builds a library, with CMake.
A required build step is to run an executable called versionInfo that processes all the source files of the library and generates a new source file called SourceFileInfo.cpp. This generated file must be compiled and added to the library. This step must be executed when any library dependency changes (i.e. any other source file changes).
I tried:
add_custom_command (
TARGET Kernel
PRE_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/../VersionInfo/versionInfo ${CMAKE_SOURCE_DIR} KERNEL
[COMMENT "Building SourceFileInfo.cpp"]
)
add_library(Kernel STATIC
ErrorHandler.cpp
EnvVars.cpp
SourceFileInfo.cpp
<snip>
)
The source files are compiled ok, but versionInfo does not run and, because SourceFileInfo.cpp is therefore not found, the script fails.
Am I on the right track?
I read that PRE_BUILD is only supported for Visual Studio 7 or later, but I got no better result with PRE_LINK.
Best regards
David
More information about the CMake
mailing list