[CMake] How the heck does one set options?

Dan Kegel dank at kegel.com
Wed Nov 2 21:36:57 EDT 2011


On Wed, Nov 2, 2011 at 6:21 PM, Tim Gallagher <tim.gallagher at gatech.edu> wrote:
> Using set() as you have done only sets the value in the current scoping unit. If you did:
>
> set(gtest_force_shared_crt ON CACHE INTERNAL "")
>
> then it will be set to ON and hidden from the GUI display.
>
> If it will always be a bool and you want it displayed on the GUI, you can also do:
>
> option(gtest_force_shared_crt ON)

Tried it, no change, still broken.

$ grep gtest_force_shared_crt CMakeLists.txt build/CMakeCache.txt
CMakeLists.txt:option(gtest_force_shared_crt ON)
build/CMakeCache.txt:gtest_force_shared_crt:BOOL=OFF

--trace shows

CMakeLists.txt(23):  option(gtest_force_shared_crt ON )
gtest/CMakeLists.txt(14):  option(gtest_force_shared_crt Use shared
(DLL) run-time lib even when Google Test is built as static lib. OFF )

So, now what?  How does one set an option declared by a subdirectory
before entering that subdirectory?  Lots of people use gtest, surely
someone has run into this before.
- Dan


More information about the CMake mailing list