From 861807fc7e96c8f382042a3b3d7086df79be4e41 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Tue, 3 Dec 2024 15:39:59 +0100 Subject: [PATCH 01/22] first attempt to auto-install MOAB change location cmake up cmake up cmake up CMAKE_MODULE_PATH CMAKE_MODULE_PATH CMAKE_MODULE_PATH adding LIBS adding LIBS install_dependent_library(MOAB ) install_dependent_library adding LIBS adding LIBS adding LIBS adding LIBS adding LIBS adding LIBS adding LIBS adding LIBS instal_prefix instal_prefix instal_prefix instal_prefix instal_prefix instal_prefix instal_prefix instal_prefix instal_prefix instal_prefix INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE INTERFACE tmp get the safeguard revert unnecessary change --- cmake/FindMOAB.cmake | 51 +++++++++++++++++++++++++++++++++++++--- src/dagmc/CMakeLists.txt | 4 ++++ src/pyne/CMakeLists.txt | 3 +++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 92602c8917..6a860e5e32 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -13,12 +13,57 @@ find_path(MOAB_CMAKE_CONFIG 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) + message(STATUS "MOAB will be downloaded and built") + include(ExternalProject) + # Configure MOAB + if(NOT MOAB_VERSION) + set(MOAB_VERSION "5.5.1") + endif() + 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= + -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}) + + include_directories(${MOAB_INCLUDE_DIRS}) + link_directories(${MOAB_LIBRARY_DIRS}) + include_directories(${EIGEN3_INCLUDE_DIRS}) else () message(FATAL_ERROR "Could not find MOAB. Set -DMOAB_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) @@ -74,8 +119,8 @@ message(STATUS "MOAB_LIBRARIES_STATIC: ${MOAB_LIBRARIES_STATIC}") if (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}) diff --git a/src/dagmc/CMakeLists.txt b/src/dagmc/CMakeLists.txt index 2fbc05161a..4bc24b2860 100644 --- a/src/dagmc/CMakeLists.txt +++ b/src/dagmc/CMakeLists.txt @@ -14,6 +14,10 @@ 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) diff --git a/src/pyne/CMakeLists.txt b/src/pyne/CMakeLists.txt index 910c4df542..9fa181a2c6 100644 --- a/src/pyne/CMakeLists.txt +++ b/src/pyne/CMakeLists.txt @@ -34,3 +34,6 @@ 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() From a5e83e3e23278f72d353d96447f2ff04e0f48d9b Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot <15145274+bam241@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:54:50 +0100 Subject: [PATCH 02/22] Update cmake/FindMOAB.cmake Co-authored-by: Jonathan Shimwell --- cmake/FindMOAB.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 6a860e5e32..8511cdd7df 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -15,11 +15,11 @@ if (MOAB_CMAKE_CONFIG) message(STATUS "MOAB_CMAKE_CONFIG: ${MOAB_CMAKE_CONFIG}") include(${MOAB_CMAKE_CONFIG}) elseif (DDL_INSTALL_DEPS) - message(STATUS "MOAB will be downloaded and built") include(ExternalProject) - # Configure MOAB + # Configure MOAB if(NOT MOAB_VERSION) set(MOAB_VERSION "5.5.1") + message(STATUS "MOAB version ${MOAB_VERSION} will be downloaded and built") endif() set(CMAKE_INSTALL_LIBDIR "lib") SET(MOAB_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/moab") From b28d95108a127b2661f3c39df055b1f84007b040 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot <15145274+bam241@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:02:56 +0100 Subject: [PATCH 03/22] Update cmake/FindMOAB.cmake Co-authored-by: Jonathan Shimwell --- cmake/FindMOAB.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 8511cdd7df..5cf215cc0b 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -19,8 +19,9 @@ elseif (DDL_INSTALL_DEPS) # Configure MOAB if(NOT MOAB_VERSION) set(MOAB_VERSION "5.5.1") - message(STATUS "MOAB version ${MOAB_VERSION} will be downloaded and built") 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") From 26e03af9494ce6baa7c29cce5fe1a2e108179b67 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 6 Dec 2024 12:32:14 +0100 Subject: [PATCH 04/22] reformating + changelog + tests --- .github/workflows/linux_build_test.yml | 12 +++++ CMakeLists.txt | 2 +- cmake/DAGMC_macros.cmake | 5 ++ cmake/FindMOAB.cmake | 71 ++++++++------------------ cmake/MOAB_PullAndMake.cmake | 44 ++++++++++++++++ doc/CHANGELOG.rst | 3 ++ src/dagmc/CMakeLists.txt | 4 -- src/mcnp/CMakeLists.txt | 5 ++ src/pyne/CMakeLists.txt | 3 -- 9 files changed, 90 insertions(+), 59 deletions(-) create mode 100644 cmake/MOAB_PullAndMake.cmake diff --git a/.github/workflows/linux_build_test.yml b/.github/workflows/linux_build_test.yml index 2aaf9ec298..98202fe83f 100644 --- a/.github/workflows/linux_build_test.yml +++ b/.github/workflows/linux_build_test.yml @@ -50,6 +50,9 @@ jobs: 5.4.1, 5.5.1, ] + ddl_deps : [ + off, + ] geant4_version : [ 10.7.4, 11.1.2 @@ -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-${{ @@ -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 \ diff --git a/CMakeLists.txt b/CMakeLists.txt index cd6c24fcfd..4b90a5eedb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ project(DAGMC) -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.1) enable_language(CXX) # Set DAGMC version diff --git a/cmake/DAGMC_macros.cmake b/cmake/DAGMC_macros.cmake index d5b2cd04e9..d8373d2c4b 100644 --- a/cmake/DAGMC_macros.cmake +++ b/cmake/DAGMC_macros.cmake @@ -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) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 5cf215cc0b..5497f650ce 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -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= - -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= 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) @@ -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}) diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake new file mode 100644 index 0000000000..e068c718bb --- /dev/null +++ b/cmake/MOAB_PullAndMake.cmake @@ -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= + -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) diff --git a/doc/CHANGELOG.rst b/doc/CHANGELOG.rst index 2480d32eff..0f288e580f 100644 --- a/doc/CHANGELOG.rst +++ b/doc/CHANGELOG.rst @@ -7,6 +7,9 @@ DAGMC Changelog Next version ==================== +**Added:** + * Allow download from cmake and compilation at build time of MOAB (#969) + v3.2.4 ==================== diff --git a/src/dagmc/CMakeLists.txt b/src/dagmc/CMakeLists.txt index 4bc24b2860..2fbc05161a 100644 --- a/src/dagmc/CMakeLists.txt +++ b/src/dagmc/CMakeLists.txt @@ -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) diff --git a/src/mcnp/CMakeLists.txt b/src/mcnp/CMakeLists.txt index c4fe947503..983534840c 100644 --- a/src/mcnp/CMakeLists.txt +++ b/src/mcnp/CMakeLists.txt @@ -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 () diff --git a/src/pyne/CMakeLists.txt b/src/pyne/CMakeLists.txt index 9fa181a2c6..910c4df542 100644 --- a/src/pyne/CMakeLists.txt +++ b/src/pyne/CMakeLists.txt @@ -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() From 0908fddfe65787f155a9c2b18cf75081e8be7010 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 6 Dec 2024 12:33:22 +0100 Subject: [PATCH 05/22] add missing indent --- src/mcnp/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mcnp/CMakeLists.txt b/src/mcnp/CMakeLists.txt index 983534840c..7b4dd5f493 100644 --- a/src/mcnp/CMakeLists.txt +++ b/src/mcnp/CMakeLists.txt @@ -19,8 +19,8 @@ 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) + add_dependencies(mcnp_funcs MOAB) + add_dependencies(meshtal_funcs MOAB) endif() if (BUILD_MCNP5) From 83ca15ea6135122d711242fd7df66807a34d4867 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 6 Dec 2024 13:55:17 +0100 Subject: [PATCH 06/22] generalyze shared lib extention --- cmake/DAGMC_macros.cmake | 2 +- cmake/FindMOAB.cmake | 2 +- cmake/MOAB_PullAndMake.cmake | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/DAGMC_macros.cmake b/cmake/DAGMC_macros.cmake index d8373d2c4b..71fe2a07d0 100644 --- a/cmake/DAGMC_macros.cmake +++ b/cmake/DAGMC_macros.cmake @@ -256,7 +256,7 @@ macro (dagmc_install_library lib_name) # 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) + target_link_libraries(${lib_name}-shared PUBLIC ${MOAB_LIBRARY_DIRS}/libMOAB${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() endif () diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 5497f650ce..483c84b95d 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -25,13 +25,13 @@ if (DDL_INSTALL_DEPS) # 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= 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) diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index e068c718bb..16c0594bf3 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -10,6 +10,7 @@ MACRO (moab_pull_make moab_version) set(MOAB_INCLUDE_DIRS "${MOAB_INSTALL_PREFIX}/include") set(MOAB_LIBRARY_DIRS "${MOAB_INSTALL_PREFIX}/lib") message("MOAB_LIBRARY_DIRS: ${MOAB_LIBRARY_DIRS}") + MEsSAGE("CMAKE_SHARED_LIBRARY_SUFFIX: ${CMAKE_SHARED_LIBRARY_SUFFIX}") set(MOAB_LIBRARIES_SHARED "") ExternalProject_Add(MOAB_ep PREFIX ${MOAB_ROOT} @@ -32,7 +33,7 @@ MACRO (moab_pull_make moab_version) add_library(MOAB INTERFACE) target_include_directories(MOAB SYSTEM INTERFACE ${MOAB_INCLUDE_DIRS}) - target_link_libraries(MOAB INTERFACE ${MOAB_LIBRARY_DIRS}/libMOAB.so) + target_link_libraries(MOAB INTERFACE ${MOAB_LIBRARY_DIRS}/libMOAB${CMAKE_SHARED_LIBRARY_SUFFIX}) add_dependencies(MOAB MOAB_ep) install(TARGETS MOAB LIBRARY DESTINATION ${MOAB_LIBRARY_DIRS} PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDE_DIR}) From c6df67ac855b181ac754a13337049279bc4ccff5 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 6 Dec 2024 14:20:19 +0100 Subject: [PATCH 07/22] temporary change to master --- cmake/FindMOAB.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 483c84b95d..428ac24624 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -17,7 +17,8 @@ if (DDL_INSTALL_DEPS) message(FATAL_ERROR "DDL_INSTALL_DEPS is ONLY compatible with shared libraries.") ENDIF() IF(NOT MOAB_VERSION) - SET(MOAB_VERSION "5.5.1") + # SET(MOAB_VERSION "5.5.1") + SET(MOAB_VERSION "master") ENDIF() include(MOAB_PullAndMake) moab_pull_make(${MOAB_VERSION}) From 853b3b9e7ead58bef4ffb394b006bb26951d901c Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 6 Dec 2024 14:41:55 +0100 Subject: [PATCH 08/22] back to 5.5.1 --- cmake/FindMOAB.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 428ac24624..483c84b95d 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -17,8 +17,7 @@ if (DDL_INSTALL_DEPS) message(FATAL_ERROR "DDL_INSTALL_DEPS is ONLY compatible with shared libraries.") ENDIF() IF(NOT MOAB_VERSION) - # SET(MOAB_VERSION "5.5.1") - SET(MOAB_VERSION "master") + SET(MOAB_VERSION "5.5.1") ENDIF() include(MOAB_PullAndMake) moab_pull_make(${MOAB_VERSION}) From 612893a6c72f1ccbfedca8981b4f024330e721ab Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Thu, 12 Dec 2024 11:56:27 +0100 Subject: [PATCH 09/22] adding DDL_INSTALL_DEPS as an option with default to OFF --- cmake/DAGMC_macros.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/DAGMC_macros.cmake b/cmake/DAGMC_macros.cmake index 71fe2a07d0..3f3a54947c 100644 --- a/cmake/DAGMC_macros.cmake +++ b/cmake/DAGMC_macros.cmake @@ -73,6 +73,8 @@ macro (dagmc_setup_options) option(DOUBLE_DOWN "Enable ray tracing with Embree via double down" OFF) + option(DDL_INSTALL_DEPS "Enable automatic downloading of MOAB dependency" OFF) + if (BUILD_ALL) set(BUILD_MCNP5 ON) set(BUILD_MCNP6 ON) From b012285a84551ea00633508e7bc63b0d9244a1d9 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Thu, 12 Dec 2024 11:58:14 +0100 Subject: [PATCH 10/22] keeping jon changes --- cmake/MOAB_PullAndMake.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index 16c0594bf3..0114f19335 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -5,12 +5,12 @@ 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_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}") - MEsSAGE("CMAKE_SHARED_LIBRARY_SUFFIX: ${CMAKE_SHARED_LIBRARY_SUFFIX}") + message("CMAKE_SHARED_LIBRARY_SUFFIX: ${CMAKE_SHARED_LIBRARY_SUFFIX}") set(MOAB_LIBRARIES_SHARED "") ExternalProject_Add(MOAB_ep PREFIX ${MOAB_ROOT} From bbe4828d1d4b6cd218ae5ad13490676d81501cb4 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Thu, 12 Dec 2024 11:59:51 +0100 Subject: [PATCH 11/22] trying MOAB master --- cmake/FindMOAB.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 483c84b95d..1a6c204f2d 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -16,9 +16,9 @@ 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() + # IF(NOT MOAB_VERSION) + SET(MOAB_VERSION "master") + # ENDIF() include(MOAB_PullAndMake) moab_pull_make(${MOAB_VERSION}) From ef5a2e05414ea09f6c0ed1a987752261f527b74b Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Thu, 12 Dec 2024 12:10:05 +0100 Subject: [PATCH 12/22] reverting to 5.5.1 as default version for MOAB --- cmake/FindMOAB.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 1a6c204f2d..233bf8f549 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -13,12 +13,12 @@ find_path(MOAB_CMAKE_CONFIG # First check if we are forcing the download of MOAB if (DDL_INSTALL_DEPS) - IF(DAGMC_BUILD_STATIC_LIBS) + 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 "master") - # ENDIF() + endif() + if(NOT MOAB_VERSION) + set(MOAB_VERSION "5.5.1") + endif() include(MOAB_PullAndMake) moab_pull_make(${MOAB_VERSION}) From 6675cef74ea44f14ab2970f1278f1ee207d67b15 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Thu, 12 Dec 2024 21:56:08 +0100 Subject: [PATCH 13/22] cleaning variable name --- .github/workflows/linux_build_test.yml | 6 +++--- cmake/DAGMC_macros.cmake | 4 ++-- cmake/FindMOAB.cmake | 6 +++--- src/mcnp/CMakeLists.txt | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linux_build_test.yml b/.github/workflows/linux_build_test.yml index 98202fe83f..ca90b76ff9 100644 --- a/.github/workflows/linux_build_test.yml +++ b/.github/workflows/linux_build_test.yml @@ -50,7 +50,7 @@ jobs: 5.4.1, 5.5.1, ] - ddl_deps : [ + pull_install_moab : [ off, ] geant4_version : [ @@ -66,7 +66,7 @@ jobs: compiler: gcc hdf5_version: 1.14.3 moab_version: 5.4.1 - ddl_deps: on + pull_install_moab: on geant4_version: off double_down_version: off @@ -99,7 +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}") \ + -DPULL_INSTALL_MOAB=$([ "${{ matrix.pull_install_moab }}" != "on" ] && echo "OFF" || echo "ON -DHDF5_ROOT=${hdf5_install_dir}") \ -DGEANT4_DIR=${geant4_install_dir} \ -DBUILD_CI_TESTS=ON \ -DBUILD_MW_REG_TESTS=OFF \ diff --git a/cmake/DAGMC_macros.cmake b/cmake/DAGMC_macros.cmake index 3f3a54947c..bd34eb1e45 100644 --- a/cmake/DAGMC_macros.cmake +++ b/cmake/DAGMC_macros.cmake @@ -73,7 +73,7 @@ macro (dagmc_setup_options) option(DOUBLE_DOWN "Enable ray tracing with Embree via double down" OFF) - option(DDL_INSTALL_DEPS "Enable automatic downloading of MOAB dependency" OFF) + option(PULL_INSTALL_MOAB "Enable automatic downloading of MOAB dependency" OFF) if (BUILD_ALL) set(BUILD_MCNP5 ON) @@ -256,7 +256,7 @@ macro (dagmc_install_library lib_name) 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) + if(PULL_INSTALL_MOAB) add_dependencies(${lib_name}-shared MOAB) target_link_libraries(${lib_name}-shared PUBLIC ${MOAB_LIBRARY_DIRS}/libMOAB${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index 233bf8f549..d5fcddc720 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -12,9 +12,9 @@ find_path(MOAB_CMAKE_CONFIG ) # First check if we are forcing the download of MOAB -if (DDL_INSTALL_DEPS) +if (PULL_INSTALL_MOAB) if(DAGMC_BUILD_STATIC_LIBS) - message(FATAL_ERROR "DDL_INSTALL_DEPS is ONLY compatible with shared libraries.") + message(FATAL_ERROR "PULL_INSTALL_MOAB is ONLY compatible with shared libraries.") endif() if(NOT MOAB_VERSION) set(MOAB_VERSION "5.5.1") @@ -84,7 +84,7 @@ 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(DDL_INSTALL_DEPS) +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)) diff --git a/src/mcnp/CMakeLists.txt b/src/mcnp/CMakeLists.txt index 7b4dd5f493..118d1e958c 100644 --- a/src/mcnp/CMakeLists.txt +++ b/src/mcnp/CMakeLists.txt @@ -18,7 +18,7 @@ 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) +if(PULL_INSTALL_MOAB) add_dependencies(mcnp_funcs MOAB) add_dependencies(meshtal_funcs MOAB) endif() From 19da17b0679dc0b58381e9d53ae62d305de4c2be Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 10 Jan 2025 13:02:12 +0100 Subject: [PATCH 14/22] moving this up one level --- CMakeLists.txt | 11 ++- cmake/FindMOAB.cmake | 43 ++--------- cmake/HDF5_macro.cmake | 25 +++++++ cmake/MOAB_PullAndMake.cmake | 136 ++++++++++++++++++++++++----------- 4 files changed, 134 insertions(+), 81 deletions(-) create mode 100644 cmake/HDF5_macro.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b90a5eedb..c16fc6ff48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ project(DAGMC) -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.18) enable_language(CXX) # Set DAGMC version @@ -44,7 +44,14 @@ if(BUILD_MCNP5 OR BUILD_MCNP6) enable_language(Fortran) endif() -find_package(MOAB REQUIRED) +# Dealing with MOAB +if (PULL_INSTALL_MOAB) + include(MOAB_PullAndMake) + moab_pull_make(${MOAB_VERSION} +else() + find_package(MOAB REQUIRED) +endif() + find_package(OpenMP) dagmc_setup_flags() diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index d5fcddc720..db19e53e4f 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -10,49 +10,18 @@ find_path(MOAB_CMAKE_CONFIG PATHS ${MOAB_SEARCH_DIRS} NO_DEFAULT_PATH ) - -# 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) +if (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= when running cmake or use the $MOAB_DIR environment variable.") endif () # Find 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(${MOAB_CMAKE_CONFIG}) +include(HDF5_macro) +find_set_HDF5() -include_directories(${HDF5_INCLUDE_DIRS}) if(MSVC) set(BUILD_STATIC_LIBS TRUE) set(BUILD_SHARED_LIBS OFF) @@ -84,9 +53,7 @@ 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(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 +if (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 () diff --git a/cmake/HDF5_macro.cmake b/cmake/HDF5_macro.cmake new file mode 100644 index 0000000000..9f6f0849fa --- /dev/null +++ b/cmake/HDF5_macro.cmake @@ -0,0 +1,25 @@ +MACRO (find_set_HDF5) + # Find 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}) + +ENDMACRO (find_set_HDF5) diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index 0114f19335..57ca0d0b1c 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -1,45 +1,99 @@ -# 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 +# This Macro sets up the download and build of MOAB using ExternalProject +# few tweak are done in src/dagmc/CMakeLists.txt and src/PyNE/CMakeists.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}") - message("CMAKE_SHARED_LIBRARY_SUFFIX: ${CMAKE_SHARED_LIBRARY_SUFFIX}") - 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= - -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${CMAKE_SHARED_LIBRARY_SUFFIX}) - 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}) + MESSAGE(STATUS "MOAB will be downloaded and built") + + # Ensure STATIC LIBS Build + IF(DAGMC_BUILD_STATIC_LIBS) + MESSAGE(FATAL_ERROR "PULL_INSTALL_MOAB is ONLY compatible with shared libraries.") + endIF() + + # Ensure MOAB_VERSION + IF(NOT MOAB_VERSION) + SET(MOAB_VERSION "5.5.1") + endIF() + + # Ensure we have the right variables to build MOAB + moab_autobuild_check_deps() + + + 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}") + MESSAGE("CMAKE_SHARED_LIBRARY_SUFFIX: ${CMAKE_SHARED_LIBRARY_SUFFIX}") + 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= + -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 + ${OPTION_FLAG} + 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${CMAKE_SHARED_LIBRARY_SUFFIX}) + 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}) + + # Find HDF5 + INCLUDE(HDF5_macro) + find_SET_HDF5() + + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) + FIND_LIBRARY(MOAB_LIBRARIES_SHARED + NAMES MOAB + HINTS ${MOAB_LIBRARY_DIRS} + NO_DEFAULT_PATH + ) + LIST(APPEND MOAB_LIBRARIES_SHARED) + MESSAGE(STATUS "MOAB_INCLUDE_DIRS: ${MOAB_INCLUDE_DIRS}") + MESSAGE(STATUS "MOAB_LIBRARY_DIRS: ${MOAB_LIBRARY_DIRS}") + 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) + + +MACRO (moab_autobuild_check_deps) +# First check IF we are forcing the download of MOAB +IF (PULL_INSTALL_MOAB) + IF (NOT DEFINED HDF5_ROOT or not DEFINED ${HDF5_ROOT}) + MESSAGE(FATAL_ERROR "HDF5_ROOT is required to build MOAB") + ENDIF() + + IF (DEFINED ${EIGEN3_DIR}) + OPTION_FLAG = "-DEIGEN3_DIR=${EIGEN3_DIR}" + ENDIF() + +ENDIF () + +ENDMACRO (moab_autobuild_check_deps) \ No newline at end of file From bf4ecff0a66260df1083fcb504eb3cdea8cb0737 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 10 Jan 2025 13:04:59 +0100 Subject: [PATCH 15/22] missing a ) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c16fc6ff48..3b0de00659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ endif() # Dealing with MOAB if (PULL_INSTALL_MOAB) include(MOAB_PullAndMake) - moab_pull_make(${MOAB_VERSION} + moab_pull_make(${MOAB_VERSION}) else() find_package(MOAB REQUIRED) endif() From ef2c3e58cf456ea802aaf9c9f679f45891f07230 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 10 Jan 2025 13:10:34 +0100 Subject: [PATCH 16/22] cmake likes set to define variables --- cmake/MOAB_PullAndMake.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index 57ca0d0b1c..4809bd0df3 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -91,7 +91,7 @@ IF (PULL_INSTALL_MOAB) ENDIF() IF (DEFINED ${EIGEN3_DIR}) - OPTION_FLAG = "-DEIGEN3_DIR=${EIGEN3_DIR}" + SET(OPTION_FLAG "-DEIGEN3_DIR=${EIGEN3_DIR}") ENDIF() ENDIF () From e7a03fd5b3a961215afd2da86fc3ce92a16cacaf Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 10 Jan 2025 13:13:23 +0100 Subject: [PATCH 17/22] no need for MOAB_VERSION --- CMakeLists.txt | 2 +- cmake/MOAB_PullAndMake.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b0de00659..5b95acbd9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ endif() # Dealing with MOAB if (PULL_INSTALL_MOAB) include(MOAB_PullAndMake) - moab_pull_make(${MOAB_VERSION}) + moab_pull_make() else() find_package(MOAB REQUIRED) endif() diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index 4809bd0df3..be5afc9ad0 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -1,7 +1,7 @@ # This Macro sets up the download and build of MOAB using ExternalProject # few tweak are done in src/dagmc/CMakeLists.txt and src/PyNE/CMakeists.txt # to make sure that MOAB is built before DAGMC. -MACRO (moab_pull_make moab_version) +MACRO (moab_pull_make) MESSAGE(STATUS "MOAB will be downloaded and built") # Ensure STATIC LIBS Build From 5907867560942c89e1b3ea2ebd62cccf0b5f8181 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 10 Jan 2025 13:17:27 +0100 Subject: [PATCH 18/22] how about now ? --- cmake/MOAB_PullAndMake.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index be5afc9ad0..e83f607491 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -86,7 +86,7 @@ ENDMACRO(moab_pull_make) MACRO (moab_autobuild_check_deps) # First check IF we are forcing the download of MOAB IF (PULL_INSTALL_MOAB) - IF (NOT DEFINED HDF5_ROOT or not DEFINED ${HDF5_ROOT}) + IF (NOT DEFINED HDF5_ROOT) MESSAGE(FATAL_ERROR "HDF5_ROOT is required to build MOAB") ENDIF() From 8a8597d298e6661fac6f1a8885f538d61b0e5596 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 10 Jan 2025 13:20:01 +0100 Subject: [PATCH 19/22] how about now ? --- cmake/FindMOAB.cmake | 43 +++++++++++++++++++++++++++++++----- cmake/MOAB_PullAndMake.cmake | 5 ----- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index db19e53e4f..d5fcddc720 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -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= 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) @@ -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 () diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index e83f607491..7f053b79b3 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -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) From 9d4ccc044afe3681248b20f8eff2a48ec5d5c3c3 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 10 Jan 2025 13:33:08 +0100 Subject: [PATCH 20/22] no caps for include folder --- cmake/MOAB_PullAndMake.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index 7f053b79b3..62b4244a7c 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -22,7 +22,7 @@ MACRO (moab_pull_make) 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_INCLUDE_DIRS "${MOAB_INSTALL_PREFIX}/include") SET(MOAB_LIBRARY_DIRS "${MOAB_INSTALL_PREFIX}/lib") MESSAGE("MOAB_LIBRARY_DIRS: ${MOAB_LIBRARY_DIRS}") MESSAGE("CMAKE_SHARED_LIBRARY_SUFFIX: ${CMAKE_SHARED_LIBRARY_SUFFIX}") From 445aab9e841fa74091c92bef4215033b366d20ed Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Fri, 10 Jan 2025 14:11:35 +0100 Subject: [PATCH 21/22] revamping find_MOAB --- cmake/FindMOAB.cmake | 43 +++++------------------------------- cmake/MOAB_PullAndMake.cmake | 7 +++--- 2 files changed, 8 insertions(+), 42 deletions(-) diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index d5fcddc720..db19e53e4f 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -10,49 +10,18 @@ find_path(MOAB_CMAKE_CONFIG PATHS ${MOAB_SEARCH_DIRS} NO_DEFAULT_PATH ) - -# 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) +if (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= when running cmake or use the $MOAB_DIR environment variable.") endif () # Find 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(${MOAB_CMAKE_CONFIG}) +include(HDF5_macro) +find_set_HDF5() -include_directories(${HDF5_INCLUDE_DIRS}) if(MSVC) set(BUILD_STATIC_LIBS TRUE) set(BUILD_SHARED_LIBS OFF) @@ -84,9 +53,7 @@ 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(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 +if (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 () diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index 62b4244a7c..fa1c2c76fd 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -55,8 +55,9 @@ MACRO (moab_pull_make) 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}) + + # FIND_PACKAGE(Eigen3 REQUIRED NO_MODULE) + # INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIRS}) # Find HDF5 INCLUDE(HDF5_macro) @@ -73,8 +74,6 @@ MACRO (moab_pull_make) MESSAGE(STATUS "MOAB_LIBRARY_DIRS: ${MOAB_LIBRARY_DIRS}") MESSAGE(STATUS "MOAB_LIBRARIES_SHARED: ${MOAB_LIBRARIES_SHARED}") - INCLUDE_DIRECTORIES(${MOAB_INCLUDE_DIRS}) - ENDMACRO(moab_pull_make) From b1232becf378ff6ab0bce4188cebc3f44c291f02 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Mon, 13 Jan 2025 08:36:36 +0100 Subject: [PATCH 22/22] adressing @gonuke comments --- CMakeLists.txt | 6 +++++- cmake/FindMOAB.cmake | 2 ++ cmake/MOAB_PullAndMake.cmake | 9 ++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b95acbd9c..f4fe4c4f31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,8 +46,12 @@ endif() # Dealing with MOAB if (PULL_INSTALL_MOAB) + # Ensure MOAB_VERSION + if(NOT DEFINED MOAB_VERSION) + set(MOAB_VERSION "5.5.1") + endif() include(MOAB_PullAndMake) - moab_pull_make() + moab_pull_make(${MOAB_VERSION}) else() find_package(MOAB REQUIRED) endif() diff --git a/cmake/FindMOAB.cmake b/cmake/FindMOAB.cmake index db19e53e4f..04a968f443 100644 --- a/cmake/FindMOAB.cmake +++ b/cmake/FindMOAB.cmake @@ -1,3 +1,5 @@ +# This leverage HDF5_macro.cmake in order to find HDF5 libraries. + message("") # Find MOAB cmake config file diff --git a/cmake/MOAB_PullAndMake.cmake b/cmake/MOAB_PullAndMake.cmake index fa1c2c76fd..c6825a2e4c 100644 --- a/cmake/MOAB_PullAndMake.cmake +++ b/cmake/MOAB_PullAndMake.cmake @@ -1,19 +1,14 @@ # This Macro sets up the download and build of MOAB using ExternalProject # few tweak are done in src/dagmc/CMakeLists.txt and src/PyNE/CMakeists.txt # to make sure that MOAB is built before DAGMC. -MACRO (moab_pull_make) +MACRO (moab_pull_make MOAB_Version) MESSAGE(STATUS "MOAB will be downloaded and built") # Ensure STATIC LIBS Build IF(DAGMC_BUILD_STATIC_LIBS) MESSAGE(FATAL_ERROR "PULL_INSTALL_MOAB is ONLY compatible with shared libraries.") endIF() - - # Ensure MOAB_VERSION - IF(NOT MOAB_VERSION) - SET(MOAB_VERSION "5.5.1") - endIF() - + # Ensure we have the right variables to build MOAB moab_autobuild_check_deps()