Skip to content

Commit

Permalink
Reuse common add_cxx_example function for Sat Runner
Browse files Browse the repository at this point in the history
Add an optional parameter to leave out the example from testing.
  • Loading branch information
StefanBruens committed May 10, 2023
1 parent b0dad09 commit 03b8139
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
5 changes: 3 additions & 2 deletions cmake/cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,9 @@ function(add_cxx_example FILE_NAME)

install(TARGETS ${EXAMPLE_NAME})

if(BUILD_TESTING)
add_test(NAME cxx_${COMPONENT_NAME}_${EXAMPLE_NAME} COMMAND ${EXAMPLE_NAME})
set(SKIP_TEST (${ARGC} GREATER 1) AND ${ARG1})
if(BUILD_TESTING AND NOT SKIP_TEST)
add_test(NAME cxx_${COMPONENT_NAME}_${EXAMPLE_NAME} COMMAND ${EXAMPLE_NAME})
endif()
message(STATUS "Configuring example ${FILE_NAME}: ...DONE")
endfunction()
Expand Down
17 changes: 1 addition & 16 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,8 @@ foreach(SAMPLE IN LISTS CXX_SRCS)
endforeach()

# Sat Runner
include(GNUInstallDirs)
if(APPLE)
set(CMAKE_INSTALL_RPATH
"@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path")
elseif(UNIX)
set(CMAKE_INSTALL_RPATH
"$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:$ORIGIN/../lib64:$ORIGIN/../lib:$ORIGIN")
endif()

add_executable(sat_runner)
add_cxx_example("${CMAKE_CURRENT_LIST_DIR}/sat_runner.cc" TRUE)
target_sources(sat_runner PRIVATE
"sat_runner.cc"
"opb_reader.h"
"sat_cnf_reader.h")
target_include_directories(sat_runner PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(sat_runner PRIVATE cxx_std_17)
target_link_libraries(sat_runner PRIVATE ${PROJECT_NAMESPACE}::ortools)

install(TARGETS sat_runner)

0 comments on commit 03b8139

Please sign in to comment.