[CMake] How to add "-DDEBUG" just in command line?

Kermit Mei kermit.mei at gmail.com
Sat Feb 28 04:48:33 EST 2009


Hello, is there any elegant way to add "-DDEBUG" to the complier flag
just in command line?


I don't want to modify my CMakeLists.txt file, I just want to build it when
I run :
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr ..

I tried the following command in CMakeLists.txt:

IF(CMAKE_BUILD_TYPE == debug)
  add_definitions(-DDEBUG)
ENDIF()

But nothing did ...

Thanks


More information about the CMake mailing list