Skip to content

Commit

Permalink
Enable file-config conditionally
Browse files Browse the repository at this point in the history
+ It depends on nlohmann-json
  • Loading branch information
pratikvn committed Nov 15, 2024
1 parent dc8cfeb commit 49aba31
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ set(EXAMPLES_EXEC_LIST
set(EXAMPLES_LIST
${EXAMPLES_EXEC_LIST}
custom-stopping-criterion
file-config-solver
ginkgo-overhead
minimal-cuda-solver
mixed-spmv
Expand Down Expand Up @@ -64,6 +63,15 @@ else()
message(STATUS "No Kokkos found, disabling examples with Kokkos assembly.")
endif()

set(GKO_FILE_CONFIG_ENABLED 0)
find_package(nlohmann_json 3.9.1 QUIET)
if(nlohmann_json_FOUND)
set(GKO_FILE_CONFIG_ENABLED 1)
list(APPEND EXAMPLES_LIST file-config-solver)
else()
message(STATUS "No nlohmann-json found, disabling file-config example")
endif()

foreach(example ${EXAMPLES_LIST})
add_subdirectory(${example})
endforeach()
Expand Down Expand Up @@ -104,18 +112,20 @@ if(GINKGO_BUILD_TESTS)
endforeach()
endforeach()

file(GLOB config_list RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" file-config-solver/config/*.json)
foreach(config IN LISTS config_list)
get_filename_component(config_name "${config}" NAME_WE)
foreach(executor IN LISTS executors)
add_test(NAME example_file-config-solver_${config_name}_${executor}
COMMAND
"$<TARGET_FILE:file-config-solver>"
"${executor}" "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/config/${config_name}.json"
"${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/data/A.mtx"
WORKING_DIRECTORY
"$<TARGET_FILE_DIR:ginkgo>")
endforeach()
endforeach()
if(GKO_FILE_CONFIG_ENABLED)
file(GLOB config_list RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" file-config-solver/config/*.json)
foreach(config IN LISTS config_list)
get_filename_component(config_name "${config}" NAME_WE)
foreach(executor IN LISTS executors)
add_test(NAME example_file-config-solver_${config_name}_${executor}
COMMAND
"$<TARGET_FILE:file-config-solver>"
"${executor}" "${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/config/${config_name}.json"
"${CMAKE_CURRENT_SOURCE_DIR}/file-config-solver/data/A.mtx"
WORKING_DIRECTORY
"$<TARGET_FILE_DIR:ginkgo>")
endforeach()
endforeach()
endif()

endif()

0 comments on commit 49aba31

Please sign in to comment.