nick
nick

Reputation: 872

How to check my cmake using debug or release?

I want to check default cmake build mode.

when i do this:

message(${CMAKE_BUILD_TYPE})

it comes out:

CMake Error at CMakeLists.txt:9 (message):
  message called with incorrect number of arguments

seems not existed environment variable ${CMAKE_BUILD_TYPE}.

I also read some blogs, which said, i can:

cmake -L . | grep CMAKE_BUILD_TYPE

to check, but i got:

CMAKE_BUILD_TYPE:STRING=

So, how to check my cmake default build mode?

I want to use release mode, but seems

cmake ..

and

cmake .. -DCMAKE_BUILD_TYPE=Release

make no difference in the messages.

Could you help on this?

Upvotes: 1

Views: 1995

Answers (1)

DevSolar
DevSolar

Reputation: 70391

The default is that CMAKE_BUILD_TYPE is undefined, which equates to a toolchain-specific implicit default.

Personally I add something like...

if ( NOT CMAKE_BUILD_TYPE )
    message( "Build Type not set, defaulting to Debug..." )
    set( CMAKE_BUILD_TYPE Debug )
endif()

...both to make the default explicit, and to default to Debug, as you usually build that much more often than the Release configuration.

Upvotes: 3

Related Questions