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

Kermit Mei kermit.mei at gmail.com
Sat Feb 28 06:47:02 EST 2009


Enrico Franchi wrote:
>
> On Feb 28, 2009, at 10:48 AM, Kermit Mei wrote:
>
>> Hello, is there any elegant way to add "-DDEBUG" to the complier flag
>> just in command line?
>
> IF(${CMAKE_BUILD_TYPE} STREQUAL Debug)
> MESSAGE("Adding Debug flag...")
> ADD_DEFINITIONS(-DDEBUG)
> ENDIF(${CMAKE_BUILD_TYPE} STREQUAL Debug)
>
Thanks, but when I run without debug, something goes wrong:
$ cmake -DCMAKE_INSTALL_PREFIX=/usr ..
CMake Error at CMakeLists.txt:9 (IF):
if had incorrect arguments: ${CMAKE_BUILD_TYPE} STREQUAL Debug (Unknown 
arguments specified).
... ...
Adding Debug flag...


As you see, Whenever I set -DCMAKE_BUILD_TYPE=Debug,
the statement within if-endif is always be run.





More information about the CMake mailing list