Skip to content

Commit

Permalink
reformating + changelog + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bam241 committed Dec 6, 2024
1 parent 21343f9 commit 45feb89
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 59 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/linux_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
5.4.1,
5.5.1,
]
ddl_deps : [
off,
]
geant4_version : [
10.7.4,
11.1.2
Expand All @@ -58,6 +61,14 @@ jobs:
off,
v1.1.0,
]
include:
- ubuntu_version: 22.04
compiler: gcc
hdf5_version: 1.14.3
moab_version: 5.4.1
ddl_deps: on
geant4_version: off
double_down_version: off

container:
image: ghcr.io/svalinn/dagmc-ci-ubuntu-${{
Expand Down Expand Up @@ -88,6 +99,7 @@ jobs:
cmake ../ \
-DMOAB_DIR=${moab_install_dir} \
-DBUILD_GEANT4=$([ "${{ matrix.geant4_version }}" != "off" ] && echo "ON" || echo "OFF") \
-DDDL_INSTALL_DEPS=$([ "${{ matrix.ddl_deps }}" != "on" ] && echo "OFF" || echo "ON -DHDF5_ROOT=${hdf5_install_dir}") \
-DGEANT4_DIR=${geant4_install_dir} \
-DBUILD_CI_TESTS=ON \
-DBUILD_MW_REG_TESTS=OFF \
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(DAGMC)
cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.1)
enable_language(CXX)

# Set DAGMC version
Expand Down
5 changes: 5 additions & 0 deletions cmake/DAGMC_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ macro (dagmc_install_library lib_name)
EXPORT DAGMCTargets
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDE_DIR})
# Required to ensure that MOAB is built before DAGMC and to properly link against MOAB
if(DDL_INSTALL_DEPS)
add_dependencies(${lib_name}-shared MOAB)
target_link_libraries(${lib_name}-shared PUBLIC ${MOAB_LIBRARY_DIRS}/libMOAB.so)
endif()
endif ()

if (BUILD_STATIC_LIBS)
Expand Down
71 changes: 20 additions & 51 deletions cmake/FindMOAB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,28 @@ find_path(MOAB_CMAKE_CONFIG
PATHS ${MOAB_SEARCH_DIRS}
NO_DEFAULT_PATH
)
if (MOAB_CMAKE_CONFIG)
set(MOAB_CMAKE_CONFIG ${MOAB_CMAKE_CONFIG}/MOABConfig.cmake)
message(STATUS "MOAB_CMAKE_CONFIG: ${MOAB_CMAKE_CONFIG}")
include(${MOAB_CMAKE_CONFIG})
elseif (DDL_INSTALL_DEPS)
include(ExternalProject)
# Configure MOAB
if(NOT MOAB_VERSION)
set(MOAB_VERSION "5.5.1")
endif()
message(STATUS "MOAB version ${MOAB_VERSION} will be downloaded and built")

