In a project using cmake, I build two versions of a library, one statically and one dynamically linked. For a single source file, I want to pass a different compile definition (i.e. -Dfoo=bar
) when compiling for the shared library only.
I know about set_target_properties
where I can use the COMPILE_DEFINITIONS
for a single source, but I don't know how to add that definition only for the shared library.
How can this be done?
Edit
To clarify how this question is different, I am already making two versions of the same library.
add_library(static_lib STATIC foo.cpp bar.cpp)
add_library(dyn_lib SHARED foo.cpp bar.cpp)
What I would like to do is to add the target property that foo.cpp
is compiled with -Dbaz=True
only when compiling foo.cpp
for dyn_lib
.