From 28a11777d7ca578900a540b9a09a6d8fc2639ef7 Mon Sep 17 00:00:00 2001 From: Alexander Sherikov Date: Mon, 20 Nov 2023 22:24:47 +0400 Subject: [PATCH] Use find_package for yaml-cpp, use C++14 by default (new boost wants it) --- CMakeLists.txt | 3 ++- README.md | 2 ++ cmake/cmakeut_compiler_flags.cmake | 19 +------------------ extra_visitors/yaml_cpp/CMakeLists.txt | 17 +++++++++++------ 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fd3cb7f..596049f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ option (ARILES_VERBOSE "Verbose build" ON) option (ARILES_BUILD_REGRESSION_TESTS "Build regression tests." ON) option (ARILES_CCACHE "Enable ccache if available" ON) set (ARILES_DEB_TARGETS "" CACHE STRING "Enable debian package generation.") +set (ARILES_CPP_STANDARD "14" CACHE STRING "14 is required for boost >= 1.82, 11 is still ok for ariles") # install parameters set (ARILES_PKGCONFIG_INSTALL_PATH "" CACHE STRING "pkg-config pc-file install path, not installed if empty") @@ -209,7 +210,7 @@ set(CMAKEUT_CPP_SANITIZERS ${ARILES_CPP_SANITIZERS}) set(CMAKEUT_CLANG_TIDY ${ARILES_CPP_CLANG_TIDY}) set(CMAKEUT_CLANG_TIDY_EXTRA_IGNORES "-cppcoreguidelines-special-member-functions,-hicpp-special-member-functions,-altera-struct-pack-align,-llvm-namespace-comment,-misc-no-recursion,-readability-const-return-type,-google-default-arguments,-bugprone-macro-parentheses,-cppcoreguidelines-pro-type-union-access,-hicpp-named-parameter,-readability-named-parameter,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-avoid-non-const-global-variables,-cert-err58-cpp,-cert-env33-c") -cmakeut_compiler_flags("c++11") +cmakeut_compiler_flags("c++${ARILES_CPP_STANDARD}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKEUT_CXX_FLAGS}") diff --git a/README.md b/README.md index e1ae250e..cd05416e 100644 --- a/README.md +++ b/README.md @@ -263,3 +263,5 @@ Related software * Serialization libraries, e.g., `boost::serialization`, https://github.com/USCiLab/cereal. +* A library with similar functionality in C++17 + https://github.com/injae/serdepp. diff --git a/cmake/cmakeut_compiler_flags.cmake b/cmake/cmakeut_compiler_flags.cmake index b4ad550b..d358f896 100644 --- a/cmake/cmakeut_compiler_flags.cmake +++ b/cmake/cmakeut_compiler_flags.cmake @@ -115,22 +115,5 @@ function(cmakeut_compiler_flags STANDARD) set(CXX_GENERIC "-std=${STANDARD} ${CXX_WARNINGS} ${CXX_OTHER} ${CXX_SANITIZERS}") - if ("${STANDARD}" STREQUAL "c++11") - - # -Wsuggest-override -Wsuggest-final-methods - set (CMAKEUT_CXX_FLAGS "${CXX_GENERIC}" PARENT_SCOPE) - - elseif ("${STANDARD}" STREQUAL "c++03") - - set (CMAKEUT_CXX_FLAGS "${CXX_GENERIC}" PARENT_SCOPE) - - elseif ("${STANDARD}" STREQUAL "c++98") - - set (CMAKEUT_CXX_FLAGS "${CXX_GENERIC}" PARENT_SCOPE) - - else() - - message(FATAL_ERROR "Unknown standard") - - endif() + set (CMAKEUT_CXX_FLAGS "${CXX_GENERIC}" PARENT_SCOPE) endfunction() diff --git a/extra_visitors/yaml_cpp/CMakeLists.txt b/extra_visitors/yaml_cpp/CMakeLists.txt index 0d564994..c4e3062f 100644 --- a/extra_visitors/yaml_cpp/CMakeLists.txt +++ b/extra_visitors/yaml_cpp/CMakeLists.txt @@ -1,15 +1,20 @@ set (TGT_ARILES_VISITOR_LIB "${PROJECT_NAME}_visitor_${ARILES_VISITOR}") if(NOT ARILES_DEB_TARGETS) - pkg_search_module(${ARILES_VISITOR} REQUIRED yaml-cpp>=0.5.1) + find_package(yaml-cpp) + if(yaml-cpp_FOUND) + set(ARILES_VISITOR_${ARILES_VISITOR}_INCLUDES "${YAML_CPP_INCLUDE_DIR}") + set(ARILES_VISITOR_${ARILES_VISITOR}_LIBS "yaml-cpp") + else() + pkg_search_module(${ARILES_VISITOR} REQUIRED yaml-cpp>=0.5.1) - set(ARILES_VISITOR_${ARILES_VISITOR}_LIBRARY_DIRS "${${ARILES_VISITOR}_LIBRARY_DIRS}") - set(ARILES_VISITOR_${ARILES_VISITOR}_INCLUDES "${${ARILES_VISITOR}_INCLUDE_DIRS}") - set(ARILES_VISITOR_${ARILES_VISITOR}_LIBS "${${ARILES_VISITOR}_LIBRARIES}") + set(ARILES_VISITOR_${ARILES_VISITOR}_LIBRARY_DIRS "${${ARILES_VISITOR}_LIBRARY_DIRS}") + set(ARILES_VISITOR_${ARILES_VISITOR}_INCLUDES "${${ARILES_VISITOR}_INCLUDE_DIRS}") + set(ARILES_VISITOR_${ARILES_VISITOR}_LIBS "${${ARILES_VISITOR}_LIBRARIES}") - - link_directories(${ARILES_VISITOR_${ARILES_VISITOR}_LIBRARY_DIRS}) + link_directories(${ARILES_VISITOR_${ARILES_VISITOR}_LIBRARY_DIRS}) + endif() endif() add_library(${TGT_ARILES_VISITOR_LIB}