[Cmake] CMake Newbie (Trying to understand ADD_DEFINITIONS)
Brad King
brad.king at kitware.com
Sat Aug 21 08:58:57 EDT 2004
On Fri, 20 Aug 2004, Brand Hunt wrote:
> I want to have 2 executables built with the same files, but one executable
> needs an extra -D (for a different debugging level.)
Currently CMake supports one .o file per source file per directory. The
generated makefile has a single rule to build "application.o" in your
example. This means that it can be built with only one set of flags.
There is currently no support for a .o file per source file per target,
but this feature may be added in the future.
> ADD_EXECUTABLE( application application.cpp )
> TARGET_LINK_LIBRARIES( application mylib )
>
> ADD_EXECUTABLE( application_no_ship application.cpp )
> TARGET_LINK_LIBRARIES( application mylib )
You can add a source file
// application_no_ship.cpp
#define HYPER_DEBUG 1
#include "application.cpp"
Then use that source file for the second executable. Using the FOREACH
and CONFIGURE_FILE commands you can automate the generation of these extra
source files from the list of originals.
-Brad
More information about the Cmake
mailing list