add xpress tests dir

This commit is contained in:
Andrea Sgattoni
2023-10-23 12:56:08 +02:00
parent 53f1aa0013
commit f189b4e2f5
7 changed files with 33 additions and 38 deletions

View File

@@ -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)

View File

@@ -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 ()

View File

@@ -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

View File

@@ -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()