Fix `option(BUILD_SHARED_LIBS …)`

* Fix order of arguments
* Keep building static libraries by default to stick with CMake's default
  except when devel defaults are enabled and we're targeting GNU/Linux
This commit is contained in:
Martchus 2021-08-21 23:39:17 +02:00
parent c2ab0d8e29
commit f55dc67a93
1 changed files with 6 additions and 1 deletions

View File

@ -413,7 +413,12 @@ elseif ("${META_PROJECT_TYPE}" STREQUAL "application")
set(META_PROJECT_IS_APPLICATION YES)
endif ()
if (META_PROJECT_IS_LIBRARY)
option(BUILD_SHARED_LIBS ON "whether to build shared or static libraries")
# when development defaults are enabled, build shared libs by default when targeting GNU/Linux
set(BUILD_SHARED_LIBS_BY_DEFAULT "${BUILD_SHARED_LIBS}")
if (ENABLE_DEVEL_DEFAULTS AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(BUILD_SHARED_LIBS_BY_DEFAULT ON)
endif ()
option(BUILD_SHARED_LIBS "whether to build shared or static libraries" "${BUILD_SHARED_LIBS_BY_DEFAULT}")
option(
STATIC_LIBRARY_LINKAGE
"prefer linking against dependencies statically; adds additional flags for static linkage; only applies when building shared libraries"