CMakeLists.txt revision a74702c6
1# Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc.  See LICENSE.
2SET(lsquic_STAT_SRCS
3    ls-qpack/lsqpack.c
4    lsquic_adaptive_cc.c
5    lsquic_alarmset.c
6    lsquic_arr.c
7    lsquic_attq.c
8    lsquic_bbr.c
9    lsquic_bw_sampler.c
10    lsquic_cfcw.c
11    lsquic_chsk_stream.c
12    lsquic_conn.c
13    lsquic_crand.c
14    lsquic_crt_compress.c
15    lsquic_crypto.c
16    lsquic_cubic.c
17    lsquic_di_error.c
18    lsquic_di_hash.c
19    lsquic_di_nocopy.c
20    lsquic_enc_sess_common.c
21    lsquic_enc_sess_ietf.c
22    lsquic_eng_hist.c
23    lsquic_engine.c
24    lsquic_ev_log.c
25    lsquic_frab_list.c
26    lsquic_frame_common.c
27    lsquic_frame_reader.c
28    lsquic_frame_writer.c
29    lsquic_full_conn.c
30    lsquic_full_conn_ietf.c
31    lsquic_global.c
32    lsquic_handshake.c
33    lsquic_hash.c
34    lsquic_hcsi_reader.c
35    lsquic_hcso_writer.c
36    lsquic_headers_stream.c
37    lsquic_hkdf.c
38    lsquic_hpi.c
39    lsquic_hspack_valid.c
40    lsquic_http.c
41    lsquic_http1x_if.c
42    lsquic_logger.c
43    lsquic_malo.c
44    lsquic_min_heap.c
45    lsquic_mini_conn.c
46    lsquic_mini_conn_ietf.c
47    lsquic_minmax.c
48    lsquic_mm.c
49    lsquic_pacer.c
50    lsquic_packet_common.c
51    lsquic_packet_gquic.c
52    lsquic_packet_in.c
53    lsquic_packet_out.c
54    lsquic_packet_resize.c
55    lsquic_parse_Q046.c
56    lsquic_parse_Q050.c
57    lsquic_parse_common.c
58    lsquic_parse_gquic_be.c
59    lsquic_parse_gquic_common.c
60    lsquic_parse_ietf_v1.c
61    lsquic_parse_iquic_common.c
62    lsquic_pr_queue.c
63    lsquic_purga.c
64    lsquic_qdec_hdl.c
65    lsquic_qenc_hdl.c
66    lsquic_qlog.c
67    lsquic_qpack_exp.c
68    lsquic_rechist.c
69    lsquic_rtt.c
70    lsquic_send_ctl.c
71    lsquic_senhist.c
72    lsquic_set.c
73    lsquic_sfcw.c
74    lsquic_shsk_stream.c
75    lsquic_spi.c
76    lsquic_stock_shi.c
77    lsquic_str.c
78    lsquic_stream.c
79    lsquic_tokgen.c
80    lsquic_trans_params.c
81    lsquic_trechist.c
82    lsquic_util.c
83    lsquic_varint.c
84    lsquic_version.c
85)
86
87IF(NOT MSVC)
88    SET(QPACK_FLAGS "-Wno-uninitialized")
89    INCLUDE(CheckCCompilerFlag)
90    CHECK_C_COMPILER_FLAG(-Wno-implicit-fallthrough HAS_NO_IMPLICIT_FALLTHROUGH)
91    IF (HAS_NO_IMPLICIT_FALLTHROUGH)
92        SET(QPACK_FLAGS "${QPACK_FLAGS} -Wno-implicit-fallthrough")
93    ENDIF()
94set_source_files_properties(ls-qpack/lsqpack.c PROPERTIES COMPILE_FLAGS ${QPACK_FLAGS})
95ENDIF()
96
97include_directories(ls-qpack)
98
99IF(PROJECT_NAME STREQUAL "openlitespeed")
100    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/spdy)
101ELSE()
102    INCLUDE_DIRECTORIES(../lshpack)
103    SET(lsquic_STAT_SRCS ${lsquic_STAT_SRCS}
104        lsquic_xxhash.c
105        ../lshpack/lshpack.c
106    )
107ENDIF()
108
109ADD_CUSTOM_COMMAND(
110    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lsquic_versions_to_string.c
111    COMMAND ${PERL}
112    ARGS ${CMAKE_CURRENT_SOURCE_DIR}/gen-verstrs.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../include/lsquic.h ${CMAKE_CURRENT_BINARY_DIR}/lsquic_versions_to_string.c
113    DEPENDS ./gen-verstrs.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../include/lsquic.h
114)
115SET(lsquic_STAT_SRCS ${lsquic_STAT_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/lsquic_versions_to_string.c)
116SET(lsquic_STAT_SRCS ${lsquic_STAT_SRCS} ls-sfparser.c)
117
118SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXXH_HEADER_NAME=\\\"lsquic_xxhash.h\\\"")
119SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQPACK_ENC_LOGGER_HEADER=\\\"lsquic_qpack_enc_logger.h\\\"")
120SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQPACK_DEC_LOGGER_HEADER=\\\"lsquic_qpack_dec_logger.h\\\"")
121
122if(NEED_LIBRT_FOR_clock_getres)
123    target_link_libraries(lsquic PRIVATE ${RT_LIBRARY})
124endif()
125
126IF(LSQUIC_SHARED_LIB)
127  add_library(lsquic SHARED ${lsquic_STAT_SRCS})
128  TARGET_LINK_LIBRARIES(lsquic PRIVATE ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB})
129  IF(MSVC)
130    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_EXPORTS")
131  TARGET_LINK_LIBRARIES(lsquic PRIVATE ws2_32.lib)
132  ENDIF()
133ELSE()
134  add_library(lsquic STATIC ${lsquic_STAT_SRCS})
135ENDIF()
136
137target_include_directories(
138    lsquic PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lsquic>)
139
140install(TARGETS lsquic
141    EXPORT lsquic-targets
142    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
143    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
144)
145
146include(CMakePackageConfigHelpers)
147configure_package_config_file(
148    lsquic-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/lsquic-config.cmake
149    INSTALL_DESTINATION share/lsquic
150    NO_CHECK_REQUIRED_COMPONENTS_MACRO
151    PATH_VARS CMAKE_INSTALL_INCLUDEDIR)
152
153install(
154    FILES ${CMAKE_CURRENT_BINARY_DIR}/lsquic-config.cmake
155    DESTINATION share/lsquic)
156
157install(
158    EXPORT lsquic-targets
159    DESTINATION share/lsquic
160    NAMESPACE lsquic::
161    FILE lsquic-targets.cmake)
162
163