106 lines
4.0 KiB
Diff
106 lines
4.0 KiB
Diff
From 56d58f6863feafa1fccddbe1d828bad2aa9d62e3 Mon Sep 17 00:00:00 2001
|
|
From: kidrigger <rex16saddler@gmail.com>
|
|
Date: Sat, 1 Feb 2025 23:20:58 +0100
|
|
Subject: [PATCH] Fix Installation and add Config.
|
|
|
|
---
|
|
CMakeLists.txt | 61 ++++++++++++++++++++++++++++++++++---------
|
|
EABaseConfig.cmake.in | 6 +++++
|
|
2 files changed, 55 insertions(+), 12 deletions(-)
|
|
create mode 100644 EABaseConfig.cmake.in
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 652f07f..933b113 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -4,6 +4,9 @@
|
|
cmake_minimum_required(VERSION 3.1)
|
|
project(EABase CXX)
|
|
|
|
+include(GNUInstallDirs)
|
|
+include(CMakePackageConfigHelpers)
|
|
+
|
|
#-------------------------------------------------------------------------------------------
|
|
# Options
|
|
#-------------------------------------------------------------------------------------------
|
|
@@ -21,17 +24,51 @@ endif()
|
|
#-------------------------------------------------------------------------------------------
|
|
add_definitions(-D_CHAR16T)
|
|
|
|
-#-------------------------------------------------------------------------------------------
|
|
-# Header only library
|
|
-#-------------------------------------------------------------------------------------------
|
|
-add_library(EABase INTERFACE)
|
|
+if (NOT EABASE_BUILD_TESTS)
|
|
+ #-------------------------------------------------------------------------------------------
|
|
+ # Header only library
|
|
+ #-------------------------------------------------------------------------------------------
|
|
+ add_library(EABase INTERFACE)
|
|
+ add_library(EABase::EABase ALIAS EABase)
|
|
|
|
-#-------------------------------------------------------------------------------------------
|
|
-# Include dirs
|
|
-#-------------------------------------------------------------------------------------------
|
|
-target_include_directories(EABase INTERFACE include/Common)
|
|
+ #-------------------------------------------------------------------------------------------
|
|
+ # Include dirs
|
|
+ #-------------------------------------------------------------------------------------------
|
|
+ target_include_directories(EABase INTERFACE
|
|
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/Common>
|
|
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
+ )
|
|
|
|
-#-------------------------------------------------------------------------------------------
|
|
-# Installation
|
|
-#-------------------------------------------------------------------------------------------
|
|
-install(DIRECTORY include/Common/EABase DESTINATION include)
|
|
+ # create and install an export set for eabase target as EABase::EABase
|
|
+ set(EABase_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/EABase")
|
|
+
|
|
+ configure_package_config_file(
|
|
+ EABaseConfig.cmake.in
|
|
+ ${CMAKE_CURRENT_BINARY_DIR}/EABaseConfig.cmake
|
|
+ INSTALL_DESTINATION ${EABase_CMAKE_CONFIG_DESTINATION}
|
|
+ )
|
|
+
|
|
+ # create and install an export set for Terra target as Terra
|
|
+ install(
|
|
+ TARGETS EABase EXPORT EABaseTargets
|
|
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
+ )
|
|
+
|
|
+ install(EXPORT EABaseTargets DESTINATION ${EABase_CMAKE_CONFIG_DESTINATION})
|
|
+
|
|
+ write_basic_package_version_file(
|
|
+ "${CMAKE_CURRENT_BINARY_DIR}/EABaseConfigVersion.cmake"
|
|
+ VERSION 2.09.12
|
|
+ COMPATIBILITY SameMajorVersion
|
|
+ )
|
|
+
|
|
+ install(TARGETS EABase LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
|
+ install(DIRECTORY "include/Common/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
+
|
|
+ install(
|
|
+ FILES
|
|
+ "${CMAKE_CURRENT_BINARY_DIR}/EABaseConfig.cmake"
|
|
+ "${CMAKE_CURRENT_BINARY_DIR}/EABaseConfigVersion.cmake"
|
|
+ DESTINATION ${EABase_CMAKE_CONFIG_DESTINATION}
|
|
+ )
|
|
+endif()
|
|
diff --git a/EABaseConfig.cmake.in b/EABaseConfig.cmake.in
|
|
new file mode 100644
|
|
index 0000000..afc9b10
|
|
--- /dev/null
|
|
+++ b/EABaseConfig.cmake.in
|
|
@@ -0,0 +1,6 @@
|
|
+@PACKAGE_INIT@
|
|
+
|
|
+# Provide path for scripts
|
|
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
|
+
|
|
+include(${CMAKE_CURRENT_LIST_DIR}/EABaseTargets.cmake)
|
|
\ No newline at end of file
|
|
--
|
|
2.47.0
|
|
|