1a74702c6SGeorge Wang# Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc.  See LICENSE.
250aadb33SDmitri TikhonovSET(lsquic_STAT_SRCS
35392f7a3SLiteSpeed Tech    ls-qpack/lsqpack.c
4b1a7c3f9SDmitri Tikhonov    lsquic_adaptive_cc.c
550aadb33SDmitri Tikhonov    lsquic_alarmset.c
65392f7a3SLiteSpeed Tech    lsquic_arr.c
75392f7a3SLiteSpeed Tech    lsquic_attq.c
85392f7a3SLiteSpeed Tech    lsquic_bbr.c
95392f7a3SLiteSpeed Tech    lsquic_bw_sampler.c
105392f7a3SLiteSpeed Tech    lsquic_cfcw.c
1150aadb33SDmitri Tikhonov    lsquic_chsk_stream.c
125392f7a3SLiteSpeed Tech    lsquic_conn.c
1310c41073SDmitri Tikhonov    lsquic_crand.c
145392f7a3SLiteSpeed Tech    lsquic_crt_compress.c
1550aadb33SDmitri Tikhonov    lsquic_crypto.c
165392f7a3SLiteSpeed Tech    lsquic_cubic.c
175392f7a3SLiteSpeed Tech    lsquic_di_error.c
185392f7a3SLiteSpeed Tech    lsquic_di_hash.c
195392f7a3SLiteSpeed Tech    lsquic_di_nocopy.c
205392f7a3SLiteSpeed Tech    lsquic_enc_sess_common.c
215392f7a3SLiteSpeed Tech    lsquic_enc_sess_ietf.c
225392f7a3SLiteSpeed Tech    lsquic_eng_hist.c
235392f7a3SLiteSpeed Tech    lsquic_engine.c
245392f7a3SLiteSpeed Tech    lsquic_ev_log.c
255392f7a3SLiteSpeed Tech    lsquic_frab_list.c
265392f7a3SLiteSpeed Tech    lsquic_frame_common.c
275392f7a3SLiteSpeed Tech    lsquic_frame_reader.c
285392f7a3SLiteSpeed Tech    lsquic_frame_writer.c
295392f7a3SLiteSpeed Tech    lsquic_full_conn.c
305392f7a3SLiteSpeed Tech    lsquic_full_conn_ietf.c
315392f7a3SLiteSpeed Tech    lsquic_global.c
3250aadb33SDmitri Tikhonov    lsquic_handshake.c
335392f7a3SLiteSpeed Tech    lsquic_hash.c
345392f7a3SLiteSpeed Tech    lsquic_hcsi_reader.c
355392f7a3SLiteSpeed Tech    lsquic_hcso_writer.c
365392f7a3SLiteSpeed Tech    lsquic_headers_stream.c
375392f7a3SLiteSpeed Tech    lsquic_hkdf.c
38fbc6cc04SDmitri Tikhonov    lsquic_hpi.c
395392f7a3SLiteSpeed Tech    lsquic_hspack_valid.c
40fbc6cc04SDmitri Tikhonov    lsquic_http.c
415392f7a3SLiteSpeed Tech    lsquic_http1x_if.c
4250aadb33SDmitri Tikhonov    lsquic_logger.c
4350aadb33SDmitri Tikhonov    lsquic_malo.c
445392f7a3SLiteSpeed Tech    lsquic_min_heap.c
455392f7a3SLiteSpeed Tech    lsquic_mini_conn.c
465392f7a3SLiteSpeed Tech    lsquic_mini_conn_ietf.c
475392f7a3SLiteSpeed Tech    lsquic_minmax.c
4850aadb33SDmitri Tikhonov    lsquic_mm.c
495392f7a3SLiteSpeed Tech    lsquic_pacer.c
505392f7a3SLiteSpeed Tech    lsquic_packet_common.c
515392f7a3SLiteSpeed Tech    lsquic_packet_gquic.c
525392f7a3SLiteSpeed Tech    lsquic_packet_in.c
535392f7a3SLiteSpeed Tech    lsquic_packet_out.c
54b8fa6195SDmitri Tikhonov    lsquic_packet_resize.c
555392f7a3SLiteSpeed Tech    lsquic_parse_Q046.c
567a8b2eceSDmitri Tikhonov    lsquic_parse_Q050.c
575392f7a3SLiteSpeed Tech    lsquic_parse_common.c
585392f7a3SLiteSpeed Tech    lsquic_parse_gquic_be.c
595392f7a3SLiteSpeed Tech    lsquic_parse_gquic_common.c
605392f7a3SLiteSpeed Tech    lsquic_parse_ietf_v1.c
615392f7a3SLiteSpeed Tech    lsquic_parse_iquic_common.c
625392f7a3SLiteSpeed Tech    lsquic_pr_queue.c
635392f7a3SLiteSpeed Tech    lsquic_purga.c
645392f7a3SLiteSpeed Tech    lsquic_qdec_hdl.c
655392f7a3SLiteSpeed Tech    lsquic_qenc_hdl.c
665392f7a3SLiteSpeed Tech    lsquic_qlog.c
67758aff32SDmitri Tikhonov    lsquic_qpack_exp.c
6850aadb33SDmitri Tikhonov    lsquic_rechist.c
6950aadb33SDmitri Tikhonov    lsquic_rtt.c
7050aadb33SDmitri Tikhonov    lsquic_send_ctl.c
7150aadb33SDmitri Tikhonov    lsquic_senhist.c
725392f7a3SLiteSpeed Tech    lsquic_set.c
7350aadb33SDmitri Tikhonov    lsquic_sfcw.c
745392f7a3SLiteSpeed Tech    lsquic_shsk_stream.c
755392f7a3SLiteSpeed Tech    lsquic_spi.c
765392f7a3SLiteSpeed Tech    lsquic_stock_shi.c
775392f7a3SLiteSpeed Tech    lsquic_str.c
7850aadb33SDmitri Tikhonov    lsquic_stream.c
795392f7a3SLiteSpeed Tech    lsquic_tokgen.c
805392f7a3SLiteSpeed Tech    lsquic_trans_params.c
81fbc6cc04SDmitri Tikhonov    lsquic_trechist.c
8250aadb33SDmitri Tikhonov    lsquic_util.c
835392f7a3SLiteSpeed Tech    lsquic_varint.c
8450aadb33SDmitri Tikhonov    lsquic_version.c
855392f7a3SLiteSpeed Tech)
865392f7a3SLiteSpeed Tech
87fb3e20e0SDmitri TikhonovIF(NOT MSVC)
8899a1ad0fSDmitri Tikhonov    SET(QPACK_FLAGS "-Wno-uninitialized")
8999a1ad0fSDmitri Tikhonov    INCLUDE(CheckCCompilerFlag)
9099a1ad0fSDmitri Tikhonov    CHECK_C_COMPILER_FLAG(-Wno-implicit-fallthrough HAS_NO_IMPLICIT_FALLTHROUGH)
9199a1ad0fSDmitri Tikhonov    IF (HAS_NO_IMPLICIT_FALLTHROUGH)
9299a1ad0fSDmitri Tikhonov        SET(QPACK_FLAGS "${QPACK_FLAGS} -Wno-implicit-fallthrough")
9399a1ad0fSDmitri Tikhonov    ENDIF()
9499a1ad0fSDmitri Tikhonovset_source_files_properties(ls-qpack/lsqpack.c PROPERTIES COMPILE_FLAGS ${QPACK_FLAGS})
95fb3e20e0SDmitri TikhonovENDIF()
9650aadb33SDmitri Tikhonov
975392f7a3SLiteSpeed Techinclude_directories(ls-qpack)
985392f7a3SLiteSpeed Tech
995392f7a3SLiteSpeed TechIF(PROJECT_NAME STREQUAL "openlitespeed")
1005392f7a3SLiteSpeed Tech    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/spdy)
1015392f7a3SLiteSpeed TechELSE()
10283506617SDmitri Tikhonov    INCLUDE_DIRECTORIES(../lshpack)
1035392f7a3SLiteSpeed Tech    SET(lsquic_STAT_SRCS ${lsquic_STAT_SRCS}
1045392f7a3SLiteSpeed Tech        lsquic_xxhash.c
1055392f7a3SLiteSpeed Tech        ../lshpack/lshpack.c
1065392f7a3SLiteSpeed Tech    )
1075392f7a3SLiteSpeed TechENDIF()
10850aadb33SDmitri Tikhonov
1095392f7a3SLiteSpeed TechADD_CUSTOM_COMMAND(
110454939cdSRyan A. Pavlik    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lsquic_versions_to_string.c
111fb3e20e0SDmitri Tikhonov    COMMAND ${PERL}
112454939cdSRyan A. Pavlik    ARGS ${CMAKE_CURRENT_SOURCE_DIR}/gen-verstrs.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../include/lsquic.h ${CMAKE_CURRENT_BINARY_DIR}/lsquic_versions_to_string.c
1131245d2e0SDmitri Tikhonov    DEPENDS ./gen-verstrs.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../include/lsquic.h
1145392f7a3SLiteSpeed Tech)
115454939cdSRyan A. PavlikSET(lsquic_STAT_SRCS ${lsquic_STAT_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/lsquic_versions_to_string.c)
116fbc6cc04SDmitri TikhonovSET(lsquic_STAT_SRCS ${lsquic_STAT_SRCS} ls-sfparser.c)
11750aadb33SDmitri Tikhonov
118bea64822SDmitri TikhonovSET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXXH_HEADER_NAME=\\\"lsquic_xxhash.h\\\"")
1195392f7a3SLiteSpeed TechSET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQPACK_ENC_LOGGER_HEADER=\\\"lsquic_qpack_enc_logger.h\\\"")
1205392f7a3SLiteSpeed TechSET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQPACK_DEC_LOGGER_HEADER=\\\"lsquic_qpack_dec_logger.h\\\"")
12150aadb33SDmitri Tikhonov
122d755d26eSRyan A. Pavlikif(NEED_LIBRT_FOR_clock_getres)
123d755d26eSRyan A. Pavlik    target_link_libraries(lsquic PRIVATE ${RT_LIBRARY})
124d755d26eSRyan A. Pavlikendif()
125d755d26eSRyan A. Pavlik
1262e1429b4SDmitri TikhonovIF(LSQUIC_SHARED_LIB)
127f07b3eaeSTyler Young  add_library(lsquic SHARED ${lsquic_STAT_SRCS})
1282e1429b4SDmitri Tikhonov  TARGET_LINK_LIBRARIES(lsquic PRIVATE ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB})
129f07b3eaeSTyler Young  IF(MSVC)
130f07b3eaeSTyler Young    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_EXPORTS")
131f07b3eaeSTyler Young  TARGET_LINK_LIBRARIES(lsquic PRIVATE ws2_32.lib)
132f07b3eaeSTyler Young  ENDIF()
133038a9441SAaron FranceELSE()
134038a9441SAaron France  add_library(lsquic STATIC ${lsquic_STAT_SRCS})
135038a9441SAaron FranceENDIF()
136b62ec17fSDmitri Tikhonov
137797b40e7SRyan A. Pavliktarget_include_directories(
138797b40e7SRyan A. Pavlik    lsquic PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lsquic>)
139797b40e7SRyan A. Pavlik
140966c52fcSJonas Vautherininstall(TARGETS lsquic
141966c52fcSJonas Vautherin    EXPORT lsquic-targets
142966c52fcSJonas Vautherin    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
143966c52fcSJonas Vautherin    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
144966c52fcSJonas Vautherin)
145966c52fcSJonas Vautherin
146797b40e7SRyan A. Pavlikinclude(CMakePackageConfigHelpers)
147797b40e7SRyan A. Pavlikconfigure_package_config_file(
148797b40e7SRyan A. Pavlik    lsquic-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/lsquic-config.cmake
149797b40e7SRyan A. Pavlik    INSTALL_DESTINATION share/lsquic
150797b40e7SRyan A. Pavlik    NO_CHECK_REQUIRED_COMPONENTS_MACRO
151797b40e7SRyan A. Pavlik    PATH_VARS CMAKE_INSTALL_INCLUDEDIR)
152797b40e7SRyan A. Pavlik
153797b40e7SRyan A. Pavlikinstall(
154797b40e7SRyan A. Pavlik    FILES ${CMAKE_CURRENT_BINARY_DIR}/lsquic-config.cmake
155797b40e7SRyan A. Pavlik    DESTINATION share/lsquic)
156797b40e7SRyan A. Pavlik
157797b40e7SRyan A. Pavlikinstall(
158797b40e7SRyan A. Pavlik    EXPORT lsquic-targets
159797b40e7SRyan A. Pavlik    DESTINATION share/lsquic
160797b40e7SRyan A. Pavlik    NAMESPACE lsquic::
161797b40e7SRyan A. Pavlik    FILE lsquic-targets.cmake)
162a74702c6SGeorge Wang
163