Allow overriding BUILD_SHARED_LIBS via a project-specific cache variable

This commit is contained in:
Martchus 2021-09-11 17:07:43 +02:00
parent af0294f0fb
commit 6d0148e2c3
2 changed files with 8 additions and 2 deletions

View File

@ -115,7 +115,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parser, IO and conversion utilities")
set(META_VERSION_MAJOR 5)
set(META_VERSION_MINOR 11)
set(META_VERSION_PATCH 1)
set(META_VERSION_PATCH 2)
# find required 3rd party libraries
include(3rdParty)

View File

@ -418,7 +418,13 @@ if (META_PROJECT_IS_LIBRARY)
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}")
if (DEFINED CACHE{${META_PROJECT_VARNAME}_BUILD_SHARED_LIBS})
# allow overriding BUILD_SHARED_LIBS via a project-specific cache variable
set(BUILD_SHARED_LIBS "${${META_PROJECT_VARNAME}_BUILD_SHARED_LIBS}")
else ()
# make BUILD_SHARED_LIBS an overridable cache variable
option(BUILD_SHARED_LIBS "whether to build shared or static libraries" "${BUILD_SHARED_LIBS_BY_DEFAULT}")
endif ()
option(
STATIC_LIBRARY_LINKAGE
"prefer linking against dependencies statically; adds additional flags for static linkage; only applies when building shared libraries"