diff --git a/src/search/CMakeLists.txt b/src/search/CMakeLists.txt index 8387577a8d..ed9f7f52eb 100644 --- a/src/search/CMakeLists.txt +++ b/src/search/CMakeLists.txt @@ -22,14 +22,14 @@ # # is used to describe the cmake option, for example in ccmake. # SOURCES lists the source files that are part of the library. Entries are -# listed without extension. For an entry , both .h and .cc -# are added if the files exist. -# DEPENDS lists libraries that will be automatically enabled if this library is -# enabled. If the dependency was not enabled before, this will be logged. +# listed without extension. For an entry , both .h and .cc +# are added if the files exist. +# DEPENDS lists libraries that will be compiled as dependendies if this library +# is enabled. # DEPENDENCY_ONLY disables the library unless it is needed as a dependency and -# hides the option to enable the library in cmake GUIs like ccmake. +# hides the option to enable the library in cmake GUIs like ccmake. # CORE_LIBRARY always enables the library (even if DISABLE_LIBRARIES_BY_DEFAULT -# is used) and hides the option to disable it in CMake GUIs like ccmake. +# is used) and hides the option to disable it in CMake GUIs like ccmake. cmake_minimum_required(VERSION 3.16) @@ -45,7 +45,7 @@ project(downward LANGUAGES CXX) add_executable(downward planner.cc) # On Windows we have to copy all DLLs next to the generated binary. -copy_dlls_to_binary_dir(downward) +copy_dlls_to_binary_dir_after_build(downward) # In the following, we include all source files, grouped into libraries with # dependencies among each other. @@ -501,24 +501,18 @@ create_fast_downward_library( if(USE_LP) find_package(Cplex 12) if(CPLEX_FOUND) - add_library(downward_cplex_interface INTERFACE) - target_compile_definitions(downward_cplex_interface INTERFACE HAS_CPLEX) - target_link_libraries(downward_cplex_interface INTERFACE cplex::cplex) - target_sources(downward_cplex_interface INTERFACE lp/cplex_solver_interface.h lp/cplex_solver_interface.cc) - - target_link_libraries(downward_lp_solver INTERFACE downward_cplex_interface) + target_compile_definitions(downward_lp_solver INTERFACE HAS_CPLEX) + target_link_libraries(downward_lp_solver INTERFACE cplex::cplex) + target_sources(downward_lp_solver INTERFACE lp/cplex_solver_interface.h lp/cplex_solver_interface.cc) endif() # TODO: we actually require a version greater than 6.0.3 but it is not released yet. find_package(soplex 6.0.3 QUIET) if (SOPLEX_FOUND) message(STATUS "Found SoPlex: ${SOPLEX_INCLUDE_DIRS}") - add_library(downward_soplex_interface INTERFACE) - target_link_libraries(downward_soplex_interface INTERFACE libsoplex) - target_compile_definitions(downward_soplex_interface INTERFACE HAS_SOPLEX) - target_sources(downward_soplex_interface INTERFACE lp/soplex_solver_interface.h lp/soplex_solver_interface.cc) - - target_link_libraries(downward_lp_solver INTERFACE downward_soplex_interface) + target_link_libraries(downward_lp_solver INTERFACE libsoplex) + target_compile_definitions(downward_lp_solver INTERFACE HAS_SOPLEX) + target_sources(downward_lp_solver INTERFACE lp/soplex_solver_interface.h lp/soplex_solver_interface.cc) endif() endif() diff --git a/src/search/cmake/cxx_options.cmake b/src/search/cmake/cxx_options.cmake deleted file mode 100644 index f5c68f89b2..0000000000 --- a/src/search/cmake/cxx_options.cmake +++ /dev/null @@ -1,45 +0,0 @@ -add_library(cxx_options INTERFACE) -target_compile_features(cxx_options 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(cxx_options INTERFACE - "$<${using_gcc_like}:-O3;-g>") -target_link_options(cxx_options INTERFACE - "$<${using_gcc_like}:-g>") -target_compile_options(cxx_options INTERFACE - "$<${using_gcc_like_release}:-DNDEBUG;-fomit-frame-pointer>") -target_compile_definitions(cxx_options INTERFACE - "$<${should_use_glibcxx_debug}:_GLIBCXX_DEBUG>") -# Enable exceptions for MSVC. -target_compile_options(cxx_options INTERFACE - "$<${using_msvc}:/EHsc>") - -add_library(cxx_warnings INTERFACE) -target_compile_options(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(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(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(cxx_options INTERFACE cxx_warnings) diff --git a/src/search/cmake/macros.cmake b/src/search/cmake/macros.cmake index de7b11e9b5..8a58555f02 100644 --- a/src/search/cmake/macros.cmake +++ b/src/search/cmake/macros.cmake @@ -1,8 +1,8 @@ include_guard(GLOBAL) include(CMakeParseArguments) -include(cxx_options) -include(project_options) +include(common_cxx_flags) +include(options) function(set_up_build_types allowedBuildTypes) get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) @@ -80,7 +80,7 @@ function(create_fast_downward_library) endif() add_library(downward_${_LIBRARY_NAME} INTERFACE) - target_link_libraries(downward_${_LIBRARY_NAME} INTERFACE cxx_options) + target_link_libraries(downward_${_LIBRARY_NAME} INTERFACE common_cxx_flags) target_sources(downward_${_LIBRARY_NAME} INTERFACE ${_LIBRARY_SOURCES}) foreach(DEPENDENCY ${_LIBRARY_DEPENDS}) target_link_libraries(downward_${_LIBRARY_NAME} INTERFACE downward_${DEPENDENCY}) @@ -91,7 +91,7 @@ function(create_fast_downward_library) endif() endfunction() -function(copy_dlls_to_binary_dir _TARGET_NAME) +function(copy_dlls_to_binary_dir_after_build _TARGET_NAME) # https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:_TARGET_RUNTIME_DLLS add_custom_command(TARGET ${_TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy -t $ $ diff --git a/src/search/cmake/project_options.cmake b/src/search/cmake/project_options.cmake deleted file mode 100644 index 663995efbc..0000000000 --- a/src/search/cmake/project_options.cmake +++ /dev/null @@ -1,37 +0,0 @@ -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