@@ -21,6 +21,23 @@ macro (restore_default_library_suffixes)
2121 unset (DEFAULT_CMAKE_FIND_LIBRARY_SUFFIXES)
2222endmacro ()
2323
24+ macro (save_library_preference)
25+ save_default_library_suffixes()
26+ set (DEFAULT_OPENSSL_USE_STATIC_LIBS ${OPENSSL_USE_STATIC_LIBS} )
27+ set (DEFAULT_Boost_USE_STATIC_LIBS ${Boost_USE_STATIC_LIBS} )
28+ set (DEFAULT_PKG_CONFIG_USE_STATIC_LIBS ${PKG_CONFIG_USE_STATIC_LIBS} )
29+ endmacro ()
30+
31+ macro (restore_library_preference)
32+ restore_default_library_suffixes()
33+ set (OPENSSL_USE_STATIC_LIBS ${DEFAULT_OPENSSL_USE_STATIC_LIBS} )
34+ unset (DEFAULT_OPENSSL_USE_STATIC_LIBS)
35+ set (Boost_USE_STATIC_LIBS ${DEFAULT_Boost_USE_STATIC_LIBS} )
36+ unset (DEFAULT_Boost_USE_STATIC_LIBS)
37+ set (PKG_CONFIG_USE_STATIC_LIBS ${DEFAULT_PKG_CONFIG_USE_STATIC_LIBS} )
38+ unset (DEFAULT_PKG_CONFIG_USE_STATIC_LIBS)
39+ endmacro ()
40+
2441macro (configure_static_library_suffixes)
2542 # allows to look for static libraries in particular NOTE: code duplicated in Config.cmake.in
2643 if (WIN32 )
@@ -41,6 +58,13 @@ macro (configure_dynamic_library_suffixes)
4158 endif ()
4259endmacro ()
4360
61+ macro (prefer_static_libraries)
62+ set (OPENSSL_USE_STATIC_LIBS ON )
63+ set (Boost_USE_STATIC_LIBS ON )
64+ set (PKG_CONFIG_USE_STATIC_LIBS ON )
65+ configure_static_library_suffixes()
66+ endmacro ()
67+
4468function (validate_visibility VISIBILITY)
4569 if (NOT (VISIBILITY STREQUAL PUBLIC OR VISIBILITY STREQUAL PRIVATE ))
4670 message (FATAL_ERROR "Specified visibility ${VISIBILITY} is invalid (must be either PUBLIC or PRIVATE)." )
@@ -494,12 +518,7 @@ if ((STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION) OR (STATIC_LIBRARY_LINKAGE
494518 endif ()
495519 list (APPEND META_ADDITIONAL_LINK_FLAGS_TEST_TARGET ${STATIC_LINKAGE_LINKER_FLAGS} )
496520
497- # prefer static libraries
498- set (OPENSSL_USE_STATIC_LIBS ON )
499- set (Boost_USE_STATIC_LIBS ON )
500- set (PKG_CONFIG_USE_STATIC_LIBS ON )
501- configure_static_library_suffixes()
502-
521+ prefer_static_libraries()
503522else ()
504523 set (STATIC_LINKAGE_CONFIGURED OFF )
505524endif ()
0 commit comments