• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1add_subdirectory(includes)
2
3include_directories(
4  "${CMAKE_CURRENT_SOURCE_DIR}/includes"
5  "${CMAKE_CURRENT_BINARY_DIR}/includes"
6)
7
8add_definitions(-DBUILDING_NGHTTP2)
9
10set(NGHTTP2_SOURCES
11  nghttp2_pq.c nghttp2_map.c nghttp2_queue.c
12  nghttp2_frame.c
13  nghttp2_buf.c
14  nghttp2_stream.c nghttp2_outbound_item.c
15  nghttp2_session.c nghttp2_submit.c
16  nghttp2_helper.c
17  nghttp2_alpn.c
18  nghttp2_hd.c nghttp2_hd_huffman.c nghttp2_hd_huffman_data.c
19  nghttp2_version.c
20  nghttp2_priority_spec.c
21  nghttp2_option.c
22  nghttp2_callbacks.c
23  nghttp2_mem.c
24  nghttp2_http.c
25  nghttp2_rcbuf.c
26  nghttp2_extpri.c
27  nghttp2_ratelim.c
28  nghttp2_time.c
29  nghttp2_debug.c
30  sfparse.c
31)
32
33set(NGHTTP2_RES "")
34set(STATIC_LIB "nghttp2_static")
35set(SHARED_LIB "nghttp2")
36
37if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS AND MSVC AND NOT STATIC_LIB_SUFFIX)
38  set(STATIC_LIB_SUFFIX "_static")
39endif()
40
41if(WIN32)
42  configure_file(
43    version.rc.in
44    ${CMAKE_CURRENT_BINARY_DIR}/version.rc
45    @ONLY)
46
47  set(NGHTTP2_RES ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
48endif()
49
50set(EXPORT_SET "${PROJECT_NAME}-targets")
51
52# Public shared library
53if(BUILD_SHARED_LIBS)
54  add_library(${SHARED_LIB} SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES})
55
56  set_target_properties(${SHARED_LIB} PROPERTIES
57    COMPILE_FLAGS "${WARNCFLAGS}"
58    VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
59    C_VISIBILITY_PRESET hidden
60  )
61
62  target_include_directories(${SHARED_LIB} INTERFACE
63    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/includes>
64    $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/includes>
65    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
66  )
67
68  install(TARGETS ${SHARED_LIB} EXPORT ${EXPORT_SET})
69  list(APPEND nghttp2_exports ${SHARED_LIB})
70endif()
71
72# Static library (for unittests because of symbol visibility)
73if(BUILD_STATIC_LIBS)
74  add_library(${STATIC_LIB} STATIC ${NGHTTP2_SOURCES})
75
76  set_target_properties(${STATIC_LIB} PROPERTIES
77    COMPILE_FLAGS "${WARNCFLAGS}"
78    VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
79    ARCHIVE_OUTPUT_NAME nghttp2${STATIC_LIB_SUFFIX}
80  )
81
82  target_include_directories(${STATIC_LIB} INTERFACE
83    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/includes>
84    $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/includes>
85    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
86  )
87
88  target_compile_definitions(${STATIC_LIB} PUBLIC "-DNGHTTP2_STATICLIB")
89
90  install(TARGETS ${STATIC_LIB} EXPORT ${EXPORT_SET})
91  list(APPEND nghttp2_exports ${STATIC_LIB})
92endif()
93
94if(BUILD_SHARED_LIBS)
95  set(LIB_SELECTED ${SHARED_LIB})
96else()
97  set(LIB_SELECTED ${STATIC_LIB})
98endif()
99
100add_library(${PROJECT_NAME}::nghttp2 ALIAS ${LIB_SELECTED})
101
102install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnghttp2.pc"
103  DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
104
105install(EXPORT ${EXPORT_SET}
106  DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
107  NAMESPACE ${PROJECT_NAME}::)
108