From a4e8c6da5d5e15178c2cd234426014acd542e753 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Wed, 8 Jan 2025 14:07:10 +0100 Subject: [PATCH] More use of CMAKE_INSTALL_<...>DIR (#4738) CMAKE_INSTALL_INCLUDEDIR is already used for the exported build interface. This change applies the standard variables to more destinations, moves the related GNUInstallDirs include to the top-level CMakeLists.txt, and adds explicit RUNTIME/LIBRARY/ARCHIVE destinations. This should be beneficial for external packaging. Last not least put msquic.lttng into the msquic CMake export set. --- CMakeLists.txt | 2 ++ src/bin/CMakeLists.txt | 15 ++++++++++----- src/generated/CMakeLists.txt | 7 ++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a32b057c25..6ce78d0c08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,6 +198,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${QUIC_OUTPUT_DIR}) set(QUIC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/inc) +include(GNUInstallDirs) + if (WIN32) set(QUIC_WARNING_FLAGS /WX /W4 /sdl /wd4206 CACHE INTERNAL "") set(QUIC_COMMON_FLAGS "") diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt index e69cf51ac5..535593502b 100644 --- a/src/bin/CMakeLists.txt +++ b/src/bin/CMakeLists.txt @@ -251,8 +251,6 @@ elseif (CX_PLATFORM STREQUAL "darwin") PROPERTIES LINK_FLAGS "-exported_symbols_list \"${CMAKE_CURRENT_SOURCE_DIR}/darwin/exports.txt\"") endif() -include(GNUInstallDirs) - file(GLOB PUBLIC_HEADERS "../inc/*.h" "../inc/*.hpp") if(QUIC_TLS STREQUAL "openssl" OR QUIC_TLS STREQUAL "openssl3") @@ -264,11 +262,18 @@ if(WIN32) endif() if(BUILD_SHARED_LIBS) - install(TARGETS msquic msquic_platform inc logging_inc warnings main_binary_link_args ${OTHER_TARGETS} EXPORT msquic DESTINATION lib) + install(TARGETS msquic msquic_platform inc logging_inc warnings main_binary_link_args ${OTHER_TARGETS} + EXPORT msquic + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) else() - install(FILES ${QUIC_STATIC_LIBRARY} DESTINATION lib) + install(FILES "${QUIC_STATIC_LIBRARY}" + DESTINATION lib + ) endif() -install(FILES ${PUBLIC_HEADERS} DESTINATION include) +install(FILES ${PUBLIC_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") configure_file(msquic-config.cmake.in ${CMAKE_BINARY_DIR}/msquic-config.cmake @ONLY) diff --git a/src/generated/CMakeLists.txt b/src/generated/CMakeLists.txt index 93bd6cc9a2..86d1fb0a3d 100644 --- a/src/generated/CMakeLists.txt +++ b/src/generated/CMakeLists.txt @@ -43,7 +43,12 @@ if(QUIC_ENABLE_LOGGING) target_link_libraries(msquic.lttng PRIVATE ${LTTNGUST_LIBRARIES}) set_target_properties(msquic.lttng PROPERTIES SOVERSION ${QUIC_FULL_VERSION} VERSION ${QUIC_FULL_VERSION}) - install(TARGETS msquic.lttng DESTINATION lib) + install(TARGETS msquic.lttng + EXPORT msquic + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) endif() else()