|
| 1 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 2 | +index 0b21f5a..ddf1536 100644 |
| 3 | +--- a/CMakeLists.txt |
| 4 | ++++ b/CMakeLists.txt |
| 5 | +@@ -27,6 +27,10 @@ set(CPACK_PACKAGE_VERSION_PATCH "${SOPLEX_VERSION_PATCH}") |
| 6 | + set(CPACK_PACKAGE_VENDOR "Zuse Institute Berlin") |
| 7 | + include(CPack) |
| 8 | + |
| 9 | ++# Disable CTest targets |
| 10 | ++set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1) |
| 11 | ++include(CTest) |
| 12 | ++ |
| 13 | + option(ZLIB "Use ZLIB" ON) |
| 14 | + option(GMP "Use GMP" ON) |
| 15 | + option(EMSCRIPTEN_HTML "Emscripten HTML output" OFF) |
| 16 | +@@ -43,11 +47,17 @@ option(SANITIZE_THREAD "should the thread sanitizer be enabled in debug mode if |
| 17 | + option(COVERAGE "enable coverage support" OFF) |
| 18 | + option(PAPILO "should papilo library be linked" ON) |
| 19 | + |
| 20 | ++option(SOPLEX_EXAMPLE "Build example" OFF) |
| 21 | ++option(SOPLEX_SOPLEX "Build soplex program" OFF) |
| 22 | ++option(SOPLEX_EXPORT "Enable to use soplex from the current project's build tree, without installation." OFF) |
| 23 | ++ |
| 24 | + SET(COVERAGE_CTEST_ARGS "" CACHE STRING "additional ctest arguments for coverage") |
| 25 | + |
| 26 | +-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| 27 | +-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 28 | +-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 29 | ++if(CMAKE_PROJECT_NAME EQUAL "SOPLEX") |
| 30 | ++ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| 31 | ++ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 32 | ++ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 33 | ++endif() |
| 34 | + |
| 35 | + # for colorized output |
| 36 | + if(NOT WIN32) |
| 37 | +@@ -69,6 +79,8 @@ set(CMAKE_MACOSX_RPATH ON) |
| 38 | + |
| 39 | + # use C++14 standard |
| 40 | + set(CMAKE_CXX_STANDARD 14) |
| 41 | ++set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 42 | ++set(CMAKE_CXX_EXTENSIONS OFF) |
| 43 | + |
| 44 | + # set function visibility default to hidden |
| 45 | + set(CMAKE_CXX_VISIBILITY_PRESET hidden) |
| 46 | +@@ -123,12 +135,11 @@ if(COVERAGE) |
| 47 | + endif() |
| 48 | + |
| 49 | + if(ZLIB) |
| 50 | +- find_package(ZLIB) |
| 51 | +-endif() |
| 52 | +-if(ZLIB_FOUND) |
| 53 | +- set(SOPLEX_WITH_ZLIB on) |
| 54 | +- set(libs ${libs} ${ZLIB_LIBRARIES}) |
| 55 | +- include_directories(${ZLIB_INCLUDE_DIRS}) |
| 56 | ++ if(NOT TARGET ZLIB::ZLIB) |
| 57 | ++ find_package(ZLIB REQUIRED) |
| 58 | ++ endif() |
| 59 | ++ set(SOPLEX_WITH_ZLIB on) |
| 60 | ++ set(libs ${libs} ZLIB::ZLIB) |
| 61 | + endif() |
| 62 | + |
| 63 | + if(GMP) |
| 64 | +@@ -170,39 +181,24 @@ else() |
| 65 | + set(SOPLEX_WITH_PAPILO off) |
| 66 | + endif() |
| 67 | + |
| 68 | +-set(BOOST_MINIMUM_VERSION 1.65.0) |
| 69 | ++set(BOOST_MINIMUM_VERSION 1.65.0) # PaPILO requires at least Boost 1.65 (on mac 1.72) |
| 70 | + if(BOOST) |
| 71 | +- find_package(Boost ${BOOST_MINIMUM_VERSION}) # PaPILO requires at least Boost 1.65 (on mac 1.72) |
| 72 | +- if(Boost_FOUND) |
| 73 | +- set(SOPLEX_WITH_BOOST on) |
| 74 | +- include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) |
| 75 | +- if(NOT Boost_VERSION_MACRO) |
| 76 | +- set(Boost_VERSION_MACRO ${Boost_VERSION}) |
| 77 | +- endif() |
| 78 | +- if(${Boost_VERSION_MACRO} LESS "107000") |
| 79 | +- if(NOT SOPLEX_WITH_GMP) |
| 80 | +- message(SEND_ERROR "If no GMP is linked, then the minimal Boost verion is 1.70. \ |
| 81 | +- Found Boost version is ${Boost_VERSION_STRING}. Either provide newer Boost, link GMP, or disable Boost by setting BOOST=off.") |
| 82 | +- else() |
| 83 | +- message(WARNING "The multiprecision and quadprecision features are disabled with Boost versions older than 1.70. \ |
| 84 | +- Found Boost version is ${Boost_VERSION_STRING}.") |
| 85 | +- endif() |
| 86 | +- endif() |
| 87 | +- if(MPFR) # MPFR is used within boost multiprecision, so using it without Boost does not make sense |
| 88 | +- find_package(MPFR) |
| 89 | +- endif() |
| 90 | +- if(MPFR_FOUND) |
| 91 | +- message(STATUS "SoPlex with Boost MPFR libraries") |
| 92 | +- set(SOPLEX_WITH_MPFR on) |
| 93 | +- include_directories(${MPFR_INCLUDE_DIRS}) |
| 94 | +- set(libs ${libs} ${MPFR_LIBRARIES}) |
| 95 | +- else() |
| 96 | +- message(STATUS "SoPlex with Boost CPP multiprecision libraries") |
| 97 | +- set(SOPLEX_WITH_CPPMPF on) |
| 98 | +- endif() |
| 99 | +- else() |
| 100 | +- set(BOOST off) |
| 101 | +- endif() |
| 102 | ++ if(NOT TARGET Boost::multiprecision OR NOT TARGET Boost::serialization) |
| 103 | ++ message(FATAL_ERROR "Boost::multiprecision or Boost::serialization not available!!!") |
| 104 | ++ find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED) |
| 105 | ++ endif() |
| 106 | ++ set(SOPLEX_WITH_BOOST on) |
| 107 | ++ set(libs ${libs} Boost::multiprecision Boost::serialization) |
| 108 | ++ if(MPFR) # MPFR is used within boost multiprecision, so using it without Boost does not make sense |
| 109 | ++ find_package(MPFR REQUIRED) |
| 110 | ++ message(STATUS "SoPlex with Boost MPFR libraries") |
| 111 | ++ set(SOPLEX_WITH_MPFR on) |
| 112 | ++ include_directories(${MPFR_INCLUDE_DIRS}) |
| 113 | ++ set(libs ${libs} ${MPFR_LIBRARIES}) |
| 114 | ++ else() |
| 115 | ++ message(STATUS "SoPlex with Boost CPP multiprecision libraries") |
| 116 | ++ set(SOPLEX_WITH_CPPMPF on) |
| 117 | ++ endif() |
| 118 | + endif() |
| 119 | + |
| 120 | + # disable fused floating point contraction to enhance reproducibility across compilers and architectures |
| 121 | +@@ -247,7 +243,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/soplex/config.h.in ${PROJECT_BINA |
| 122 | + configure_file(${PROJECT_SOURCE_DIR}/soplex-config.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/soplex-config.cmake" @ONLY) |
| 123 | + |
| 124 | + add_subdirectory(src) |
| 125 | +-add_subdirectory(tests/c_interface) |
| 126 | +-add_subdirectory(check) |
| 127 | +- |
| 128 | +-enable_testing() |
| 129 | ++if(BUILD_TESTING) |
| 130 | ++ add_subdirectory(tests/c_interface) |
| 131 | ++ add_subdirectory(check) |
| 132 | ++endif() |
| 133 | +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt |
| 134 | +index 84ec5a5..6f5d4ef 100644 |
| 135 | +--- a/src/CMakeLists.txt |
| 136 | ++++ b/src/CMakeLists.txt |
| 137 | +@@ -193,24 +193,28 @@ target_link_libraries(libsoplexshared libsoplex ${libs}) |
| 138 | + set_target_properties(libsoplexshared PROPERTIES CXX_VISIBILITY_PRESET default) |
| 139 | + |
| 140 | + # create soplex binary using library without pic |
| 141 | +-add_executable(soplex soplexmain.cpp) |
| 142 | +-target_link_libraries(soplex LINK_PUBLIC libsoplex ${Boost_LIBRARIES}) |
| 143 | ++if(SOPLEX_SOPLEX) |
| 144 | ++ add_executable(soplex EXCLUDE_FROM_ALL soplexmain.cpp) |
| 145 | ++ target_link_libraries(soplex PRIVATE libsoplex ${Boost_LIBRARIES}) |
| 146 | + |
| 147 | +-if(EMSCRIPTEN AND EMSCRIPTEN_HTML) |
| 148 | ++ # set the install rpath to the installed destination |
| 149 | ++ set_target_properties(soplex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") |
| 150 | ++ |
| 151 | ++ if(EMSCRIPTEN AND EMSCRIPTEN_HTML) |
| 152 | + set_target_properties(soplex PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/soplex_webdemo_shell.html) |
| 153 | + set(CMAKE_EXECUTABLE_SUFFIX ".html") |
| 154 | +-endif() |
| 155 | ++ endif() |
| 156 | + |
| 157 | +-if(CMAKE_BUILD_TYPE EQUAL "Debug") |
| 158 | +- find_package(Sanitizers) |
| 159 | +- add_sanitizers(soplex) |
| 160 | ++ if(CMAKE_BUILD_TYPE EQUAL "Debug") |
| 161 | ++ find_package(Sanitizers) |
| 162 | ++ add_sanitizers(soplex) |
| 163 | ++ endif() |
| 164 | + endif() |
| 165 | + |
| 166 | +-add_executable(example EXCLUDE_FROM_ALL example.cpp) |
| 167 | +-target_link_libraries(example libsoplex) |
| 168 | +- |
| 169 | +-# set the install rpath to the installed destination |
| 170 | +-set_target_properties(soplex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") |
| 171 | ++if(SOPLEX_EXAMPLE) |
| 172 | ++ add_executable(example example.cpp) |
| 173 | ++ target_link_libraries(example libsoplex) |
| 174 | ++endif() |
| 175 | + |
| 176 | + # install the header files of soplex |
| 177 | + install(FILES ${headers} ${PROJECT_BINARY_DIR}/soplex/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/soplex) |
| 178 | +@@ -237,15 +241,28 @@ install(FILES |
| 179 | + DESTINATION include/soplex/external/zstr) |
| 180 | + |
| 181 | + # install the binary and the library to appropriate lcoations and add them to an export group |
| 182 | +-install(TARGETS soplex libsoplex libsoplex-pic libsoplexshared EXPORT soplex-targets |
| 183 | ++if(SOPLEX_SOPLEX) |
| 184 | ++ install(TARGETS soplex |
| 185 | ++ EXPORT soplex-targets |
| 186 | ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 187 | ++endif() |
| 188 | ++ |
| 189 | ++install(TARGETS libsoplex libsoplex-pic libsoplexshared |
| 190 | ++ EXPORT soplex-targets |
| 191 | + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 192 | + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 193 | + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 194 | + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 195 | + |
| 196 | ++install(EXPORT soplex-targets |
| 197 | ++ FILE soplex-targets.cmake |
| 198 | ++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/soplex) |
| 199 | ++ |
| 200 | + # Add library targets to the build-tree export set |
| 201 | +-export(TARGETS libsoplex libsoplex-pic libsoplexshared |
| 202 | +- FILE "${CMAKE_BINARY_DIR}/soplex-targets.cmake") |
| 203 | ++if(SOPLEX_EXPORT) |
| 204 | ++ export(TARGETS libsoplex libsoplex-pic libsoplexshared |
| 205 | ++ FILE "${CMAKE_BINARY_DIR}/soplex-targets.cmake") |
| 206 | ++endif() |
| 207 | + |
| 208 | + #configure the config file for the build tree |
| 209 | + set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}") |
| 210 | +@@ -259,7 +276,6 @@ ${CMAKE_BINARY_DIR}/soplex-config-version.cmake |
| 211 | + COMPATIBILITY SameMajorVersion |
| 212 | + ) |
| 213 | + |
| 214 | +- |
| 215 | + #configure the config file for the install |
| 216 | + set(CONF_INCLUDE_DIRS "\${CMAKE_CURRENT_LIST_DIR}/../../../include") |
| 217 | + configure_file(${PROJECT_SOURCE_DIR}/soplex-config.cmake.in |
| 218 | +@@ -267,7 +283,6 @@ configure_file(${PROJECT_SOURCE_DIR}/soplex-config.cmake.in |
| 219 | + |
| 220 | + # install the targets of the soplex export group and the config file so that other projects |
| 221 | + # can link easily against soplex |
| 222 | +-install(EXPORT soplex-targets FILE soplex-targets.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/soplex) |
| 223 | + install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/soplex-config.cmake" |
| 224 | + ${CMAKE_BINARY_DIR}/soplex-config-version.cmake |
| 225 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/soplex) |
0 commit comments