Skip to content

Commit

Permalink
Clean up CHAI dependency handling
Browse files Browse the repository at this point in the history
  • Loading branch information
adayton1 committed Feb 16, 2024
1 parent a6ee821 commit 5afb66a
Showing 1 changed file with 21 additions and 54 deletions.
75 changes: 21 additions & 54 deletions cmake/thirdparty/SetupChaiThirdparty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,34 @@
#
# SPDX-License-Identifier: BSD-3-Clause
##############################################################################

if (NOT TARGET umpire)
if (DEFINED umpire_DIR)
# this allows umpire_DIR to be the install prefix if we are relying on umpire's
# installed umpire-config.cmake
list(APPEND CMAKE_PREFIX_PATH ${umpire_DIR})
find_package(umpire REQUIRED)

if (ENABLE_MPI)
set(UMPIRE_DEPENDS mpi)
else()
set(UMPIRE_DEPENDS)
endif()

blt_register_library(
NAME umpire
INCLUDES ${UMPIRE_INCLUDE_DIRS}
LIBRARIES umpire
DEPENDS_ON ${UMPIRE_DEPENDS})
find_package(umpire CONFIG REQUIRED NO_DEFAULT_PATH PATHS ${umpire_DIR})
else ()
set(UMPIRE_ENABLE_FORTRAN Off CACHE BOOL "Enable Fortran in Umpire")
set(UMPIRE_ENABLE_C Off CACHE BOOL "Enable Fortran in Umpire")
set(UMPIRE_ENABLE_TESTS Off CACHE BOOL "")
set(UMPIRE_ENABLE_TOOLS Off CACHE BOOL "")
add_subdirectory(${PROJECT_SOURCE_DIR}/src/tpl/umpire)
endif()

# Umpire depends on camp
if (NOT TARGET camp)
if (DEFINED camp_DIR)
find_package(camp REQUIRED)
set_target_properties(camp PROPERTIES IMPORTED_GLOBAL TRUE)
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/src/tpl/umpire/CMakeLists.txt)
message(FATAL_ERROR "[CHAI] Umpire not found! Set umpire_DIR to the install location of Umpire or run 'git submodule update --init --recursive' in the CHAI repository, then try building again.")
else ()
message(FATAL_ERROR "camp is required. Please set camp_DIR")
endif()
set(UMPIRE_ENABLE_FORTRAN Off CACHE BOOL "Enable Fortran in Umpire")
set(UMPIRE_ENABLE_C Off CACHE BOOL "Enable Fortran in Umpire")
set(UMPIRE_ENABLE_TESTS Off CACHE BOOL "Enable tests in Umpire")
set(UMPIRE_ENABLE_TOOLS Off CACHE BOOL "Enable tools in Umpire")

if(ENABLE_CUDA)
blt_add_target_definitions(
TO camp
SCOPE INTERFACE
TARGET_DEFINITIONS CAMP_HAVE_CUDA)
endif()
add_subdirectory(${PROJECT_SOURCE_DIR}/src/tpl/umpire)
endif ()
endif ()
endif()
endif ()

if (CHAI_ENABLE_RAJA_PLUGIN)
if (NOT TARGET RAJA)
if (DEFINED RAJA_DIR)
# this allows RAJA_DIR to be the install prefix if we are relying on RAJA's
# installed RAJA-config.cmake
list(APPEND CMAKE_PREFIX_PATH ${RAJA_DIR})
message(STATUS "CHAI: using external RAJA via find_package ${RAJA_DIR}")
find_package(RAJA REQUIRED)
blt_register_library(
NAME RAJA
INCLUDES ${RAJA_INCLUDE_DIRS}
LIBRARIES RAJA)
else()
message(STATUS "CHAI: using builtin RAJA submodule")
add_subdirectory(${PROJECT_SOURCE_DIR}/src/tpl/raja)
endif()
else()
message(STATUS "CHAI: using existing RAJA target")
endif()
if (DEFINED raja_DIR)
find_package(raja CONFIG REQUIRED NO_DEFAULT_PATH PATHS ${raja_DIR})
else ()
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/src/tpl/raja/CMakeLists.txt)
message(FATAL_ERROR "[CHAI] RAJA not found! Set raja_DIR to the install location of RAJA or run 'git submodule update --init --recursive' in the CHAI repository, then try building again.")
else ()
add_subdirectory(${PROJECT_SOURCE_DIR}/src/tpl/raja)
endif ()
endif ()
endif ()
endif ()

0 comments on commit 5afb66a

Please sign in to comment.