My program needs FOO
or BAR
macro defined, but not both. By default, FOO
is defined. Following is the snippet of CMakeList.txt
:
OPTION(BAR "BAR" OFF)
OPTION(FOO "FOO" ON)
IF(BAR)
SET(FOO OFF CACHE BOOL "Use BAR" FORCE)
MESSAGE(STATUS "Use BAR\n")
ADD_DEFINITIONS(-DBAR)
ELSE()
MESSAGE(STATUS "Use FOO\n")
ADD_DEFINITIONS(-DFOO)
ENDIF()
Notice: for simplicity, I just use the same name for macro and option variable. It may not be what you want.