229 lines
8.7 KiB
Diff
229 lines
8.7 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 9511442..3993fc4 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -1,4 +1,4 @@
|
|
-cmake_minimum_required(VERSION 3.11)
|
|
+cmake_minimum_required(VERSION 3.25)
|
|
|
|
# FindBoost is removed in version cmake 3.30
|
|
if(POLICY CMP0167)
|
|
@@ -31,6 +31,10 @@ set(CPACK_PACKAGE_VERSION_PATCH "${SOPLEX_VERSION_PATCH}")
|
|
set(CPACK_PACKAGE_VENDOR "Zuse Institute Berlin")
|
|
include(CPack)
|
|
|
|
+# Disable CTest targets
|
|
+set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
|
|
+include(CTest)
|
|
+
|
|
option(ZLIB "Use ZLIB" ON)
|
|
option(GMP "Use GMP" ON)
|
|
option(EMSCRIPTEN_HTML "Emscripten HTML output" OFF)
|
|
@@ -44,11 +48,17 @@ option(SANITIZE "should sanitizers be enabled if available" OFF)
|
|
option(COVERAGE "enable coverage support" OFF)
|
|
option(PAPILO "should papilo library be linked" ON)
|
|
|
|
+option(SOPLEX_EXAMPLE "Build example" OFF)
|
|
+option(SOPLEX_SOPLEX "Build soplex program" OFF)
|
|
+option(SOPLEX_EXPORT "Enable to use soplex from the current project's build tree, without installation." OFF)
|
|
+
|
|
SET(COVERAGE_CTEST_ARGS "" CACHE STRING "additional ctest arguments for coverage")
|
|
|
|
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
+if(CMAKE_PROJECT_NAME EQUAL "SOPLEX")
|
|
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
+ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
+endif()
|
|
|
|
# for colorized output
|
|
if(NOT WIN32)
|
|
@@ -70,6 +80,8 @@ set(CMAKE_MACOSX_RPATH ON)
|
|
|
|
# use C++14 standard
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
+set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
# set function visibility default to hidden
|
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
|
@@ -124,12 +136,11 @@ if(COVERAGE)
|
|
endif()
|
|
|
|
if(ZLIB)
|
|
- find_package(ZLIB)
|
|
-endif()
|
|
-if(ZLIB_FOUND)
|
|
- set(SOPLEX_WITH_ZLIB on)
|
|
- set(libs ${libs} ${ZLIB_LIBRARIES})
|
|
- include_directories(${ZLIB_INCLUDE_DIRS})
|
|
+ if(NOT TARGET ZLIB::ZLIB)
|
|
+ find_package(ZLIB REQUIRED)
|
|
+ endif()
|
|
+ set(SOPLEX_WITH_ZLIB on)
|
|
+ set(libs ${libs} ZLIB::ZLIB)
|
|
endif()
|
|
|
|
if(GMP)
|
|
@@ -171,42 +182,24 @@ else()
|
|
set(SOPLEX_WITH_PAPILO off)
|
|
endif()
|
|
|
|
-set(BOOST_MINIMUM_VERSION 1.65.0)
|
|
+set(BOOST_MINIMUM_VERSION 1.65.0) # PaPILO requires at least Boost 1.65 (on mac 1.72)
|
|
if(BOOST)
|
|
- find_package(Boost ${BOOST_MINIMUM_VERSION}) # PaPILO requires at least Boost 1.65 (on mac 1.72)
|
|
- if(Boost_FOUND)
|
|
- set(SOPLEX_WITH_BOOST on)
|
|
- if(NOT Boost_VERSION_MACRO)
|
|
- set(Boost_VERSION_MACRO ${Boost_VERSION})
|
|
- endif()
|
|
- if(${Boost_VERSION_MACRO} LESS "107000")
|
|
- if(NOT SOPLEX_WITH_GMP)
|
|
- message(SEND_ERROR "If no GMP is linked, then the minimal Boost verion is 1.70. \
|
|
- Found Boost version is ${Boost_VERSION_STRING}. Either provide newer Boost, link GMP, or disable Boost by setting BOOST=off.")
|
|
- else()
|
|
- message(WARNING "The multiprecision and quadprecision features are disabled with Boost versions older than 1.70. \
|
|
- Found Boost version is ${Boost_VERSION_STRING}.")
|
|
- endif()
|
|
- endif()
|
|
- if(Boost_DIR)
|
|
- message(STATUS "Found Boost: ${Boost_DIR}")
|
|
- endif()
|
|
- set(libs ${libs} Boost::boost)
|
|
- if(MPFR) # MPFR is used within boost multiprecision, so using it without Boost does not make sense
|
|
- find_package(MPFR)
|
|
- endif()
|
|
- if(MPFR_FOUND)
|
|
- message(STATUS "SoPlex with Boost MPFR ${MPFR_VERSION} libraries")
|
|
- set(SOPLEX_WITH_MPFR on)
|
|
- include_directories(${MPFR_INCLUDE_DIRS})
|
|
- set(libs ${libs} ${MPFR_LIBRARIES})
|
|
- else()
|
|
- message(STATUS "SoPlex with Boost CPP multiprecision libraries")
|
|
- set(SOPLEX_WITH_CPPMPF on)
|
|
- endif()
|
|
- else()
|
|
- set(BOOST off)
|
|
- endif()
|
|
+ if(NOT TARGET Boost::multiprecision OR NOT TARGET Boost::serialization)
|
|
+ message(FATAL_ERROR "Boost::multiprecision or Boost::serialization not available!!!")
|
|
+ find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED)
|
|
+ endif()
|
|
+ set(SOPLEX_WITH_BOOST on)
|
|
+ set(libs ${libs} Boost::multiprecision Boost::serialization)
|
|
+ if(MPFR) # MPFR is used within boost multiprecision, so using it without Boost does not make sense
|
|
+ find_package(MPFR REQUIRED)
|
|
+ message(STATUS "SoPlex with Boost MPFR libraries")
|
|
+ set(SOPLEX_WITH_MPFR on)
|
|
+ include_directories(${MPFR_INCLUDE_DIRS})
|
|
+ set(libs ${libs} ${MPFR_LIBRARIES})
|
|
+ else()
|
|
+ message(STATUS "SoPlex with Boost CPP multiprecision libraries")
|
|
+ set(SOPLEX_WITH_CPPMPF on)
|
|
+ endif()
|
|
endif()
|
|
|
|
# disable fused floating point contraction to enhance reproducibility across compilers and architectures
|
|
@@ -251,7 +244,7 @@ set(EXTRA_CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
|
configure_file(${PROJECT_SOURCE_DIR}/soplex-config.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/soplex-config.cmake" @ONLY)
|
|
|
|
add_subdirectory(src)
|
|
-add_subdirectory(tests/c_interface)
|
|
-add_subdirectory(check)
|
|
-
|
|
-enable_testing()
|
|
+if(BUILD_TESTING)
|
|
+ add_subdirectory(tests/c_interface)
|
|
+ add_subdirectory(check)
|
|
+endif()
|
|
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
|
index d57c5fe..11f914a 100644
|
|
--- a/src/CMakeLists.txt
|
|
+++ b/src/CMakeLists.txt
|
|
@@ -193,28 +193,32 @@ target_link_libraries(libsoplexshared libsoplex ${libs})
|
|
set_target_properties(libsoplexshared PROPERTIES CXX_VISIBILITY_PRESET default)
|
|
|
|
# create soplex binary using library without pic
|
|
-add_executable(soplex soplexmain.cpp)
|
|
-target_link_libraries(soplex LINK_PUBLIC libsoplex)
|
|
+if(SOPLEX_SOPLEX)
|
|
+ add_executable(soplex soplexmain.cpp)
|
|
+ target_link_libraries(soplex LINK_PUBLIC libsoplex)
|
|
|
|
-if(EMSCRIPTEN AND EMSCRIPTEN_HTML)
|
|
+ if(EMSCRIPTEN AND EMSCRIPTEN_HTML)
|
|
set_target_properties(soplex PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/soplex_webdemo_shell.html)
|
|
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
|
-endif()
|
|
+ endif()
|
|
+
|
|
+ # set the install rpath to the installed destination
|
|
+ set_target_properties(soplex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
|
|
|
-if(SANITIZE)
|
|
+ if(SANITIZE)
|
|
find_package(Sanitizers)
|
|
add_sanitizers(libsoplex)
|
|
add_sanitizers(libsoplex-pic)
|
|
add_sanitizers(libsoplexshared)
|
|
add_sanitizers(soplex)
|
|
get_target_property(CONF_SANITIZE_FLAGS libsoplex SANITIZE_FLAGS)
|
|
-endif(SANITIZE)
|
|
-
|
|
-add_executable(example EXCLUDE_FROM_ALL example.cpp)
|
|
-target_link_libraries(example libsoplex)
|
|
+ endif(SANITIZE)
|
|
+endif()
|
|
|
|
-# set the install rpath to the installed destination
|
|
-set_target_properties(soplex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
|
+if(SOPLEX_EXAMPLE)
|
|
+ add_executable(example EXCLUDE_FROM_ALL example.cpp)
|
|
+ target_link_libraries(example libsoplex)
|
|
+endif()
|
|
|
|
# install the header files of soplex
|
|
install(FILES ${headers} ${PROJECT_BINARY_DIR}/soplex/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/soplex)
|
|
@@ -243,14 +247,23 @@ install(FILES
|
|
install(FILES ${PROJECT_SOURCE_DIR}/src/soplex/external/zstr/License.txt DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/soplex/zstr)
|
|
|
|
# install the binary and the library to appropriate lcoations and add them to an export group
|
|
-install(TARGETS soplex libsoplex libsoplex-pic libsoplexshared EXPORT soplex-targets
|
|
+if(SOPLEX_SOPLEX)
|
|
+ install(TARGETS soplex EXPORT soplex-targets
|
|
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
+
|
|
+ if(MSVC)
|
|
+ install(FILES $<TARGET_PDB_FILE:soplex> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
|
|
+ endif()
|
|
+endif()
|
|
+
|
|
+install(TARGETS libsoplex libsoplex-pic libsoplexshared EXPORT soplex-targets
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
if(MSVC)
|
|
- install(FILES $<TARGET_PDB_FILE:libsoplexshared> $<TARGET_PDB_FILE:soplex> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
|
|
+ install(FILES $<TARGET_PDB_FILE:libsoplexshared> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
|
|
endif()
|
|
|
|
# install license files of soplex and fmt
|
|
@@ -258,8 +271,10 @@ install(FILES ${PROJECT_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}
|
|
install(FILES ${PROJECT_SOURCE_DIR}/src/soplex/external/fmt/LICENSE.rst DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/soplex/fmt)
|
|
|
|
# Add library targets to the build-tree export set
|
|
-export(TARGETS libsoplex libsoplex-pic libsoplexshared
|
|
- FILE "${CMAKE_BINARY_DIR}/soplex-targets.cmake")
|
|
+if(SOPLEX_EXPORT)
|
|
+ export(TARGETS libsoplex libsoplex-pic libsoplexshared
|
|
+ FILE "${CMAKE_BINARY_DIR}/soplex-targets.cmake")
|
|
+endif()
|
|
|
|
#configure the config file for the build tree
|
|
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}")
|