From af225b5975a5b8a4e5188829fbc235a83bc70d3c Mon Sep 17 00:00:00 2001 From: Peter Wu <peter@lekensteyn.nl> Date: Fri, 8 May 2020 19:47:16 +0200 Subject: [PATCH] CMake: add BUILD_SHARED_LIBS option Prior to commit 4e955731d3a6ac344a593ee9d9c5d00982846adf, ngtcp2 was built as shared library. That has changed into a static or shared library depending on the BUILD_SHARED_LIBS option, but this option was not documented and the comments were misleading. Rectify both issues. Note that autotools builds both libraries by default, but the current CMake config is only able to build one of them. --- CMakeLists.txt | 2 ++ CMakeOptions.txt | 2 ++ crypto/gnutls/CMakeLists.txt | 2 +- crypto/openssl/CMakeLists.txt | 2 +- lib/CMakeLists.txt | 4 ++-- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6fcaa54..23fbc571 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,6 +313,8 @@ message(STATUS "summary of build options: CXXFLAGS: ${CMAKE_CXX_FLAGS_${_build_type}} ${CMAKE_CXX_FLAGS} WARNCFLAGS: ${WARNCFLAGS} WARNCXXFLAGS: ${WARNCXXFLAGS} + Library: + Shared: ${BUILD_SHARED_LIBS} Test: CUnit: ${HAVE_CUNIT} (LIBS='${CUNIT_LIBRARIES}') Libs: diff --git a/CMakeOptions.txt b/CMakeOptions.txt index 6172d307..92c41fe9 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -1,5 +1,7 @@ # Features that can be enabled for cmake (see CMakeLists.txt) +option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) + option(ENABLE_WERROR "Make compiler warnings fatal" OFF) option(ENABLE_DEBUG "Turn on debug output" OFF) option(ENABLE_ASAN "Enable AddressSanitizer (ASAN)" OFF) diff --git a/crypto/gnutls/CMakeLists.txt b/crypto/gnutls/CMakeLists.txt index bf5cfd8c..575fc3fe 100644 --- a/crypto/gnutls/CMakeLists.txt +++ b/crypto/gnutls/CMakeLists.txt @@ -41,7 +41,7 @@ foreach(name libngtcp2_crypto_gnutls.pc) configure_file("${name}.in" "${name}" @ONLY) endforeach() -# Public shared library +# Public shared or static library add_library(ngtcp2_crypto_gnutls ${ngtcp2_crypto_gnutls_SOURCES}) set_target_properties(ngtcp2_crypto_gnutls PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" diff --git a/crypto/openssl/CMakeLists.txt b/crypto/openssl/CMakeLists.txt index 430693aa..a12d93aa 100644 --- a/crypto/openssl/CMakeLists.txt +++ b/crypto/openssl/CMakeLists.txt @@ -41,7 +41,7 @@ foreach(name libngtcp2_crypto_openssl.pc) configure_file("${name}.in" "${name}" @ONLY) endforeach() -# Public shared library +# Public shared or static library add_library(ngtcp2_crypto_openssl ${ngtcp2_crypto_openssl_SOURCES}) set_target_properties(ngtcp2_crypto_openssl PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 6f8f6f45..fc3d8cfd 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -64,7 +64,7 @@ set(ngtcp2_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/includes" ) -# Public shared library +# Public shared or static library add_library(ngtcp2 ${ngtcp2_SOURCES}) set_target_properties(ngtcp2 PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" @@ -79,7 +79,7 @@ if(NOT BUILD_SHARED_LIBS) endif() if(HAVE_CUNIT) - # Static library (for unittests because of symbol visibility) + # Private static library (for unittests because of symbol visibility) add_library(ngtcp2_static STATIC ${ngtcp2_SOURCES}) set_target_properties(ngtcp2_static PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" -- GitLab