From 96434681469ae88859bd7223c8109612f4c1545d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccolo=CC=80=20Iardella?= Date: Mon, 17 Jan 2022 18:44:58 +0100 Subject: [PATCH 1/4] Add CMake support --- CMakeLists.txt | 68 ++++++++++++++++++++++++++++++++++++ cmake/eventppConfig.cmake.in | 8 +++++ 2 files changed, 76 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/eventppConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6a6388c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required(VERSION 3.11) +project(eventpp VERSION 0.1.1) + +add_library(eventpp INTERFACE) +target_compile_features(eventpp INTERFACE cxx_std_11) + +target_include_directories( + eventpp INTERFACE + $ + $ +) + +# Installation +# ------------ +include(GNUInstallDirs) + +# Install the library +install( + TARGETS eventpp + EXPORT eventppTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +# Install the headers +install( + DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +# (Generate and) install the target import file +install( + EXPORT eventppTargets + NAMESPACE eventpp:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp +) + +# Generate the package version file +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion +) + +# Generate the package configuration file, that allows other +# CMake projects to find the library with find_package() +configure_package_config_file( + cmake/eventppConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp +) + +# Install the package version and configuration files +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp +) + +# Install readme and license +install( + FILES + readme.md + license + DESTINATION ${CMAKE_INSTALL_DATADIR}/eventpp +) diff --git a/cmake/eventppConfig.cmake.in b/cmake/eventppConfig.cmake.in new file mode 100644 index 0000000..f0d145d --- /dev/null +++ b/cmake/eventppConfig.cmake.in @@ -0,0 +1,8 @@ +include(CMakeFindDependencyMacro) + +get_filename_component(eventpp_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +if (NOT TARGET eventpp::eventpp) + include("${eventpp_CMAKE_DIR}/eventppTargets.cmake") +endif () + +set(eventpp_LIBRARIES eventpp::eventpp) From c0852fd7384ad382ac3309650c8ef0d9c72ca8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccolo=CC=80=20Iardella?= Date: Mon, 17 Jan 2022 19:10:39 +0100 Subject: [PATCH 2/4] Fix target install interface --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a6388c..fd309d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ target_compile_features(eventpp INTERFACE cxx_std_11) target_include_directories( eventpp INTERFACE $ - $ + $ ) # Installation From dd06c09cce88c018a04067cb8601b6a044248306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccolo=CC=80=20Iardella?= Date: Mon, 17 Jan 2022 19:19:10 +0100 Subject: [PATCH 3/4] Remove unused CMake macro --- cmake/eventppConfig.cmake.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/eventppConfig.cmake.in b/cmake/eventppConfig.cmake.in index f0d145d..c1be965 100644 --- a/cmake/eventppConfig.cmake.in +++ b/cmake/eventppConfig.cmake.in @@ -1,5 +1,3 @@ -include(CMakeFindDependencyMacro) - get_filename_component(eventpp_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) if (NOT TARGET eventpp::eventpp) include("${eventpp_CMAKE_DIR}/eventppTargets.cmake") From 3757f86633ae9f2b4b5051d735991810e66559ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccolo=CC=80=20Iardella?= Date: Mon, 17 Jan 2022 19:59:36 +0100 Subject: [PATCH 4/4] Fix target build interface --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd309d9..5376c74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,10 +6,12 @@ target_compile_features(eventpp INTERFACE cxx_std_11) target_include_directories( eventpp INTERFACE - $ + $ $ ) +add_library(eventpp::eventpp ALIAS eventpp) + # Installation # ------------ include(GNUInstallDirs)