diff --git a/CMakeLists.txt b/CMakeLists.txt index 13d11b90..04fddf55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,11 +347,6 @@ if(NOT CMAKE_C_COMPILER_ID STREQUAL "MSVC") ) endif() -set(EXTRACFLAG) -extract_valid_c_flags(EXTRACFLAG - -fvisibility=hidden -) - if(ENABLE_DEBUG) set(DEBUGBUILD 1) endif() @@ -449,7 +444,6 @@ message(STATUS "summary of build options: CXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_build_type}} WARNCFLAGS: ${WARNCFLAGS} CXX1XCXXFLAGS: ${CXX1XCXXFLAGS} - EXTRACFLAG: ${EXTRACFLAG} Library: Shared: ${enable_shared} Static: ${enable_static} diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 7b012acb..a6adc04d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -24,14 +24,24 @@ set(NGHTTP2_SOURCES nghttp2_http.c ) -add_library(nghttp2-obj OBJECT ${NGHTTP2_SOURCES}) +# Public shared library +add_library(nghttp2 SHARED ${NGHTTP2_SOURCES}) # Needed because the object files are linked into a shared library. -set_target_properties(nghttp2-obj PROPERTIES - POSITION_INDEPENDENT_CODE ON) -add_library(nghttp2 SHARED $) set_target_properties(nghttp2 PROPERTIES - COMPILE_FLAGS "${WARNCFLAGS} ${EXTRACFLAG}" - VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}) + COMPILE_FLAGS "${WARNCFLAGS}" + VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION} + C_VISIBILITY_PRESET hidden +) + +if(HAVE_CUNIT) + # Static library (for unittests because of symbol visibility) + add_library(nghttp2_static STATIC ${NGHTTP2_SOURCES}) + set_target_properties(nghttp2_static PROPERTIES + COMPILE_FLAGS "${WARNCFLAGS}" + VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION} + ARCHIVE_OUTPUT_NAME nghttp2 + ) +endif() install(TARGETS nghttp2 LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08c89b0e..1d6af25c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -248,7 +248,6 @@ if(ENABLE_ASIO_LIB) ) # XXX use add_compile_options with a list instead of COMPILE_FLAGS set_target_properties(nghttp2_asio PROPERTIES - COMPILE_FLAGS "${EXTRACFLAG}" VERSION 1.0.0 SOVERSION 1) install(TARGETS nghttp2_asio diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1ffa16c7..5a641834 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,10 +26,12 @@ if(HAVE_CUNIT) add_executable(main EXCLUDE_FROM_ALL ${MAIN_SOURCES} - $ ) target_include_directories(main PRIVATE ${CUNIT_INCLUDE_DIRS}) - target_link_libraries(main ${CUNIT_LIBRARIES}) + target_link_libraries(main + nghttp2_static + ${CUNIT_LIBRARIES} + ) add_test(main main) if(ENABLE_FAILMALLOC) @@ -40,9 +42,11 @@ if(HAVE_CUNIT) ) add_executable(failmalloc EXCLUDE_FROM_ALL ${FAILMALLOC_SOURCES} - $ ) - target_link_libraries(failmalloc ${CUNIT_LIBRARIES}) + target_link_libraries(failmalloc + nghttp2_static + ${CUNIT_LIBRARIES} + ) add_test(failmalloc failmalloc) endif()