From 797b40e7c2217ab5a9682742e406bbdcaf31a3e7 Mon Sep 17 00:00:00 2001 From: "Ryan A. Pavlik" Date: Thu, 28 Apr 2022 11:11:45 -0500 Subject: [PATCH] Add an installed CMake config. (#370) * Add an installed CMake config. Does not perform transitive link to boringssl though. * Install vc_compat.h header --- CMakeLists.txt | 8 ++++++++ src/liblsquic/CMakeLists.txt | 19 +++++++++++++++++++ src/liblsquic/lsquic-config.cmake | 4 ++++ 3 files changed, 31 insertions(+) create mode 100644 src/liblsquic/lsquic-config.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e928c9..c2d080c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -336,3 +336,11 @@ INSTALL(FILES include/lsxpack_header.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lsquic ) + +if(WIN32) + # The other file in wincompat is not used in installed headers + INSTALL(FILES + wincompat/vc_compat.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lsquic + ) +endif() diff --git a/src/liblsquic/CMakeLists.txt b/src/liblsquic/CMakeLists.txt index 87fce00..be40f9c 100644 --- a/src/liblsquic/CMakeLists.txt +++ b/src/liblsquic/CMakeLists.txt @@ -130,9 +130,28 @@ ELSE() add_library(lsquic STATIC ${lsquic_STAT_SRCS}) ENDIF() +target_include_directories( + lsquic PUBLIC $) + install(TARGETS lsquic EXPORT lsquic-targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) +include(CMakePackageConfigHelpers) +configure_package_config_file( + lsquic-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/lsquic-config.cmake + INSTALL_DESTINATION share/lsquic + NO_CHECK_REQUIRED_COMPONENTS_MACRO + PATH_VARS CMAKE_INSTALL_INCLUDEDIR) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/lsquic-config.cmake + DESTINATION share/lsquic) + +install( + EXPORT lsquic-targets + DESTINATION share/lsquic + NAMESPACE lsquic:: + FILE lsquic-targets.cmake) diff --git a/src/liblsquic/lsquic-config.cmake b/src/liblsquic/lsquic-config.cmake new file mode 100644 index 0000000..d45b5bb --- /dev/null +++ b/src/liblsquic/lsquic-config.cmake @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +set_and_check(lsquic_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +include("${CMAKE_CURRENT_LIST_DIR}/lsquic-targets.cmake")