[Cmake] CMake Newbie (Trying to understand ADD_DEFINITIONS)

Alexander Neundorf a.neundorf-work at gmx.net
Mon Aug 23 02:03:36 EDT 2004


Hi, 
 
> I want to have 2 executables built with the same files, but one executable

> needs an extra -D (for a different debugging level.) 
>  
> I've tried this: 
>  
> ADD_EXECUTABLE( application application.cpp ) 
> TARGET_LINK_LIBRARIES( application mylib ) 
>  
> ADD_DEFINITIONS( -DHYPER_DEBUG=1 ) 
> ADD_EXECUTABLE( application_no_ship application.cpp ) 
> TARGET_LINK_LIBRARIES( application mylib ) 
> REMOVE_DEFINITIONS( -DHYPER_DEBUG=1 ) 
>  
> But, from looking at the Makefile generated, it seems that all 
> applications  
> built use the same preprocessor definitions.  Is there an easy way to 
> define  
> different things at the application level? 
You could organize your sources the following way: 
 
src/main.cpp  
src/no_debug/CMakeLists.txt    
   contains "../main.cpp" 
src/hyper_debug/CMakeLists.txt  
   contains "../main.cpp" and ADD_DEFINTIIONS("-DHYPER_DEBUG) 
 
Then you can build your app two times with different settings. 
 
Bye 
Alex 
 

-- 
NEU: Bis zu 10 GB Speicher für e-mails & Dateien!
1 GB bereits bei GMX FreeMail http://www.gmx.net/de/go/mail



More information about the Cmake mailing list