Skip to content

Commit

Permalink
Make MOAB a proper optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Jan 5, 2024
1 parent d2f9a6b commit 5bfbdf1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(openmc C CXX)

option(XDG_MOAB_BACKEND "Enable MAOB mesh" ON)
option(XDG_MFEM_BACKEND "Enable MFEM mesh" OFF)
option(XDG_LIBMESH_BACKEND "Enable libMesh mesh" OFF)
option(XDG_ENABLE_MOAB "Enable support for the MOAB mesh library" ON)
option(XDG_ENABLE_MFEM "Enable support for the MFEM mesh library" OFF)
option(XDG_ENABLE_LIBMESH "Enable support for the libMesh mesh library" OFF)
option(XDG_BUILD_TESTS "Enable C++ unit testing" ON)

if(NOT CMAKE_BUILD_TYPE)
Expand All @@ -14,7 +14,9 @@ endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# require MOAB for now
if (XDG_ENABLE_MOAB)
find_package(MOAB REQUIRED HINTS ${MOAB_DIR})
endif()

# use Embree for CPU ray tracing
find_package(embree 3.6.1 REQUIRED)
Expand Down Expand Up @@ -46,12 +48,16 @@ src/plucker.cpp
src/ray_tracing_interface.cpp
src/triangle_ref.cpp
src/util/str_utils.cpp
)

if (XDG_ENABLE_MOAB)
list(APPEND xdg_sources
# MOAB
src/moab/mesh_manager.cpp
src/moab/direct_access.cpp
src/moab/metadata.cpp
)
endif()

add_library(xdg SHARED ${xdg_sources})

Expand All @@ -76,6 +82,6 @@ target_include_directories(xdg

target_link_libraries(xdg embree fmt::fmt)

if (XDG_MOAB_BACKEND)
if (XDG_ENABLE_MOAB)
target_link_libraries(xdg MOAB)
endif()
5 changes: 4 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ test_closest
test_ray_fire
test_mesh_internal
test_xdg_interface
test_moab
)

if (XDG_ENABLE_MOAB)
list(APPEND TEST_NAMES test_moab)
endif()

foreach(test ${TEST_NAMES})
add_executable(${test} ${test}.cpp)
target_link_libraries(${test} xdg Catch2::Catch2WithMain)
Expand Down

0 comments on commit 5bfbdf1

Please sign in to comment.