[CMake] Add BUILD_SHARED_LIBS as an option

Mateusz Loskot mateusz at loskot.net
Tue Mar 28 07:22:14 EDT 2017


Hi,

The docs [1] say:

"This variable [BUILD_SHARED_LIBS] is often added to projects as an option()"

[1] https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

Does that literally mean adding the option this way?

option(BUILD_SHARED_LIBS "Build shared library" OFF)

Or, adding an extra level of indirection via custom option:

option(XXX_BUILD_SHARED "Build shared library" OFF)

if (XXX_BUILD_SHARED)
  set(BUILD_SHARED_LIBS ON)
endif()

I do realise it's question about docs pedantism, but I'd like to get
that cleared once for good :)
I'm trying to cut number of custom options and I'm never certain
how I can actually re/ab-use the standard CMake settings.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net


More information about the CMake mailing list