[Cmake] ADD_DEFINITION to a specific target
Andy Cedilnik
andy.cedilnik at kitware.com
Wed Apr 9 14:11:10 EDT 2003
Hi Marc,
Unfortunately it is a lot of work.
This is what you do. Create two subdirectories MyLib and MyLib_FOO. In
them set sources to be a list of sources with paths specified from
toplevel project directory:
PROJECT(foo)
then you do in MyLib:
ADD_LIBRARY(MyLib ${foo_SOURCE_DIR}/src/fic1.cxx
${foo_SOURCE_DIR}/src/fic2.cxx)
and in MyLib_FOO:
ADD_LIBRARY(MyLib_FOO ${foo_SOURCE_DIR}/src/fic1.cxx
${foo_SOURCE_DIR}/src/fic2.cxx)
While sources are still in the same directory ${foo_SOURCE_DIR}/src.
This will create separate object files and everything. Then you just put
whatever library specific things you want.
Andy
On Wed, 2003-04-09 at 13:40, Marc Traina wrote:
> Hi,
>
> How can I create several libraries from the same source files with
> different compilation flags ?
>
> I would like to use a command like ADD_DEFINITIONS but specific to a
> target, for instance TARGET_ADD_DEFINITIONS.
> *||*
> Example :
> ADD_DEFINITIONS(-DBAR)
> ADD_LIBRARY(MyLib fic1.cxx fic2.cxx)
> ADD_LIBRARY(MyLib_FOO fic1.cxx fic2.cxx)
> TARGET_ADD_DEFINITIONS(MyLib_FOO -DFOO)
>
> automake manage that by prefixing the ".o" files by the name of the target.
> ex : MyLib_FOO_fic1.o and MyLib_FOO_fic2.o
>
> and link that two files to create MyLib_FOO library.
More information about the CMake
mailing list