From 7d6da788e4e7ded53f81cff416bc41e253cf34ff Mon Sep 17 00:00:00 2001 From: Florian Pommerening Date: Tue, 12 Sep 2023 12:10:29 +0200 Subject: [PATCH] forgot to add renamed files --- src/search/cmake/common_cxx_flags.cmake | 45 +++++++++++++++++++++++++ src/search/cmake/options.cmake | 37 ++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/search/cmake/common_cxx_flags.cmake create mode 100644 src/search/cmake/options.cmake diff --git a/src/search/cmake/common_cxx_flags.cmake b/src/search/cmake/common_cxx_flags.cmake new file mode 100644 index 0000000000..cf8284c3ab --- /dev/null +++ b/src/search/cmake/common_cxx_flags.cmake @@ -0,0 +1,45 @@ +add_library(common_cxx_flags INTERFACE) +target_compile_features(common_cxx_flags INTERFACE cxx_std_20) + +set(using_gcc_like "$") +set(using_gcc "$") +set(using_msvc "$") +set(using_gcc_like_release "$>") +set(using_gcc_like_debug "$>") +set(should_use_glibcxx_debug "$>") + +target_compile_options(common_cxx_flags INTERFACE + "$<${using_gcc_like}:-O3;-g>") +target_link_options(common_cxx_flags INTERFACE + "$<${using_gcc_like}:-g>") +target_compile_options(common_cxx_flags INTERFACE + "$<${using_gcc_like_release}:-DNDEBUG;-fomit-frame-pointer>") +target_compile_definitions(common_cxx_flags INTERFACE + "$<${should_use_glibcxx_debug}:_GLIBCXX_DEBUG>") +# Enable exceptions for MSVC. +target_compile_options(common_cxx_flags INTERFACE + "$<${using_msvc}:/EHsc>") + +add_library(common_cxx_warnings INTERFACE) +target_compile_options(common_cxx_warnings INTERFACE + "$<${using_gcc_like}:-Wall;-Wextra;-Wpedantic;-Wnon-virtual-dtor;-Wfloat-conversion;-Wmissing-declarations;-Wzero-as-null-pointer-constant>") + +## We ignore the warning "restrict" because of a bug in GCC 12: +## https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651 +set(v12_or_later "$,12>") +set(before_v13 "$,13>") +set(bugged_gcc "$") +target_compile_options(common_cxx_warnings INTERFACE + "$<${bugged_gcc}:-Wno-restrict>") + +# For MSVC, use warning level 4 (/W4) because /Wall currently detects too +# many warnings outside of our code to be useful. +target_compile_options(common_cxx_warnings INTERFACE + "$<${using_msvc}:/W4;/wd4456;/wd4458;/wd4459;/wd4244;/wd4267>") + # Disable warnings that currently trigger in the code until we fix them. + # /wd4456: declaration hides previous local declaration + # /wd4458: declaration hides class member + # /wd4459: declaration hides global declaration + # /wd4244: conversion with possible loss of data + # /wd4267: conversion from size_t to int with possible loss of data +target_link_libraries(common_cxx_flags INTERFACE common_cxx_warnings) diff --git a/src/search/cmake/options.cmake b/src/search/cmake/options.cmake new file mode 100644 index 0000000000..663995efbc --- /dev/null +++ b/src/search/cmake/options.cmake @@ -0,0 +1,37 @@ +include_guard(GLOBAL) + +function(set_up_options) + option( + USE_GLIBCXX_DEBUG + "Enable the libstdc++ debug mode that does additional safety checks. (On Linux \ +systems, g++ and clang++ usually use libstdc++ for the C++ library.) The checks \ +come at a significant performance cost and should only be enabled in debug mode. \ +Enabling them makes the binary incompatible with libraries that are not compiled \ +with this flag, which can lead to hard-to-debug errors." + FALSE) + + option( + USE_LP + "Compile with support for all LP solvers installed on this system. \ +If any enabled library requires an LP solver, compile with all \ +available LP solvers. If no solvers are installed, the planner will \ +still compile, but using heuristics that depend on an LP solver will \ +cause an error. This behavior can be overwritten by setting the \ +option USE_LP to false." + TRUE) + + if(USE_GLIBCXX_DEBUG AND USE_LP) + message( + FATAL_ERROR + "To prevent incompatibilities, the option USE_GLIBCXX_DEBUG is " + "not supported when an LP solver is used. See issue982 for details.") + endif() + + option( + DISABLE_LIBRARIES_BY_DEFAULT + "If set to YES only libraries that are specifically enabled will be compiled" + NO) + # This option should not show up in CMake GUIs like ccmake where all + # libraries are enabled or disabled manually. + mark_as_advanced(DISABLE_LIBRARIES_BY_DEFAULT) +endfunction() \ No newline at end of file