[CMake] How to build 2 targets from the same source, differing in -D_SWITCHES_ only
Eike Kroemer
eike-michael.kroemer at atlas-elektronik.com
Thu Aug 27 08:55:40 EDT 2009
Hi Marcel, Christian,
> Am 08/27/2009 01:30 PM Marcel Loose wrote:
> I think the only safe and reliable way to do this is create several
> build directories, e.g. build/type_1 and build/type_2.
> When running cmake in build/type_1, you should add -D_TYPE1_ to the
> preprocessor flags; same for build/type_2.
By 'build directories' you mean to duplicate the library sourcecodes?
Using the approach sketched in the original post, I have tried to create
different directories for holding objects and libs - so far without success.
---------
> Am 08/27/2009 01:37 PM Christian Ehrlicher wrote:
> Why? Does SET_TARGET_PROPERTIES() with COMPILE_FLAGS not work?
I tried something with SET_TARGET_PROPERTIES but when used on the target
sim_type1 the define-flag won't be inherited by the library the target
depends on, thus I used add_definitions instead
--------
I think the problem comes with using
add_subdirectory(../../VEHICLE VEHICLE)
and the subsequent
add_library(vehicle ${SRC})
While this sets up a binary directory local to the make-target, it also
creates CMake*-files 'globally', for all targets.
A brute-force-approach would be to remove those sources from the ${SRC}
in the add_library commands that need the -D_TYPE*_ defines and add them
to the source-list of add_executable(sim_type1 ...).
This would be awkward, would it work?
Thanks again,
Eike
More information about the CMake
mailing list