From 7ca0b93826f7d3e7fee005e5ae84be3e78b34a64 Mon Sep 17 00:00:00 2001 From: Alex Hogen Date: Fri, 28 Jun 2024 19:24:24 -0700 Subject: [PATCH 1/3] CMake modifications to more easily use this as a submodule of a project using both it and yaml-cpp. --- CMakeLists.txt | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aa3453..cff5e7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,15 @@ +cmake_minimum_required(VERSION 3.11) +cmake_policy(SET CMP0077 NEW) + project(cerberus-cpp LANGUAGES CXX) -cmake_minimum_required(VERSION 3.11) +set(CERBERUS_CPP_MAIN_PROJECT OFF) +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + set(CERBERUS_CPP_MAIN_PROJECT ON) +endif() + +option(CERBERUS_CPP_FIND_YAML_CPP "Enable find_package(yaml-cpp)." ON) +option(CERBERUS_CPP_INSTALL "Enable generation of cerberus-cpp install targets" ${CERBERUS_CPP_MAIN_PROJECT}) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -13,7 +22,9 @@ if(DOCS_ONLY) set(REQUIRED_STRING "") endif() -find_package(yaml-cpp 0.6 ${REQUIRED_STRING}) +if(NOT ${CERBERUS_SKIP_YAML_CPP_PACKAGE_SEARCH}) + find_package(yaml-cpp 0.6 ${REQUIRED_STRING}) +endif() # Add library target that can be linked against add_library(cerberus-cpp INTERFACE) @@ -41,24 +52,26 @@ endif() # Installation rules include(GNUInstallDirs) -install( - TARGETS cerberus-cpp - EXPORT cerberus-cpp-config - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} -) +if (CERBERUS_CPP_INSTALL) + install( + TARGETS cerberus-cpp + EXPORT cerberus-cpp-config + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) -install( - EXPORT cerberus-cpp-config - NAMESPACE cerberus-cpp:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cerberus-cpp -) + install( + EXPORT cerberus-cpp-config + NAMESPACE cerberus-cpp:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cerberus-cpp + ) -install( - DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) + install( + DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) +endif() include(FeatureSummary) feature_summary(WHAT ALL) From 6cd333031c348baf7881d54a7a3ffb2d281a8bd0 Mon Sep 17 00:00:00 2001 From: Alex Hogen Date: Sat, 29 Jun 2024 09:45:11 -0700 Subject: [PATCH 2/3] Fix include path --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cff5e7c..784a831 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ add_library(cerberus-cpp INTERFACE) target_include_directories( cerberus-cpp INTERFACE - $ + $ $ ) target_link_libraries(cerberus-cpp INTERFACE yaml-cpp) @@ -43,7 +43,7 @@ add_library(cerberus-cpp::cerberus-cpp ALIAS cerberus-cpp) add_subdirectory(doc) # Add the testing subdirectories -if(EXISTS ${CMAKE_SOURCE_DIR}/ext/Catch2/CMakeLists.txt) +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ext/Catch2/CMakeLists.txt) include(CTest) add_subdirectory(ext/Catch2) add_subdirectory(test) From d116c6390e006fd055a396440325c80415d7bee8 Mon Sep 17 00:00:00 2001 From: Alex Hogen Date: Mon, 1 Jul 2024 07:13:04 -0700 Subject: [PATCH 3/3] Fix cmake option I later renamed. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 784a831..e472b2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if(DOCS_ONLY) set(REQUIRED_STRING "") endif() -if(NOT ${CERBERUS_SKIP_YAML_CPP_PACKAGE_SEARCH}) +if(${CERBERUS_CPP_FIND_YAML_CPP}) find_package(yaml-cpp 0.6 ${REQUIRED_STRING}) endif()