Meysam
Meysam

Reputation: 18127

CMake: How to check if some flag has been defined

I've got something like this in the CMakeLists file:

set(CMAKE_CXX_FLAGS "-g -Wextra -DFLAG1=A")

Later in the file, I need to check if FLAG1 has been defined. Is it possible to do something like this?

IF(${FLAG1} EQUAL A)
    #Do something
ELSE()
    #Do something else
ENDIF()

Upvotes: 1

Views: 4732

Answers (1)

arrowd
arrowd

Reputation: 34391

Well, you can do

set(FLAG1 A)
set(CMAKE_CXX_FLAGS "-g -Wextra -DFLAG1=${FLAG1}")
...
if(${FLAG1} STREQUAL A)
...

Upvotes: 3

Related Questions