diff --git a/CMakeLists.txt b/CMakeLists.txt index 275ff23983..da4a4738d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -281,6 +281,7 @@ message(STATUS "CPLEX support: ${USE_CPLEX}") ## XPRESS # Since it is dynamicaly loaded upon use, OFF is currently not supported. CMAKE_DEPENDENT_OPTION(USE_XPRESS "Use the Xpress solver" ON "BUILD_CXX" OFF) +option(BUILD_XPRESS_TEST_AND_EXAMPLES "Build Xpress-specific tests" OFF) # Language specific options if(BUILD_CXX) @@ -438,3 +439,6 @@ endforeach() # Add tests in examples/tests add_subdirectory(examples/tests) + +# Add Xpress specific tests +add_subdirectory(examples/xpress_tests) diff --git a/examples/xpress_tests/CMakeLists.txt b/examples/xpress_tests/CMakeLists.txt new file mode 100644 index 0000000000..684467254f --- /dev/null +++ b/examples/xpress_tests/CMakeLists.txt @@ -0,0 +1,29 @@ +if (NOT BUILD_XPRESS_TEST_AND_EXAMPLES) + return() +endif () + +if (BUILD_CXX_EXAMPLES) + add_cxx_example(${CMAKE_CURRENT_SOURCE_DIR}/xpress_use.cc) +endif () + +if (BUILD_PYTHON_EXAMPLES) + add_python_example(${CMAKE_CURRENT_SOURCE_DIR}/callback_xpress.py) +endif () + +include(CTest) +if (BUILD_CXX_EXAMPLES) + if (APPLE) + set(CMAKE_INSTALL_RPATH + "@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path") + elseif (UNIX) + set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:$ORIGIN:$ORIGIN/../lib:$ORIGIN") + endif () + + if (BUILD_TESTING) + add_executable(xprs_interface xpress_interface.cc) + target_compile_features(xprs_interface PRIVATE cxx_std_17) + target_link_libraries(xprs_interface PRIVATE ortools::ortools GTest::gtest_main) + + add_test(NAME cxx_unittests_xpress_interface COMMAND xprs_interface) + endif () +endif () \ No newline at end of file diff --git a/xpress_tests/callback_xpress.py b/examples/xpress_tests/callback_xpress.py similarity index 100% rename from xpress_tests/callback_xpress.py rename to examples/xpress_tests/callback_xpress.py diff --git a/ortools/linear_solver/unittests/xpress_interface.cc b/examples/xpress_tests/xpress_interface.cc similarity index 100% rename from ortools/linear_solver/unittests/xpress_interface.cc rename to examples/xpress_tests/xpress_interface.cc diff --git a/xpress_tests/xpress_use.cc b/examples/xpress_tests/xpress_use.cc similarity index 100% rename from xpress_tests/xpress_use.cc rename to examples/xpress_tests/xpress_use.cc diff --git a/ortools/linear_solver/CMakeLists.txt b/ortools/linear_solver/CMakeLists.txt index 0124e6a4a9..3ae9a6a262 100644 --- a/ortools/linear_solver/CMakeLists.txt +++ b/ortools/linear_solver/CMakeLists.txt @@ -11,7 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(unittests) file(GLOB _SRCS "*.h" "*.cc") list(REMOVE_ITEM _SRCS ${CMAKE_CURRENT_SOURCE_DIR}/solve.cc diff --git a/ortools/linear_solver/unittests/CMakeLists.txt b/ortools/linear_solver/unittests/CMakeLists.txt deleted file mode 100644 index f827e1754c..0000000000 --- a/ortools/linear_solver/unittests/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -if(NOT BUILD_LINEAR_SOLVER_UNITTESTS) - return() -endif() - -include(FetchContent) -FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG 703bd9caab50b139428cea1aaff9974ebee5742e # release-1.10.0 -) -FetchContent_MakeAvailable(googletest) - - -if(BUILD_CXX_EXAMPLES) - if(APPLE) - set(CMAKE_INSTALL_RPATH - "@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path") - elseif(UNIX) - set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:$ORIGIN") - endif() - if(BUILD_TESTING) - if (USE_SIRIUS) - add_executable(test_sirius_interface sirius_interface.cc) - target_include_directories(test_sirius_interface PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - target_compile_features(test_sirius_interface PRIVATE cxx_std_17) - target_link_libraries(test_sirius_interface PRIVATE ortools::ortools gtest) - - add_test(NAME cxx_unittests_sirius_interface COMMAND test_sirius_interface) - endif() - add_executable(xprs_interface xpress_interface.cc) - target_include_directories(xprs_interface PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - target_compile_features(xprs_interface PRIVATE cxx_std_17) - target_link_libraries(xprs_interface PRIVATE ortools::ortools GTest::gtest_main) - - add_test(NAME cxx_unittests_xpress_interface COMMAND xprs_interface) - endif() -endif()