From f1c76a475d1224deb929c4e8f8f111cebc283cc0 Mon Sep 17 00:00:00 2001 From: Sam Fuller Date: Sun, 27 Jan 2019 21:35:03 -0800 Subject: [PATCH] Cmake config support --- CMakeLists.txt | 42 +++++++++++++++++++++++++++++++++++++++++- Config.cmake.in | 4 ++++ logvisor | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 Config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 63c2f13..b32b5b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,12 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17 -project(nod) +project(nod VERSION 0.1) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() +include (CMakePackageConfigHelpers) + if (MSVC) # Shaddup MSVC add_definitions(-DUNICODE=1 -D_UNICODE=1 -D__SSE__=1 -D_CRT_SECURE_NO_WARNINGS=1 -DD_SCL_SECURE_NO_WARNINGS=1 @@ -22,3 +24,41 @@ file(GLOB NOD_HEADERS include/nod/*.h*) add_subdirectory(lib) add_subdirectory(driver) install(DIRECTORY include/nod DESTINATION include/nod) + +set(version_config_file "${PROJECT_BINARY_DIR}/nodConfigVersion.cmake") +set(config_file "${PROJECT_BINARY_DIR}/nodConfig.cmake") +set(config_install_dir "lib/cmake/nod") + +# Associate target with export +install( + TARGETS nod + EXPORT nodTargets + ARCHIVE DESTINATION "lib" + INCLUDES DESTINATION "include/nod" # This sets the INTERFACE_INCLUDE_DIRECTORIES property of the target. +) + +# Install the target config files +install( + EXPORT nodTargets + NAMESPACE "nod::" + DESTINATION "${config_install_dir}" +) + +# Generate version config file +write_basic_package_version_file( + "${version_config_file}" + COMPATIBILITY SameMajorVersion +) + +# Generate config file +configure_package_config_file( + "Config.cmake.in" + "${config_file}" + INSTALL_DESTINATION "lib/cmake/nod" +) + +# Install the config files +install( + FILES "${config_file}" "${version_config_file}" + DESTINATION ${config_install_dir} +) diff --git a/Config.cmake.in b/Config.cmake.in new file mode 100644 index 0000000..7181c15 --- /dev/null +++ b/Config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/nodTargets.cmake") +check_required_components(nod) diff --git a/logvisor b/logvisor index 01e2918..02cef94 160000 --- a/logvisor +++ b/logvisor @@ -1 +1 @@ -Subproject commit 01e291833ba4d7f2a596c32cf6158cb6a9327ad7 +Subproject commit 02cef9479eea2c444715c0a84cb7aa3c8f41c1ee