diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b4dc6b7cc..fd407984b 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -17,6 +17,7 @@ jobs: mempool: [on, off] cxx_standard: [17] python: [off] + installation_test: [off] exclude: - kokkos: off mempool: on @@ -34,6 +35,12 @@ jobs: mpi: on cxx_standard: 20 python: on + #run one config as installation test + - compiler: g++ + mpi: on + kokkos: on + mempool: on + installation_test: on env: CXX: ${{matrix.compiler}} MPICH_CXX: ${{matrix.compiler}} @@ -106,7 +113,7 @@ jobs: -Bbuild -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_INSTALL_PREFIX=build/install - -DBUILD_SHARED_LIBS=${{ matrix.python }} + -DBUILD_SHARED_LIBS=${{ matrix.installation_test == 'on' || matrix.python }} - name: Build Kokkos if: ${{ matrix.kokkos == 'on' }} @@ -129,57 +136,220 @@ jobs: -DCMAKE_INSTALL_PREFIX=build/install -DADIOS2_USE_CUDA=OFF -DADIOS2_USE_ZFP=OFF - -DBUILD_SHARED_LIBS=${{ matrix.python }} + -DBUILD_SHARED_LIBS=${{ matrix.installation_test == 'on' || matrix.python }} - name: Build ADIOS2 if: ${{ matrix.mpi == 'on' }} shell: bash run: cmake --build $GITHUB_WORKSPACE/ADIOS2/build --target install + - name: cache hdf5 + id: cache-hdf5 + if: ${{ matrix.installation_test == 'on' }} + uses: actions/cache@v3 + with: + path: ${{runner.temp}}/hdf5 + key: build-hdf5-${{ matrix.compiler }} + + - name: clone hdf5 + if: ${{ matrix.installation_test == 'on' && steps.cache-hdf5.outputs.cache-hit != 'true' }} + working-directory: ${{runner.temp}} + run: git clone https://github.com/HDFGroup/hdf5.git hdf5 + + - name: build and install hdf5 + if: ${{ matrix.installation_test == 'on' && steps.cache-hdf5.outputs.cache-hit != 'true' }} + working-directory: ${{runner.temp}}/hdf5 + run: | + mkdir build + cd build + cmake .. \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_INSTALL_PREFIX=install \ + -DBUILD_SHARED_LIBS=ON \ + -DHDF5_BUILD_HL_LIB=ON \ + -DHDF5_ENABLE_PARALLEL=ON \ + -DHDF5_ENABLE_ZLIB_SUPPORT=ON + cmake --build . -j 4 --target install + + - name: cache netcdf + id: cache-netcdf + if: ${{ matrix.installation_test == 'on' }} + uses: actions/cache@v3 + with: + path: ${{runner.temp}}/netcdf-c + key: build-netcdf-${{ matrix.compiler }} + + - name: clone netcdf + if: ${{ matrix.installation_test == 'on' && steps.cache-netcdf.outputs.cache-hit != 'true' }} + working-directory: ${{runner.temp}} + run: git clone https://github.com/Unidata/netcdf-c.git netcdf-c + + - name: build and install netcdf + if: ${{ matrix.installation_test == 'on' && steps.cache-netcdf.outputs.cache-hit != 'true' }} + working-directory: ${{runner.temp}}/netcdf-c + run: | + mkdir build + cd build + cmake .. \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_INSTALL_PREFIX=install \ + -DBUILD_SHARED_LIBS=ON \ + -DHDF5_ROOT=${{runner.temp}}/hdf5/build/install \ + -DNETCDF_ENABLE_HDF5=ON \ + -DNETCDF_ENABLE_DAP=OFF \ + -DNETCDF_ENABLE_LOGGING=ON \ + -DNETCDF_ENABLE_LIBXML2=OFF + cmake --build . -j 4 --target install + + - name: cache seacas + id: cache-seacas + if: ${{ matrix.installation_test == 'on' }} + uses: actions/cache@v3 + with: + path: ${{runner.temp}}/seacas + key: build-seacas-${{ matrix.compiler }} + + - name: clone seacas + if: ${{ matrix.installation_test == 'on' && steps.cache-seacas.outputs.cache-hit != 'true' }} + working-directory: ${{runner.temp}} + run: git clone --depth 1 https://github.com/sandialabs/seacas.git seacas + + - name: build and install seacas + if: ${{ matrix.installation_test == 'on' && steps.cache-seacas.outputs.cache-hit != 'true' }} + working-directory: ${{runner.temp}}/seacas + run: | + mkdir build + cd build + cmake .. \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_INSTALL_PREFIX=install \ + -DBUILD_SHARED_LIBS=ON \ + -DSeacas_ENABLE_SEACASExodus=ON \ + -DSeacas_ENABLE_Fortran=OFF \ + -DSeacas_ENABLE_TESTS=OFF \ + -DTPL_ENABLE_Netcdf=ON \ + -DTPL_ENABLE_MPI=ON \ + -DTPL_ENABLE_Pthread=OFF \ + -DNetCDF_ROOT=${{runner.temp}}/netcdf-c/build/install \ + -DHDF5_ROOT=${{runner.temp}}/hdf5/build/install \ + -DHDF5_NO_SYSTEM_PATHS=YES + cmake --build . -j 4 --target install + + - name: cache libMeshb + id: cache-libmeshb + if: ${{ matrix.installation_test == 'on' }} + uses: actions/cache@v3 + with: + path: ${{runner.temp}}/libmeshb + key: build-libmeshb-${{ matrix.compiler }} + + - name: clone libMeshb + if: ${{ matrix.installation_test == 'on' && steps.cache-libmeshb.outputs.cache-hit != 'true' }} + working-directory: ${{runner.temp}} + run: git clone --branch v7.80 --depth 1 https://github.com/LoicMarechal/libMeshb.git libmeshb + + - name: build and install libMeshb + if: ${{ matrix.installation_test == 'on' && steps.cache-libmeshb.outputs.cache-hit != 'true' }} + working-directory: ${{runner.temp}}/libmeshb + run: | + mkdir build + cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX=install \ + -DBUILD_SHARED_LIBS=ON + cmake --build . -j 4 --target install + - name: Configure CMake shell: bash working-directory: ${{github.workspace}}/omega_h run: | export CMAKE_PREFIX_PATH="${{runner.temp }}/gmsh/install:$CMAKE_PREFIX_PATH" - export LD_LIBRARY_PATH="${{runner.temp }}/gmsh/install/lib:$LD_LIBRARY_PATH" export CMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/ADIOS2/build/install:$CMAKE_PREFIX_PATH" if [ "${{ matrix.python }}" == "on" ]; then export CMAKE_PREFIX_PATH="$(python -m pybind11 --cmakedir):$CMAKE_PREFIX_PATH" fi - cmake . -Bbuild \ - -DCMAKE_CXX_COMPILER=$CXX \ - -DCMAKE_CXX_STANDARD=${{ matrix.cxx_standard }} \ - -DCMAKE_VERBOSE_MAKEFILE=on \ - -DOmega_h_USE_MPI=${{ matrix.mpi }} \ - -DOmega_h_USE_Kokkos=${{ matrix.kokkos }} \ - -DKokkos_PREFIX=$GITHUB_WORKSPACE/kokkos/build/install \ - -DOmega_h_USE_pybind11=${{ matrix.python }} \ - -DOmega_h_USE_Gmsh=ON \ - -DGmsh_INCLUDE_DIRS=${{runner.temp }}/gmsh/install/include \ - -DGmsh_LIBRARIES=${{runner.temp }}/gmsh/install/lib/libgmsh.so.4.14.1 \ - -DOmega_h_USE_ADIOS2=${{ matrix.mpi }} \ - -DBUILD_TESTING=ON \ - -DBUILD_SHARED_LIBS=${{ matrix.python }} \ - -DENABLE_CTEST_MEMPOOL=${{ matrix.mempool }} + if [ "${{ matrix.installation_test }}" == "on" ]; then + cmake . -Bbuild \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DCMAKE_CXX_STANDARD=${{ matrix.cxx_standard }} \ + -DCMAKE_VERBOSE_MAKEFILE=on \ + -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/omega_h/build/install \ + -DOmega_h_USE_MPI=ON \ + -DOmega_h_USE_Kokkos=ON \ + -DKokkos_PREFIX=$GITHUB_WORKSPACE/kokkos/build/install \ + -DOmega_h_USE_Gmsh=ON \ + -DGmsh_INCLUDE_DIRS=${{runner.temp }}/gmsh/install/include \ + -DGmsh_LIBRARIES=${{runner.temp }}/gmsh/install/lib/libgmsh.so.4.14.1 \ + -DOmega_h_USE_ADIOS2=ON \ + -DOmega_h_USE_libMeshb=ON \ + -DlibMeshb_PREFIX=${{runner.temp}}/libmeshb/build/install \ + -DOmega_h_USE_SEACASExodus=ON \ + -DSEACASExodus_PREFIX=${{runner.temp}}/seacas/build/install \ + -DBUILD_TESTING=OFF \ + -DBUILD_SHARED_LIBS=ON + else + cmake . -Bbuild \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DCMAKE_CXX_STANDARD=${{ matrix.cxx_standard }} \ + -DCMAKE_VERBOSE_MAKEFILE=on \ + -DOmega_h_USE_MPI=${{ matrix.mpi }} \ + -DOmega_h_USE_Kokkos=${{ matrix.kokkos }} \ + -DKokkos_PREFIX=$GITHUB_WORKSPACE/kokkos/build/install \ + -DOmega_h_USE_pybind11=${{ matrix.python }} \ + -DOmega_h_USE_Gmsh=ON \ + -DGmsh_INCLUDE_DIRS=${{runner.temp }}/gmsh/install/include \ + -DGmsh_LIBRARIES=${{runner.temp }}/gmsh/install/lib/libgmsh.so.4.14.1 \ + -DOmega_h_USE_ADIOS2=${{ matrix.mpi }} \ + -DBUILD_TESTING=ON \ + -DBUILD_SHARED_LIBS=${{ matrix.python }} \ + -DENABLE_CTEST_MEMPOOL=${{ matrix.mempool }} + fi - name: Build + if: ${{ matrix.installation_test != 'on' }} working-directory: ${{github.workspace}}/omega_h/build shell: bash run: cmake --build . -j2 - name: Test + if: ${{ matrix.installation_test != 'on' }} working-directory: ${{github.workspace}}/omega_h/build shell: bash - run: ctest + run: | + export LD_LIBRARY_PATH="${{runner.temp}}/gmsh/install/lib:$GITHUB_WORKSPACE/kokkos/build/install/lib:$GITHUB_WORKSPACE/ADIOS2/build/install/lib:$LD_LIBRARY_PATH" + ctest - name: Test Python if: ${{ matrix.python == 'on' }} working-directory: ${{github.workspace}}/omega_h/build shell: bash run: | + export LD_LIBRARY_PATH="${{runner.temp}}/gmsh/install/lib:$GITHUB_WORKSPACE/kokkos/build/install/lib:$GITHUB_WORKSPACE/ADIOS2/build/install/lib:$LD_LIBRARY_PATH" export PYTHONPATH=${{github.workspace}}/omega_h/build/src:$PYTHONPATH pytest ${{github.workspace}}/omega_h/pytest + - name: Install + if: ${{ matrix.installation_test == 'on' }} + working-directory: ${{github.workspace}}/omega_h/build + shell: bash + run: cmake --build . -j2 --target install + + - name: Test Installation + if: ${{ matrix.installation_test == 'on' }} + working-directory: ${{github.workspace}}/omega_h/example/external_installation + shell: bash + run: | + export CMAKE_PREFIX_PATH="${{runner.temp}}/gmsh/install:$GITHUB_WORKSPACE/ADIOS2/build/install:$CMAKE_PREFIX_PATH" + export LD_LIBRARY_PATH="${{github.workspace}}/omega_h/build/install/lib:${{runner.temp}}/gmsh/install/lib:$GITHUB_WORKSPACE/kokkos/build/install/lib:$GITHUB_WORKSPACE/ADIOS2/build/install/lib:${{runner.temp}}/hdf5/build/install/lib:${{runner.temp}}/netcdf-c/build/install/lib:${{runner.temp}}/seacas/build/install/lib:${{runner.temp}}/libmeshb/build/install/lib:$LD_LIBRARY_PATH" + mkdir build + cd build + cmake .. -DOmega_h_DIR=${{github.workspace}}/omega_h/build/install/lib/cmake/Omega_h + cmake --build . + ctest --output-on-failure + - name: Print - if: always() + if: ${{ matrix.installation_test != 'on' && always() }} run: cat ${{github.workspace}}/omega_h/build/Testing/Temporary/LastTest.log diff --git a/CMakeLists.txt b/CMakeLists.txt index abee88cad..f6d46b259 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,9 +46,14 @@ if (Omega_h_ENABLE_DEMANGLED_STACKTRACE) endif() if (Omega_h_USE_MPI) - enable_language(C) - set(MPI_REQUIRED_VERSION 3) - bob_add_dependency(PUBLIC NAME MPI COMPONENTS CXX TARGETS MPI::MPI_CXX) + if (Omega_h_USE_ADIOS2) + enable_language(C) + set(MPI_REQUIRED_VERSION 3) + bob_add_dependency(PUBLIC NAME MPI COMPONENTS C CXX TARGETS MPI::MPI_CXX) + else() + set(MPI_REQUIRED_VERSION 3) + bob_add_dependency(PUBLIC NAME MPI COMPONENTS CXX TARGETS MPI::MPI_CXX) + endif() endif() set(Omega_h_USE_ZLIB_DEFAULT ON) @@ -87,6 +92,10 @@ bob_add_dependency(PUBLIC NAME SEACASExodus TARGETS SEACASExodus::all_libs) set(Omega_h_USE_pybind11_DEFAULT OFF) bob_public_dep(pybind11) +set(Omega_h_USE_ADIOS2_DEFAULT OFF) +set(ADIOS2_PREFIX_DEFAULT ${ADIOS2_DIR}) +bob_add_dependency(PUBLIC NAME ADIOS2 TARGETS adios2::adios2) + if(Omega_h_USE_Kokkos) bob_option(Omega_h_USE_Kokkos_Sort "Use Kokkos sort_by_key instead of vendor (Thrust, SYCL, etc.) provided sorting APIs." ON) if(Omega_h_USE_Kokkos_Sort AND Kokkos_VERSION VERSION_LESS 4.3) diff --git a/cmake/FindGmsh.cmake b/cmake/FindGmsh.cmake index 68d5c77d0..72821171f 100644 --- a/cmake/FindGmsh.cmake +++ b/cmake/FindGmsh.cmake @@ -48,8 +48,23 @@ if(Gmsh_EXECUTABLE) endif() endif() -find_path(Gmsh_INCLUDE_DIRS NAMES gmsh.h) -find_library(Gmsh_LIBRARIES NAMES gmsh) +# Get hints from executable location +if(Gmsh_EXECUTABLE) + get_filename_component(Gmsh_BINARY_DIR "${Gmsh_EXECUTABLE}" DIRECTORY) + get_filename_component(Gmsh_PREFIX_HINT "${Gmsh_BINARY_DIR}" DIRECTORY) +endif() + +find_path(Gmsh_INCLUDE_DIRS + NAMES gmsh.h + HINTS ${Gmsh_PREFIX_HINT} + PATH_SUFFIXES include +) + +find_library(Gmsh_LIBRARIES + NAMES gmsh + HINTS ${Gmsh_PREFIX_HINT} + PATH_SUFFIXES lib lib64 +) include(FindPackageHandleStandardArgs) find_package_handle_standard_args( diff --git a/cmake/bob.cmake b/cmake/bob.cmake index 6c57b5a65..ebaa3a7bf 100644 --- a/cmake/bob.cmake +++ b/cmake/bob.cmake @@ -610,13 +610,28 @@ endmacro(latest_find_dependency)" set(FIND_DEPS_CONTENT) foreach(dep IN LISTS ${PROJECT_NAME}_DEPS) string(REPLACE ";" " " FIND_DEP_ARGS "${${dep}_find_package_args}") + # Enable C language before finding MPI if MPI requires C component + if(dep STREQUAL "MPI" AND FIND_DEP_ARGS MATCHES "C") + set(FIND_DEPS_CONTENT +"${FIND_DEPS_CONTENT} +enable_language(C)" + ) + endif() set(FIND_DEPS_CONTENT "${FIND_DEPS_CONTENT} latest_find_dependency(${dep} ${FIND_DEP_ARGS})" ) endforeach() + foreach(dep IN LISTS ${PROJECT_NAME}_DEPS) + if(EXISTS "${PROJECT_SOURCE_DIR}/cmake/Find${dep}.cmake") + install(FILES + "${PROJECT_SOURCE_DIR}/cmake/Find${dep}.cmake" + DESTINATION ${BOB_LIB_DESTINATION}/cmake/${PROJECT_NAME}) + endif() + endforeach() set(CONFIG_CONTENT "set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION}) +list(APPEND CMAKE_MODULE_PATH \"\${CMAKE_CURRENT_LIST_DIR}\") ${LATEST_FIND_DEPENDENCY} ${FIND_DEPS_CONTENT} set(${PROJECT_NAME}_EXPORTED_TARGETS \"${${PROJECT_NAME}_EXPORTED_TARGETS}\") diff --git a/example/external_installation/CMakeLists.txt b/example/external_installation/CMakeLists.txt new file mode 100644 index 000000000..13fb3a8ff --- /dev/null +++ b/example/external_installation/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.10) +project(TestOmegaHConfig CXX) + +set(CMAKE_CXX_EXTENSIONS OFF) + +# Enable testing +enable_testing() + +# Find Omega_h package +find_package(Omega_h REQUIRED) + +# Create test executable +add_executable(test_export test_export.cpp) + +# Link with Omega_h +target_link_libraries(test_export Omega_h::omega_h) + +# Add test +add_test(NAME test_export COMMAND test_export) +set_tests_properties(test_export PROPERTIES + PASS_REGULAR_EXPRESSION "Test completed successfully!") \ No newline at end of file diff --git a/example/external_installation/test_export.cpp b/example/external_installation/test_export.cpp new file mode 100644 index 000000000..59b6f3886 --- /dev/null +++ b/example/external_installation/test_export.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include + +int main(int argc, char** argv) { + // Initialize Omega_h library + auto lib = Omega_h::Library(&argc, &argv); + auto world = lib.world(); + + // Create a simple 2D box mesh + std::cout << "Creating 2D box mesh..." << std::endl; + auto mesh = Omega_h::build_box(world, OMEGA_H_SIMPLEX, 1.0, 1.0, 0.0, 4, 4, 0); + + std::cout << "Mesh created with:" << std::endl; + std::cout << " Dimension: " << mesh.dim() << std::endl; + std::cout << " Vertices: " << mesh.nverts() << std::endl; + std::cout << " Elements: " << mesh.nelems() << std::endl; + + std::cout << "Test completed successfully!" << std::endl; + + return 0; +} \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e4d0fb7e..1d0b159a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -169,7 +169,6 @@ endif() message(STATUS "Omega_h_USE_ADIOS2: ${Omega_h_USE_ADIOS2}") if(Omega_h_USE_ADIOS2) list(APPEND Omega_h_SOURCES Omega_h_adios2.cpp) - find_package(ADIOS2 REQUIRED) endif() if(Omega_h_USE_SEACASExodus)