set(CMAKE_INSTALL_LIBDIR "lib")
SET(MOAB_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/moab")
set(MOAB_ROOT "${CMAKE_BINARY_DIR}/moab")
set(MOAB_INCLUDE_DIRS "${MOAB_INSTALL_PREFIX}/include")
set(MOAB_LIBRARY_DIRS "${MOAB_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(MOAB_LIBRARIES_SHARED "")
ExternalProject_Add(MOAB_ep
PREFIX ${MOAB_ROOT}
GIT_REPOSITORY https://bitbucket.org/fathomteam/moab.git
GIT_TAG ${MOAB_VERSION}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DBUILD_SHARED_LIBS:BOOL=ON
-DENABLE_HDF5:BOOL=ON
-DHDF5_ROOT:PATH=${HDF5_ROOT}
-DEIGEN3_DIR:PATH=${EIGEN3_INCLUDE_DIRS}
-DENABLE_BLASLAPACK:BOOL=OFF
-DENABLE_FORTRAN:BOOL=OFF
-DCMAKE_MACOSX_RPATH:BOOL=ON
DOWNLOAD_EXTRACT_TIMESTAMP true
BUILD_BYPRODUCTS "${MOAB_LIBRARY_DIRS}/*${CMAKE_SHARED_LIBRARY_SUFFIX}*"
# Set devel space as install prefix
INSTALL_DIR "${MOAB_INSTALL_PREFIX}"
)
add_library(MOAB INTERFACE)
# list(APPEND CMAKE_MODULE_PATH ${MOAB_LIBRARY_DIRS}/cmake)
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
message(STATUS "MOAB_LIBRARY_DIRS=${MOAB_LIBRARY_DIRS}")
message(STATUS "MOAB_LIBRARY_DIRS=${MOAB_LIBRARY_DIRS}")
target_include_directories(MOAB SYSTEM INTERFACE ${MOAB_INCLUDE_DIRS})
target_link_libraries(MOAB INTERFACE ${MOAB_INSTALL_PREFIX}/lib64/libMOAB.so)
add_dependencies(MOAB MOAB_ep)
install(TARGETS MOAB LIBRARY DESTINATION ${MOAB_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDE_DIR})
# First check if we are forcing the download of MOAB
if (DDL_INSTALL_DEPS)
IF(DAGMC_BUILD_STATIC_LIBS)
message(FATAL_ERROR "DDL_INSTALL_DEPS is ONLY compatible with shared libraries.")
ENDIF()
IF(NOT MOAB_VERSION)
SET(MOAB_VERSION "5.5.1")
ENDIF()
include(MOAB_PullAndMake)
moab_pull_make(${MOAB_VERSION})

include_directories(${MOAB_INCLUDE_DIRS})
link_directories(${MOAB_LIBRARY_DIRS})
include_directories(${EIGEN3_INCLUDE_DIRS})
# Back to normal behavior
elseif (MOAB_CMAKE_CONFIG)
set(MOAB_CMAKE_CONFIG ${MOAB_CMAKE_CONFIG}/MOABConfig.cmake)
message(STATUS "MOAB_CMAKE_CONFIG: ${MOAB_CMAKE_CONFIG}")
else ()
message(FATAL_ERROR "Could not find MOAB. Set -DMOAB_DIR=<MOAB_DIR> when running cmake or use the $MOAB_DIR environment variable.")
endif ()

# Find HDF5
include(${MOAB_CMAKE_CONFIG})
set(ENV{PATH} "${HDF5_DIR}:$ENV{PATH}")
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
find_package(HDF5 REQUIRED)
Expand Down Expand Up @@ -117,11 +84,13 @@ message(STATUS "MOAB_LIBRARY_DIRS: ${MOAB_LIBRARY_DIRS}")
message(STATUS "MOAB_LIBRARIES_SHARED: ${MOAB_LIBRARIES_SHARED}")
message(STATUS "MOAB_LIBRARIES_STATIC: ${MOAB_LIBRARIES_STATIC}")

if (MOAB_INCLUDE_DIRS AND (MOAB_LIBRARIES_SHARED OR NOT BUILD_SHARED_LIBS) AND
if(DDL_INSTALL_DEPS)
message(STATUS "MOAB will be downloaded and built at make time")
elseif (MOAB_INCLUDE_DIRS AND (MOAB_LIBRARIES_SHARED OR NOT BUILD_SHARED_LIBS) AND
(MOAB_LIBRARIES_STATIC OR NOT BUILD_STATIC_LIBS))
message(STATUS "Found MOAB")
else()
# message(FATAL_ERROR "Could not find MOAB")
else ()
message(FATAL_ERROR "Could not find MOAB")
endif ()

include_directories(${MOAB_INCLUDE_DIRS})
44 changes: 44 additions & 0 deletions cmake/MOAB_PullAndMake.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# this Macro sets up the download and build of MOAB using ExternalProject
# few tweak are done in src/dagmc/CMakeLists.txt and src/PyNE/CMakelists.txt
# to make sure that MOAB is built before DAGMC.
MACRO (moab_pull_make moab_version)
message(STATUS "MOAB will be downloaded and built")
include(ExternalProject)
message("HDF5_ROOT: ${HDF5_ROOT}")
SET(MOAB_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/moab")
set(MOAB_ROOT "${CMAKE_BINARY_DIR}/moab")
set(MOAB_INCLUDE_DIRS "${MOAB_INSTALL_PREFIX}/include")
set(MOAB_LIBRARY_DIRS "${MOAB_INSTALL_PREFIX}/lib")
message("MOAB_LIBRARY_DIRS: ${MOAB_LIBRARY_DIRS}")
set(MOAB_LIBRARIES_SHARED "")
ExternalProject_Add(MOAB_ep
PREFIX ${MOAB_ROOT}
GIT_REPOSITORY https://bitbucket.org/fathomteam/moab.git
GIT_TAG ${moab_version}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DBUILD_SHARED_LIBS:BOOL=ON
-DENABLE_HDF5:BOOL=ON
-DHDF5_ROOT:PATH=${HDF5_ROOT}
-DCMAKE_INSTALL_RPATH=${HDF5_ROOT}/lib:${MOAB_INSTALL_PREFIX}/lib
-DENABLE_BLASLAPACK:BOOL=OFF
-DENABLE_FORTRAN:BOOL=OFF
-DENABLE_PYMOAB:BOOL=OFF
DOWNLOAD_EXTRACT_TIMESTAMP true
BUILD_BYPRODUCTS "${MOAB_LIBRARY_DIRS}/*${CMAKE_SHARED_LIBRARY_SUFFIX}*"
INSTALL_DIR "${MOAB_INSTALL_PREFIX}"
)
# Setup a interface library for MOAB based on ExternalProoject MOAB_EP
add_library(MOAB INTERFACE)

target_include_directories(MOAB SYSTEM INTERFACE ${MOAB_INCLUDE_DIRS})
target_link_libraries(MOAB INTERFACE ${MOAB_LIBRARY_DIRS}/libMOAB.so)
add_dependencies(MOAB MOAB_ep)
install(TARGETS MOAB LIBRARY DESTINATION ${MOAB_LIBRARY_DIRS}
PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDE_DIR})
include_directories(${MOAB_INCLUDE_DIRS})
link_directories(${MOAB_LIBRARY_DIRS})
find_package(Eigen3 REQUIRED NO_MODULE)
include_directories(${EIGEN3_INCLUDE_DIRS})

ENDMACRO(moab_pull_make)
1 change: 1 addition & 0 deletions doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Next version
* Update github actions to newer versions as necessary (#958)
* CMake error message update (#960)
* Updated documentation to build dependencies (#963)
* Allow download from cmake and compilation at build time of MOAB (#969)

v3.2.3
====================
Expand Down
4 changes: 0 additions & 4 deletions src/dagmc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ include_directories(${CMAKE_BINARY_DIR}/src/dagmc)

dagmc_install_library(dagmc)

if(DDL_INSTALL_DEPS)
add_dependencies(dagmc-shared MOAB)
target_link_libraries(dagmc-shared PUBLIC ${MOAB_INSTALL_PREFIX}/lib64/libMOAB.so)
endif()
add_subdirectory(tools)

if (BUILD_TESTS)
Expand Down
5 changes: 5 additions & 0 deletions src/mcnp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ add_library(mcnp_funcs OBJECT mcnp_funcs.cpp)
message(STATUS "Building object library: meshtal_funcs")
add_library(meshtal_funcs OBJECT meshtal_funcs.cpp)

if(DDL_INSTALL_DEPS)
add_dependencies(mcnp_funcs MOAB)
add_dependencies(meshtal_funcs MOAB)
endif()

if (BUILD_MCNP5)
add_subdirectory(mcnp5)
endif ()
Expand Down
3 changes: 0 additions & 3 deletions src/pyne/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,3 @@ if(NOT (${HDF5_VERSION} VERSION_LESS 1.12.0))
endif()

dagmc_install_library(pyne_dagmc)
if(DDL_INSTALL_DEPS)
add_dependencies(pyne_dagmc-shared MOAB)
endif()

0 comments on commit 45feb89

Please sign in to comment.