cmake: fix symbol visibility issues
libnghttp2.so was missing -fvisibility=hidden. libnghttp2_asio.so on the other hand had hidden visibility which resulted in no exported symbols and a broken asio client examples. Just build a static nghttp2 library to solve this issue.
This commit is contained in:
parent
f4b2a4ab00
commit
77e8190b6c
|
@ -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}
|
||||
|
|
|
@ -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 $<TARGET_OBJECTS:nghttp2-obj>)
|
||||
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}")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -26,10 +26,12 @@ if(HAVE_CUNIT)
|
|||
|
||||
add_executable(main EXCLUDE_FROM_ALL
|
||||
${MAIN_SOURCES}
|
||||
$<TARGET_OBJECTS:nghttp2-obj>
|
||||
)
|
||||
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_OBJECTS:nghttp2-obj>
|
||||
)
|
||||
target_link_libraries(failmalloc ${CUNIT_LIBRARIES})
|
||||
target_link_libraries(failmalloc
|
||||
nghttp2_static
|
||||
${CUNIT_LIBRARIES}
|
||||
)
|
||||
add_test(failmalloc failmalloc)
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue