Skip to content

Commit

Permalink
how about now ?
Browse files Browse the repository at this point in the history
  • Loading branch information
bam241 committed Jan 10, 2025
1 parent 5907867 commit 8a8597d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
43 changes: 38 additions & 5 deletions cmake/FindMOAB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,49 @@ find_path(MOAB_CMAKE_CONFIG
PATHS ${MOAB_SEARCH_DIRS}
NO_DEFAULT_PATH
)
if (MOAB_CMAKE_CONFIG)

# First check if we are forcing the download of MOAB
if (PULL_INSTALL_MOAB)
if(DAGMC_BUILD_STATIC_LIBS)
message(FATAL_ERROR "PULL_INSTALL_MOAB 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})

# Back to normal behavior
elseif (MOAB_CMAKE_CONFIG)
set(MOAB_CMAKE_CONFIG ${MOAB_CMAKE_CONFIG}/MOABConfig.cmake)
include(${MOAB_CMAKE_CONFIG})
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})
include(HDF5_macro)
find_set_HDF5()
set(ENV{PATH} "${HDF5_DIR}:$ENV{PATH}")
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
find_package(HDF5 REQUIRED)
# Remove HDF5 transitive dependencies that are system libraries
list(FILTER HDF5_LIBRARIES EXCLUDE REGEX ".*lib(pthread|dl|m).*")
set(HDF5_LIBRARIES_SHARED ${HDF5_LIBRARIES})
# CMake doesn't let you find_package(HDF5) twice so we have to do this instead
if (BUILD_STATIC_LIBS)
string(REPLACE ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_SUFFIX}
HDF5_LIBRARIES_STATIC "${HDF5_LIBRARIES_SHARED}")
endif ()
if (NOT BUILD_SHARED_LIBS)
set(HDF5_LIBRARIES_SHARED)
endif ()
set(HDF5_LIBRARIES)

message(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}")
message(STATUS "HDF5_LIBRARIES_SHARED: ${HDF5_LIBRARIES_SHARED}")
message(STATUS "HDF5_LIBRARIES_STATIC: ${HDF5_LIBRARIES_STATIC}")

include_directories(${HDF5_INCLUDE_DIRS})
if(MSVC)
set(BUILD_STATIC_LIBS TRUE)
set(BUILD_SHARED_LIBS OFF)
Expand Down Expand Up @@ -53,7 +84,9 @@ 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(PULL_INSTALL_MOAB)
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 ()
Expand Down
5 changes: 0 additions & 5 deletions cmake/MOAB_PullAndMake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ MACRO (moab_pull_make)
MESSAGE(STATUS "MOAB_LIBRARIES_SHARED: ${MOAB_LIBRARIES_SHARED}")

INCLUDE_DIRECTORIES(${MOAB_INCLUDE_DIRS})
IF (MOAB_INCLUDE_DIRS AND (MOAB_LIBRARIES_SHARED))
MESSAGE(STATUS "MOAB Will be installed.")
ELSE ()
MESSAGE(FATAL_ERROR "Could not set MOAB for installation and compilation.")
ENDIF ()

ENDMACRO(moab_pull_make)

Expand Down

0 comments on commit 8a8597d

Please sign in to comment.