Skip to content

Commit

Permalink
Merge pull request picassodev#99 from streeve/optional_arborx
Browse files Browse the repository at this point in the history
Make ArborX optional
  • Loading branch information
streeve authored Apr 15, 2024
2 parents f621d19 + e8b8e0e commit 9704b1b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ project(Picasso LANGUAGES CXX C VERSION 0.1.0)

include(GNUInstallDirs)

# User options
option(Picasso_REQUIRE_ARBORX "Build with ArborX support" OFF)

# find dependencies (MPI and Kokkos found through Cabana)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
find_package(CLANG_FORMAT 10)
find_package(Cabana REQUIRED 0.5 COMPONENTS Cabana::Grid Cabana::Core)
find_package(ArborX REQUIRED)
find_package(Boost 1.66.0 REQUIRED)

# Build with ArborX if available or if requested.
find_package(ArborX QUIET)
if(Picasso_REQUIRE_ARBORX OR ArborX_FOUND)
set(Picasso_ENABLE_ARBORX ON)
find_package(ArborX REQUIRED)
endif()

if(Kokkos_VERSION_MAJOR LESS 4 AND Kokkos_VERSION_MINOR LESS 7)
message( FATAL_ERROR "Picasso requires Kokkos >= 3.7" )
endif()
Expand Down Expand Up @@ -77,8 +86,13 @@ write_basic_package_version_file("PicassoConfigVersion.cmake"

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PicassoConfig.cmakein
${CMAKE_CURRENT_BINARY_DIR}/PicassoConfig.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PicassoSettings.cmakein
${CMAKE_CURRENT_BINARY_DIR}/PicassoSettings.cmake @ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PicassoConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/PicassoConfigVersion.cmake"
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/PicassoConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/PicassoConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/PicassoSettings.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Picasso)

# Clang Format
Expand Down
5 changes: 4 additions & 1 deletion cmake/PicassoConfig.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ list(APPEND CMAKE_PREFIX_PATH @CMAKE_PREFIX_PATH@)
find_dependency(MPI REQUIRED)
find_dependency(Kokkos REQUIRED)
find_dependency(Cabana REQUIRED)
find_dependency(ArborX REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/PicassoSettings.cmake")
if(Picasso_ENABLE_ARBORX)
find_dependency(ArborX REQUIRED)
endif()
find_dependency(Boost REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/Picasso_Targets.cmake")
1 change: 1 addition & 0 deletions cmake/PicassoSettings.cmakein
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(Picasso_ENABLE_ArborX @Picasso_ENABLE_ArborX@)
10 changes: 8 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ set(HEADERS
Picasso_MarchingCubes.hpp
Picasso_ParticleInit.hpp
Picasso_ParticleInterpolation.hpp
Picasso_ParticleLevelSet.hpp
Picasso_ParticleList.hpp
Picasso_PolyPIC.hpp
Picasso_Types.hpp
Expand All @@ -27,6 +26,10 @@ set(HEADERS
Picasso_Version.hpp
)

if(Picasso_ENABLE_ARBORX)
list(APPEND HEADERS Picasso_ParticleLevelSet.hpp)
endif()

set(SOURCES
Picasso_InputParser.cpp
Picasso_UniformMesh.cpp
Expand All @@ -38,9 +41,12 @@ add_library(picasso ${SOURCES})
target_link_libraries(picasso
Cabana::Core
Cabana::Grid
ArborX::ArborX
Boost::boost )

if(Picasso_ENABLE_ARBORX)
target_link_libraries(picasso ArborX::ArborX)
endif()

target_include_directories(picasso
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand Down
4 changes: 4 additions & 0 deletions src/Picasso.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#ifndef PICASSO_HPP
#define PICASSO_HPP

#include <Picasso_config.hpp>

#include <Picasso_APIC.hpp>
#include <Picasso_AdaptiveMesh.hpp>
#include <Picasso_BatchedLinearAlgebra.hpp>
Expand All @@ -26,7 +28,9 @@
#include <Picasso_LevelSetRedistance.hpp>
#include <Picasso_ParticleInit.hpp>
#include <Picasso_ParticleInterpolation.hpp>
#ifdef Picasso_ENABLE_ARBORX
#include <Picasso_ParticleLevelSet.hpp>
#endif
#include <Picasso_ParticleList.hpp>
#include <Picasso_PolyPIC.hpp>
#include <Picasso_Types.hpp>
Expand Down
2 changes: 2 additions & 0 deletions src/Picasso_config.hpp.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@

#define Picasso_GIT_COMMIT_HASH "@Picasso_GIT_COMMIT_HASH@"

#cmakedefine Picasso_ENABLE_ARBORX

#endif // PICASSO_CONFIG_HPP

0 comments on commit 9704b1b

Please sign in to comment.