Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake option default value

Tags:

c++

cmake

If I have a CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8)

OPTION(FOO "Foo Option" OFF)

MESSAGE("FOO? " ${FOO})

And then I call cmake on it, I get the following output:

FOO? ON

Why is this? Haven't I specified the default for FOO is to be OFF?

like image 754
Karnivaurus Avatar asked Feb 11 '23 13:02

Karnivaurus


2 Answers

Delete CMakeCache.txt from build directory and reload project. This happens because CMake is caching global variables

like image 173
AshFTW Avatar answered Feb 15 '23 11:02

AshFTW


Try this:

SET(FOO OFF CACHE BOOL "Foo Option")

or

SET(FOO OFF CACHE BOOL "Foo Option" FORCE)
like image 44
Korbi Avatar answered Feb 15 '23 11:02

Korbi