[CMake] Building two binaries from common source: different
defines required
Eric Noulard
eric.noulard at gmail.com
Mon Jan 14 07:01:49 EST 2008
2008/1/14, Vladimir Pouzanov <farcaller at gmail.com>:
> I have a project consisting of two binaries build from same source (they do
> differ in one .cpp file though).
>
> Is it possible to set ADD_DEFINITIONS on per-executable basis somehow? I need to
> add a define specifying which binary type is being built.
Look at SET_TARGET_PROPERTIES
i.e. the COMPILE_FLAGS
for example
ADD_EXECUTABLE(first source1.cpp source2.cpp)
SET_TARGET_PROPERTIES(first PROPERTIES
COMPILE_FLAGS "-D_FIRST")
ADD_EXECUTABLE(second source1.cpp source2.cpp)
SET_TARGET_PROPERTIES(second PROPERTIES
COMPILE_FLAGS "-D_SECOND")
should be OK.
SET_SOURCE_FILES_PROPERTIES may be useful too
if the compile flags may be attached to the source and not
to the target. This is not the case you described but I found
it usefull too.
--
Erk
More information about the CMake
mailing list