Skip to content

Commit

Permalink
Fix issue with hard-wired CUDA consumer. (#34)
Browse files Browse the repository at this point in the history
* Fix bug 33.

* Use generic name for the consumer app.

* Set CUDA as optional in ReSolveConfig.cmake

---------

Co-authored-by: Ryan Danehy <dane678@deception02.pnl.gov>
  • Loading branch information
pelesh and Ryan Danehy authored Oct 27, 2023
1 parent ab5584b commit d84d8a5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
14 changes: 8 additions & 6 deletions cmake/ReSolveConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ include("${CMAKE_CURRENT_LIST_DIR}/ReSolveTargets.cmake")

include(CheckLanguage)
# This must come before enable_language(CUDA)
set(CMAKE_CUDA_COMPILER @CMAKE_CUDA_COMPILER@)
enable_language(CUDA)
check_language(CUDA)
set(CMAKE_CUDA_FLAGS "@CMAKE_CUDA_FLAGS@")
find_package(CUDAToolkit REQUIRED)
if(@RESOLVE_USE_CUDA@)
set(CMAKE_CUDA_COMPILER @CMAKE_CUDA_COMPILER@)
enable_language(CUDA)
check_language(CUDA)
set(CMAKE_CUDA_FLAGS "@CMAKE_CUDA_FLAGS@")
find_package(CUDAToolkit REQUIRED)
endif()

# Compute installation prefix relative to this file.
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_prefix "${_dir}/../../.." ABSOLUTE)

# Report other information.
set(ReSolve_INCLUDE_DIRS "${_prefix}/include/")
set(ReSolve_INCLUDE_DIRS "${_prefix}/include/")
9 changes: 8 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,16 @@ set(CONSUMER_PATH ${CMAKE_INSTALL_PREFIX}/share/examples)
# Make the resolve consumer test script exectuable
install(PROGRAMS test.sh DESTINATION ${CONSUMER_PATH})

# Select consumer app
if(RESOLVE_USE_CUDA)
set(RESOLVE_CONSUMER_APP "testKLU_Rf_FGMRES.cpp")
else()
set(RESOLVE_CONSUMER_APP "testKLU.cpp")
endif()

# Install directory with example on how to consume ReSolve
install(DIRECTORY resolve_consumer DESTINATION share/examples)
install(FILES ${PROJECT_SOURCE_DIR}/tests/functionality/testKLU_Rf_FGMRES.cpp DESTINATION share/examples/resolve_consumer)
install(FILES ${PROJECT_SOURCE_DIR}/tests/functionality/${RESOLVE_CONSUMER_APP} DESTINATION share/examples/resolve_consumer RENAME consumer.cpp)

# Shell script argumets:
# 1. Path to where resolve is installed.
Expand Down
2 changes: 1 addition & 1 deletion examples/resolve_consumer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project(resolve_consumer LANGUAGES CXX)
find_package(ReSolve REQUIRED)

# Build example with KLU factorization and KLU refactorization
add_executable(consume.exe testKLU_Rf_FGMRES.cpp)
add_executable(consume.exe consumer.cpp)
target_link_libraries(consume.exe PRIVATE ReSolve::ReSolve)

#------------------------------------------------------------------------------------
Expand Down

0 comments on commit d84d8a5

Please sign in to comment.