From f9a263c7c298d13840f2735f9e40db1f531b3088 Mon Sep 17 00:00:00 2001 From: Orange Date: Wed, 2 Oct 2024 04:25:43 -0700 Subject: [PATCH 1/3] added files --- CMakeLists.txt | 56 +++++++++++++++++++++++++++++++++++--- cmake/omathConfig.cmake.in | 6 ++++ 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 cmake/omathConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index ad7e13d..77bd952 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,13 @@ cmake_minimum_required(VERSION 3.26) +project(omath VERSION 1.0.0) + -project(omath) set(CMAKE_CXX_STANDARD 26) option(OMATH_BUILD_TESTS "Build unit tests" ON) -option(OMATH_THREAT_WARNING_AS_ERROR "Set highest level of warnings and force compiler to threat them as errors" ON) +option(OMATH_THREAT_WARNING_AS_ERROR "Set highest level of warnings and force compiler to treat them as errors" ON) option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so\\.dll." OFF) if (OMATH_BUILD_AS_SHARED_LIBRARY) @@ -20,7 +21,7 @@ add_subdirectory(extlibs) if(OMATH_BUILD_TESTS) add_subdirectory(tests) -endif () +endif() if (WIN32 AND OMATH_THREAT_WARNING_AS_ERROR) target_compile_options(omath PRIVATE /W4 /WX) @@ -28,4 +29,51 @@ elseif(UNIX AND OMATH_THREAT_WARNING_AS_ERROR) target_compile_options(omath PRIVATE -Wall -Wextra -Wpedantic) endif() -target_include_directories(omath PUBLIC include) \ No newline at end of file +target_include_directories(omath + PUBLIC + $ # Use this path when building the project + $ # Use this path when the project is installed +) + + +# Installation rules + +# Install the library +install(TARGETS omath + EXPORT omathTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin +) + +# Install the public headers +install(DIRECTORY include/ DESTINATION include) + +# Export omath targets +install(EXPORT omathTargets + FILE omathTargets.cmake + NAMESPACE omath:: + DESTINATION lib/cmake/omath +) + + +# Generate the omathConfigVersion.cmake file +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion +) + +# Generate the omathConfig.cmake file from the template (which is in the cmake/ folder) +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/omathConfig.cmake.in" # Path to the .in file + "${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake" # Output path for the generated file + INSTALL_DESTINATION lib/cmake/omath +) + +# Install the generated config files +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake" + DESTINATION lib/cmake/omath +) \ No newline at end of file diff --git a/cmake/omathConfig.cmake.in b/cmake/omathConfig.cmake.in new file mode 100644 index 0000000..a889c4d --- /dev/null +++ b/cmake/omathConfig.cmake.in @@ -0,0 +1,6 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# Load the targets for the omath library +include("${CMAKE_CURRENT_LIST_DIR}/omathTargets.cmake") From 8eaf77a1d7ab46d1b62f26e069619dcb7b7cae93 Mon Sep 17 00:00:00 2001 From: Orange Date: Wed, 2 Oct 2024 07:56:35 +0300 Subject: [PATCH 2/3] added component --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77bd952..69fcc24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,19 +41,19 @@ target_include_directories(omath # Install the library install(TARGETS omath EXPORT omathTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib COMPONENT omath_component # For static libraries + LIBRARY DESTINATION lib COMPONENT omath_component # For shared libraries + RUNTIME DESTINATION bin COMPONENT omath_component # For executables (on Windows) ) -# Install the public headers -install(DIRECTORY include/ DESTINATION include) +# Install headers as part of omath_component +install(DIRECTORY include/ DESTINATION include COMPONENT omath_component) -# Export omath targets +# Export omath target for CMake find_package support, also under omath_component install(EXPORT omathTargets FILE omathTargets.cmake NAMESPACE omath:: - DESTINATION lib/cmake/omath + DESTINATION lib/cmake/omath COMPONENT omath_component ) From ef1d74d8fd2a8f03b7055230fddafe1ebc7db629 Mon Sep 17 00:00:00 2001 From: Orange Date: Wed, 2 Oct 2024 07:58:04 +0300 Subject: [PATCH 3/3] fixed \\ slash --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69fcc24..94298d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD 26) option(OMATH_BUILD_TESTS "Build unit tests" ON) option(OMATH_THREAT_WARNING_AS_ERROR "Set highest level of warnings and force compiler to treat them as errors" ON) -option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so\\.dll." OFF) +option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so or .dll" OFF) if (OMATH_BUILD_AS_SHARED_LIBRARY) add_library(omath SHARED source/Vector3.cpp)