Merge pull request #1285 from staticinvocation/master

Add a CMake option to disable shared library
This commit is contained in:
Tatsuhiro Tsujikawa 2019-01-05 09:40:54 +09:00 committed by GitHub
commit 9cc412e2fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View File

@ -15,6 +15,7 @@ option(ENABLE_PYTHON_BINDINGS "Build Python bindings"
option(ENABLE_FAILMALLOC "Build failmalloc test program" ON) option(ENABLE_FAILMALLOC "Build failmalloc test program" ON)
option(ENABLE_LIB_ONLY "Build libnghttp2 only. This is a short hand for -DENABLE_APP=0 -DENABLE_EXAMPLES=0 -DENABLE_HPACK_TOOLS=0 -DENABLE_PYTHON_BINDINGS=0") option(ENABLE_LIB_ONLY "Build libnghttp2 only. This is a short hand for -DENABLE_APP=0 -DENABLE_EXAMPLES=0 -DENABLE_HPACK_TOOLS=0 -DENABLE_PYTHON_BINDINGS=0")
option(ENABLE_STATIC_LIB "Build libnghttp2 in static mode also") option(ENABLE_STATIC_LIB "Build libnghttp2 in static mode also")
option(ENABLE_SHARED_LIB "Build libnghttp2 as a shared library" ON)
option(WITH_LIBXML2 "Use libxml2" option(WITH_LIBXML2 "Use libxml2"
${WITH_LIBXML2_DEFAULT}) ${WITH_LIBXML2_DEFAULT})

View File

@ -38,6 +38,7 @@ if(WIN32)
endif() endif()
# Public shared library # Public shared library
if(ENABLE_SHARED_LIB)
add_library(nghttp2 SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES}) add_library(nghttp2 SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES})
set_target_properties(nghttp2 PROPERTIES set_target_properties(nghttp2 PROPERTIES
COMPILE_FLAGS "${WARNCFLAGS}" COMPILE_FLAGS "${WARNCFLAGS}"
@ -49,6 +50,10 @@ target_include_directories(nghttp2 INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/includes" "${CMAKE_CURRENT_SOURCE_DIR}/includes"
) )
install(TARGETS nghttp2
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()
if(HAVE_CUNIT OR ENABLE_STATIC_LIB) if(HAVE_CUNIT OR ENABLE_STATIC_LIB)
# Static library (for unittests because of symbol visibility) # Static library (for unittests because of symbol visibility)
add_library(nghttp2_static STATIC ${NGHTTP2_SOURCES}) add_library(nghttp2_static STATIC ${NGHTTP2_SOURCES})
@ -64,8 +69,6 @@ if(HAVE_CUNIT OR ENABLE_STATIC_LIB)
endif() endif()
endif() endif()
install(TARGETS nghttp2
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnghttp2.pc" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnghttp2.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")