Skip to content

Commit

Permalink
Use experimental Lingeling IPASIR-2 implementation to run examples
Browse files Browse the repository at this point in the history
  • Loading branch information
fkutzner committed Apr 13, 2024
1 parent 928065a commit ff4ff02
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "deps/ipasir2"]
path = deps/ipasir2
url = https://github.com/ipasir2/ipasir2
[submodule "testdeps/ipasir2_solver_lingeling"]
path = testdeps/ipasir2_solver_lingeling
url = https://github.com/ipasir2/ipasir2_solver_lingeling
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_link_libraries(ipasir2cpp INTERFACE ipasir2)
# is deliberately light on compiler options to make sure that the headers don't force
# clients to set any.
if (MSVC)
add_compile_options(
set(IPASIR2CPP_CXX_OPTS
/DNOMINMAX # Keep Windows.h from #defining min() and max()
/permissive- # Be strict about C++ conformance
/W4 # Use highest warning level
Expand All @@ -53,7 +53,7 @@ if (MSVC)
)
else()
# Assume GCC or clang:
add_compile_options(
set(IPASIR2CPP_CXX_OPTS
-Wall
-Wextra
-Wunused
Expand Down
10 changes: 4 additions & 6 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
if(WIN32)
# Currently the minisat dependency can't be built in cross-compilation
# Lingeling can't be built on Windows currently
return()
endif()


include(${CMAKE_CURRENT_LIST_DIR}/../deps/ipasir2/buildutils/load_solvers.cmake)

load_minisat()

add_executable(examples-all
01_readme.cpp
02_trivial_portfolio.cpp
Expand All @@ -18,7 +14,8 @@ add_executable(examples-all
main.cpp
)

target_link_libraries(examples-all PRIVATE ipasir2cpp minisat)
target_compile_options(examples-all PRIVATE ${IPASIR2CPP_CXX_OPTS})
target_link_libraries(examples-all PRIVATE ipasir2cpp lingeling-static)


if (NOT WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Expand All @@ -34,6 +31,7 @@ add_executable(example-utils-testsuite
example_utils_tests.cpp
)

target_compile_options(example-utils-testsuite PRIVATE ${IPASIR2CPP_CXX_OPTS})
target_link_libraries(example-utils-testsuite PRIVATE Catch2::Catch2WithMain)

add_test(NAME example-utils-testsuite COMMAND example-utils-testsuite)
8 changes: 7 additions & 1 deletion testdeps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/Catch2/CMakeLists.txt)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/Catch2/CMakeLists.txt
OR NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/ipasir2_solver_lingeling/CMakeLists.txt)
message(FATAL_ERROR "git submodules have not been set up yet. Run git submodule update --init")
endif()

add_subdirectory(Catch2)

if (NOT WIN32)
set(LGL_BUILD_TOOLS OFF)
add_subdirectory(ipasir2_solver_lingeling)
endif()
1 change: 1 addition & 0 deletions testdeps/ipasir2_solver_lingeling
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function(add_test_executables BASENAME)
endif()

target_include_directories(${name} PRIVATE ${test_base_dir})
target_compile_options(${name} PRIVATE ${IPASIR2CPP_CXX_OPTS})
target_link_libraries(${name} PRIVATE ipasir2cpp Catch2::Catch2WithMain)

add_test(NAME ${name} COMMAND ${name} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
Expand Down
1 change: 1 addition & 0 deletions tests/mock/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# The IPASIR2 mock is built as a shared library so it can be used to test
# the dynamic-loading functions of the IPASIR2 wrapper:
add_library(ipasir2mock SHARED ipasir2_mock.cpp ipasir2_mock.h)
target_compile_options(ipasir2mock PRIVATE ${IPASIR2CPP_CXX_OPTS})
target_link_libraries(ipasir2mock PRIVATE ipasir2)
target_compile_definitions(ipasir2mock PRIVATE BUILDING_IPASIR_SHARED_LIB)
target_compile_definitions(ipasir2mock INTERFACE IPASIR_SHARED_LIB)
Expand Down

0 comments on commit ff4ff02

Please sign in to comment.