From 4e91af62d36189dc32c6aded0556490bf20cfb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 19 Jun 2018 11:25:19 +0200 Subject: [PATCH] CMake: Export CMake package config --- CMakeLists.txt | 26 +++++++++++++++++++++++++- cmake/Config.cmake.in | 4 ++++ lib/instructions/CMakeLists.txt | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 cmake/Config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 76b280b..ab2b989 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,9 @@ option(EVMC_EXAMPLES "Build EVMC examples" OFF) option(HUNTER_ENABLED "Enable Hunter package manager support" "${EVMC_TESTING}") include(cmake/cable/bootstrap.cmake) +include(CableBuildType) include(CableCompilerSettings) +include(CMakePackageConfigHelpers) include(HunterGate) include(GNUInstallDirs) include(defaults/HunterCacheServers) @@ -30,13 +32,16 @@ HunterGate( project(evmc) set(PROJECT_VERSION "0.1.0.dev0") +cable_set_build_type(DEFAULT Release CONFIGURATION_TYPES Debug Release) + cable_configure_compiler(NO_STACK_PROTECTION) set(include_dir ${PROJECT_SOURCE_DIR}/include) add_library(evmc INTERFACE) add_library(evmc::evmc ALIAS evmc) -target_include_directories(evmc INTERFACE ${include_dir}) +target_include_directories(evmc INTERFACE $$) +install(TARGETS evmc EXPORT evmcTargets) install(DIRECTORY include/evmc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) @@ -51,6 +56,25 @@ if(EVMC_EXAMPLES) add_subdirectory(examples) endif() +write_basic_package_version_file(evmcConfigVersion.cmake COMPATIBILITY ExactVersion) + +configure_package_config_file( + cmake/Config.cmake.in + evmcConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc +) + +install( + EXPORT evmcTargets + NAMESPACE evmc:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc +) +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/evmcConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/evmcConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc +) if(WIN32) set(CPACK_GENERATOR ZIP) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in new file mode 100644 index 0000000..13df106 --- /dev/null +++ b/cmake/Config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/evmcTargets.cmake") +check_required_components(evmc) diff --git a/lib/instructions/CMakeLists.txt b/lib/instructions/CMakeLists.txt index 4d9905e..117e6c7 100644 --- a/lib/instructions/CMakeLists.txt +++ b/lib/instructions/CMakeLists.txt @@ -10,6 +10,6 @@ add_library( ) add_library(evmc::instructions ALIAS instructions) -target_include_directories(instructions PUBLIC ${include_dir}) +target_include_directories(instructions PUBLIC $$) install(TARGETS instructions EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})