diff --git a/.github/workflows/test_preparation.yml b/.github/workflows/test_preparation.yml index 074559a74c..68ac2ed131 100644 --- a/.github/workflows/test_preparation.yml +++ b/.github/workflows/test_preparation.yml @@ -66,10 +66,6 @@ jobs: # This seems to be necessary because of the docker container - name: disable ownership checks run: git config --global --add safe.directory '*' - - name: init submodules - run: git submodule init - - name: update submodules - run: git submodule update - name: Get input vars run: export MAKEFLAGS="${{ inputs.MAKEFLAGS }}" && export IGNORE_CACHE="${{ inputs.IGNORE_CACHE }}" @@ -83,20 +79,24 @@ jobs: # SC installation # - name: store sc folders in var - run: echo SC_BUILD=$PWD/sc/build >> $GITHUB_ENV + run: echo SC_SOURCE=$PWD/sc >> $GITHUB_ENV + && echo SC_BUILD=$PWD/sc/build >> $GITHUB_ENV && echo SC_DEBUG=$PWD/sc/build/Debug >> $GITHUB_ENV && echo SC_RELEASE=$PWD/sc/build/Release >> $GITHUB_ENV - - name: Get sc commit hash - run: hash=`git rev-parse HEAD:sc` && echo sc_commit=$hash >> $GITHUB_ENV + - name: Get sc commit hash and url from thirdparty.json + run: | + hash=$(jq -r '.thirdparty[] | select(.name=="SC") .source.ref' cmake/thirdparty.json) + echo SC_COMMIT=$hash >> $GITHUB_ENV + url=$(jq -r '.thirdparty[] | select(.name=="SC") .source.url' cmake/thirdparty.json) + echo SC_URL=$url >> $GITHUB_ENV - name: Check cache for previous sc installation id: sc_cmake_cache uses: actions/cache@v5 with: path: | - ${{ env.SC_DEBUG }} - ${{ env.SC_RELEASE }} + ${{ env.SC_SOURCE }} # You can increase the counter at the end to force a new key and hence recomputing the cache - key: sc-cmake-MPI-${{ inputs.MPI }}-${{ env.sc_commit }}-${{ inputs.CACHE_COUNTER }} + key: sc-cmake-MPI-${{ inputs.MPI }}-${{ env.SC_COMMIT }}-${{ inputs.CACHE_COUNTER }} - name: Log that no cache was found run: echo USED_CACHE=0 >> $GITHUB_ENV if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' }} @@ -107,22 +107,29 @@ jobs: if: ${{ inputs.IGNORE_CACHE == 1 }} # The true at the end is to ignore errors that i.e. occur when the folders do not exist run: rm -r $SC_BUILD || true - - name: make folders - run: mkdir -p $SC_DEBUG $SC_RELEASE - if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - name: install sc run: echo "Install sc" if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - ## sc debug + - uses: actions/checkout@v6 + with: + repository: cburstedde/libsc + ref: ${{ env.SC_COMMIT }} + fetch-depth: 1 + path: ${{ env.SC_SOURCE }} + if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} + - name: make folders + run: mkdir -p $SC_DEBUG $SC_RELEASE + if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} + ## sc debug build - name: sc cmake debug - run: cd $SC_DEBUG && cmake ../../ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$SC_DEBUG/install -Dmpi=$MPI -GNinja + run: cd $SC_DEBUG && cmake $SC_SOURCE -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$SC_DEBUG/install -Dmpi=$MPI -GNinja if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - name: sc build debug run: cd $SC_DEBUG && ninja $MAKEFLAGS && ninja $MAKEFLAGS install if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - ## sc release + ## sc release build - name: sc cmake release - run: cd $SC_RELEASE && cmake ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$SC_RELEASE/install -Dmpi=$MPI -GNinja + run: cd $SC_RELEASE && cmake $SC_SOURCE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$SC_RELEASE/install -Dmpi=$MPI -GNinja if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - name: sc build release run: cd $SC_RELEASE && ninja $MAKEFLAGS && ninja $MAKEFLAGS install @@ -131,46 +138,57 @@ jobs: # P4EST # - name: store p4est folders in var - run: echo P4EST_BUILD=$PWD/p4est/build >> $GITHUB_ENV + run: echo P4EST_SOURCE=$PWD/p4est >> $GITHUB_ENV + && echo P4EST_BUILD=$PWD/p4est/build >> $GITHUB_ENV && echo P4EST_DEBUG=$PWD/p4est/build/Debug >> $GITHUB_ENV && echo P4EST_RELEASE=$PWD/p4est/build/Release >> $GITHUB_ENV - - name: Get p4est commit hash - run: hash=`git rev-parse HEAD:p4est` && echo p4est_commit=$hash >> $GITHUB_ENV + - name: Get p4est commit hash and url from thirdparty.json + run: | + hash=$(jq -r '.thirdparty[] | select(.name=="P4EST") .source.ref' cmake/thirdparty.json) + echo P4EST_COMMIT=$hash >> $GITHUB_ENV + url=$(jq -r '.thirdparty[] | select(.name=="P4EST") .source.url' cmake/thirdparty.json) + echo P4EST_URL=$url >> $GITHUB_ENV - name: Check cache for previous p4est installation id: p4est_cmake_cache uses: actions/cache@v5 with: path: | - ${{ env.P4EST_DEBUG }} - ${{ env.P4EST_RELEASE }} + ${{ env.P4EST_SOURCE }} # You can increase the counter at the end to force a new key and hence recomputing the cache - key: p4est-cmake-MPI-${{ inputs.MPI }}-${{ env.p4est_commit }}-${{ env.sc_commit }}-${{ inputs.CACHE_COUNTER }} + key: p4est-cmake-MPI-${{ inputs.MPI }}-${{ env.P4EST_COMMIT }}-${{ env.SC_COMMIT }}-${{ inputs.CACHE_COUNTER }} - name: Log that no cache was found run: echo USED_CACHE=0 >> $GITHUB_ENV if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' }} - name: Cache info if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} run: echo No cache found or cache will be ignored. IGNORE_CACHE=$IGNORE_CACHE - - name: install p4est - run: echo "Install p4est" - if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - name: if ignore cache, delete folders if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} # The true at the end is to ignore errors that i.e. occur when the folders do not exist run: rm -r $P4EST_BUILD || true + - name: install p4est + run: echo "Install p4est" + if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} + - uses: actions/checkout@v6 + with: + repository: cburstedde/p4est + ref: ${{ env.P4EST_COMMIT }} + fetch-depth: 1 + path: ${{ env.P4EST_SOURCE }} + if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - name: make folders if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} run: mkdir -p $P4EST_DEBUG $P4EST_RELEASE - ## p4est debug + ## p4est debug build - name: p4est cmake debug - run: cd $P4EST_DEBUG && cmake ../../ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$P4EST_DEBUG/install -DP4EST_USE_SYSTEM_SC=ON -DSC_DIR=$SC_DEBUG/install/cmake -DP4EST_ENABLE_MPI=$MPI -GNinja + run: cd $P4EST_DEBUG && cmake $P4EST_SOURCE -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$P4EST_DEBUG/install -DP4EST_USE_SYSTEM_SC=ON -DSC_DIR=$SC_DEBUG/install/cmake -DP4EST_ENABLE_MPI=$MPI -GNinja if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - name: p4est build debug run: cd $P4EST_DEBUG && ninja $MAKEFLAGS && ninja $MAKEFLAGS install if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - ## p4est release + ## p4est release build - name: p4est cmake release - run: cd $P4EST_RELEASE && cmake ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$P4EST_RELEASE/install -DP4EST_USE_SYSTEM_SC=ON -DSC_DIR=$SC_DEBUG/install/cmake -DP4EST_ENABLE_MPI=$MPI -GNinja + run: cd $P4EST_RELEASE && cmake $P4EST_SOURCE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$P4EST_RELEASE/install -DP4EST_USE_SYSTEM_SC=ON -DSC_DIR=$SC_RELEASE/install/cmake -DP4EST_ENABLE_MPI=$MPI -GNinja if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }} - name: p4est build release run: cd $P4EST_RELEASE && ninja $MAKEFLAGS && ninja $MAKEFLAGS install diff --git a/.github/workflows/test_t8code_w_shipped_submodules.yml b/.github/workflows/test_t8code_w_shipped_submodules.yml index 69306f8743..2a86f1cbe3 100644 --- a/.github/workflows/test_t8code_w_shipped_submodules.yml +++ b/.github/workflows/test_t8code_w_shipped_submodules.yml @@ -60,10 +60,6 @@ jobs: # This seems to be necessary because of the docker container - name: disable ownership checks run: git config --global --add safe.directory '*' - - name: init submodules - run: git submodule init - - name: update submodules - run: git submodule update - name: Get input vars run: export MAKEFLAGS="${{ inputs.MAKEFLAGS }}" && export MPI="${{ inputs.MPI }}" diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index 631f7f48e8..b3a691562a 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -120,7 +120,7 @@ jobs: with: MAKEFLAGS: ${{ matrix.MAKEFLAGS }} IGNORE_CACHE: false # Use this to force a new installation of sc and p4est for this specific workflow run - CACHE_COUNTER: 0 # Increase this number to force a new installation of sc and p4est and to update the cache once + CACHE_COUNTER: 9 # Increase this number to force a new installation of sc and p4est and to update the cache once MPI: ${{ matrix.MPI }} # Run parallel tests for sc and p4est with and without MPI diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5281fdb8b3..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,8 +0,0 @@ -[submodule "p4est"] - path = p4est - url = https://github.com/cburstedde/p4est.git - ignore = dirty -[submodule "sc"] - path = sc - url = https://github.com/cburstedde/libsc.git - ignore = dirty diff --git a/CMakeLists.txt b/CMakeLists.txt index c7e010ad3a..19a6cc69c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # t8code is a C library to manage a collection (a forest) of multiple # connected adaptive space-trees of general element types in parallel. # -# Copyright (C) 2025 the developers +# Copyright (C) 2026 the developers # # t8code is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,11 +18,9 @@ # along with t8code; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -cmake_minimum_required( VERSION 3.16 ) +cmake_minimum_required( VERSION 3.19 ) include( cmake/GitProjectVersion.cmake ) -include( FetchContent ) -# All fetchcontent cmake options+ are marked as advanced below. project( T8CODE @@ -35,18 +33,6 @@ include( GNUInstallDirs) include( CTest ) include( CMakeDependentOption ) -FetchContent_Declare( - googletest - GIT_REPOSITORY "https://github.com/DLR-SC/googletest_mpi.git" - GIT_TAG 98bfff426b057400268a00f97677d749a9e25096 #v1.17.0_mpi - GIT_PROGRESS TRUE - GIT_SHALLOW TRUE - ) - -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -mark_as_advanced( FORCE gtest_force_shared_crt) - - option( T8CODE_BUILD_AS_SHARED_LIBRARY "Whether t8code should be built as a shared or a static library" ON ) option( T8CODE_BUILD_PEDANTIC "Compile t8code with `-pedantic` as done in the Github CI." OFF ) option( T8CODE_BUILD_WALL "Compile t8code with `-Wall` as done in the Github CI." OFF ) @@ -124,17 +110,79 @@ if( T8CODE_ENABLE_MPI ) else() find_package( MPI 3.0 COMPONENTS C REQUIRED ) endif() - set (gtest_disable_mpi OFF CACHE BOOL "disable gtest mpi support" FORCE) + set (gtest_disable_mpi OFF CACHE INTERNAL "disable gtest mpi support" FORCE) if( NOT MPIEXEC_EXECUTABLE ) message( FATAL_ERROR "MPIEXEC was not found" ) endif() - set( SC_ENABLE_MPI ON ) + set( SC_ENABLE_MPI ON CACHE INTERNAL "enable mpi support in libsc" FORCE) +else() + set( gtest_disable_mpi ON CACHE INTERNAL "disable gtest mpi support" FORCE) +endif() + +############################################ ThirdParty ############################################ + +# Set some variables for the thirdparty libraries +set( gtest_force_shared_crt ON CACHE INTERNAL "" FORCE ) +set( P4EST_BUILD_EXAMPLES ${T8CODE_BUILD_TPL_EXAMPLES} ) +set( P4EST_BUILD_TESTING ${T8CODE_BUILD_TPL_TESTS} ) +set( SC_BUILD_EXAMPLES ${T8CODE_BUILD_TPL_EXAMPLES} ) +set( SC_BUILD_TESTING ${T8CODE_BUILD_TPL_TESTS} ) + +# When executing CMake tests for some thirdparty libraries like sc, i.e. check_c_source_compiles/check_cxx_source_compiles and others +# we need to ignore the -Werror option, since these tests often produce warnings (see check_mpicommshared.cmake from sc for example). +# If theses warnings are interpreted as errors, the test fails even though we want it to pass. +# This behaviour caused a serious bug and did not initialize our shared memory. See https://github.com/DLR-AMR/t8code/issues/1985. +set( T8CODE_OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}" ) +if (WIN32 AND NOT MINGW) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /w" ) +else() + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -w" ) +endif() + +# Do the same for the normal build flags to suppress warnings from the thirdparty library +set(ORIGINAL_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +set(ORIGINAL_C_FLAGS "${CMAKE_C_FLAGS}") +if (WIN32 AND NOT MINGW) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w" CACHE STRING "" FORCE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w" CACHE STRING "" FORCE) else() - set( gtest_disable_mpi ON CACHE BOOL "disable gtest mpi support" FORCE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w" CACHE STRING "" FORCE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w" CACHE STRING "" FORCE) endif() -mark_as_advanced( FORCE gtest_disable_mpi) +# Capture the list of variables before adding the thirdparty libraries to mark the added ones as advanced. +get_cmake_property(_vars_before_thirdparty VARIABLES ) + +# Populate the thirdparty libraries +include (cmake/thirdparty.cmake) + +# Capture the list of variables after adding thirdparty libraries +get_cmake_property(_vars_after_thirdparty VARIABLES) + +# Find variables that exist after but not before +set(_new_thirdparty_vars) +foreach(_var IN LISTS _vars_after_thirdparty) + list(FIND _vars_before_thirdparty "${_var}" _index) + if(_index EQUAL -1) + list(APPEND _new_thirdparty_vars ${_var}) + endif() +endforeach() + +# Mark the new variables as advanced +if(_new_thirdparty_vars) + mark_as_advanced(FORCE ${_new_thirdparty_vars}) +endif() + +# Reactivate previous CMAKE_REQUIRED_FLAGS and CMAKE_C/CXX_FLAGS +set( CMAKE_REQUIRED_FLAGS "${T8CODE_OLD_CMAKE_REQUIRED_FLAGS}" ) +unset( T8CODE_OLD_CMAKE_REQUIRED_FLAGS ) +set(CMAKE_CXX_FLAGS "${ORIGINAL_CXX_FLAGS}" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS "${ORIGINAL_C_FLAGS}" CACHE STRING "" FORCE) +unset (ORIGINAL_CXX_FLAGS) +unset (ORIGINAL_C_FLAGS) + +############################################ End of ThirdParty ############################################ if( T8CODE_ENABLE_VTK ) @@ -183,39 +231,6 @@ endif() if ( T8CODE_USE_SYSTEM_SC ) find_package( SC REQUIRED ) else() - set( SC_BUILD_EXAMPLES ${T8CODE_BUILD_TPL_EXAMPLES} ) - set( SC_BUILD_TESTING ${T8CODE_BUILD_TPL_TESTS} ) - - # When executing CMake tests for libsc, i.e. check_c_source_compiles/check_cxx_source_compiles and others - # we need to ignore the -Werror option, since these tests often produce warnings (see check_mpicommshared.cmake for example). - # If theses warnings are interpreted as errors, the test fails even though we want it to pass. - # This behaviour caused a serious bug and did not initialize our shared memory. See https://github.com/DLR-AMR/t8code/issues/1985. - set( T8CODE_OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}" ) - if (WIN32 AND NOT MINGW) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /w" ) - else() - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -w" ) - endif() - - # Capture the list of variables before adding the subdirectory to mark the added ones as advanced. - get_cmake_property(_vars_before_sc VARIABLES ) - list( APPEND CMAKE_MESSAGE_CONTEXT "sc" ) - add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/sc ) - list( POP_BACK CMAKE_MESSAGE_CONTEXT ) - add_library(SC INTERFACE) - # Capture the list of variables after adding the subdirectory - get_cmake_property(_vars_after_sc VARIABLES ) - # Compute the difference (new variables added by the subdirectory) - set( _new_sc_vars) - foreach( _var IN LISTS _vars_after_sc ) - if( NOT _var IN_LIST _vars_before_sc ) - list( APPEND _new_sc_vars ${_var} ) - endif() - endforeach() - - # Mark the new variables as advanced - mark_as_advanced( FORCE ${_new_sc_vars} ) - ########################## Fix for OpenMPI ############################################ # OpenMPI sometimes has a mismatch between their C and CXX interface which produces a warning in SC. # The warning makes t8codes build fail when Werror is activated. This fix checks if t8code @@ -247,63 +262,13 @@ else() message(WARNING "mpi.h not found!") endif() ########################## End of fix for OpenMPI ############################################ - - # Reactivate previous CMAKE_REQUIRED_FLAGS - set( CMAKE_REQUIRED_FLAGS "${T8CODE_OLD_CMAKE_REQUIRED_FLAGS}" ) - unset( T8CODE_OLD_CMAKE_REQUIRED_FLAGS ) endif() + if ( T8CODE_USE_SYSTEM_P4EST ) find_package( P4EST REQUIRED ) -else() - set( P4EST_BUILD_EXAMPLES ${T8CODE_BUILD_TPL_EXAMPLES} ) - set( P4EST_BUILD_TESTING ${T8CODE_BUILD_TPL_TESTS} ) - - # Capture the list of variables before adding the subdirectory to mark the added ones as advanced. - get_cmake_property( _vars_before_p4est VARIABLES ) - list( APPEND CMAKE_MESSAGE_CONTEXT "p4est" ) - add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/p4est ) - list( POP_BACK CMAKE_MESSAGE_CONTEXT ) - # Capture the list of variables after adding the subdirectory - get_cmake_property( _vars_after_p4est VARIABLES ) - # Compute the difference (new variables added by the subdirectory) - set( _new_p4est_vars ) - foreach( _var IN LISTS _vars_after_p4est ) - if( NOT _var IN_LIST _vars_before_p4est ) - list( APPEND _new_p4est_vars ${_var} ) - endif() - endforeach() - - # Mark the new variables as advanced - mark_as_advanced( FORCE ${_new_p4est_vars} ) endif() -# Workaround: Suppress warnings for googletests, so it does not compromise the usage of -WError for t8code. -# ----------- -# 1. Save original flags -set(ORIGINAL_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -set(ORIGINAL_C_FLAGS "${CMAKE_C_FLAGS}") - -# 2. Suppress warnings for GoogleTest build -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w" CACHE STRING "" FORCE) - -FetchContent_MakeAvailable( googletest ) - -# 3. Restore original flags -set(CMAKE_CXX_FLAGS "${ORIGINAL_CXX_FLAGS}" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS "${ORIGINAL_C_FLAGS}" CACHE STRING "" FORCE) - -# End of workaround - -# Mark all cmake options starting with FETCHCONTENT as advanced. -get_cmake_property(_cmake_vars VARIABLES) -foreach(_var ${_cmake_vars}) - if(_var MATCHES "^FETCHCONTENT_.*") - mark_as_advanced(${_var}) - endif() -endforeach() - add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/src ) if( T8CODE_BUILD_MESH_HANDLE ) diff --git a/NEWS.md b/NEWS.md index fc2ff796fc..7387b0f657 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# Updated dependencies + +We have switched from a submodules approach to a FetchContent approach for our dependencies p4est and sc. If you use p4est and sc shipped with t8code, calling cmake will pull and add the right commit from github. You can also still link against your local installations. Either way you do not need to update your workflow. The submodules of p4est and sc should be removed with this update. Instead they will be downloaded and installed in the _deps folder in your build folder. +If you use a separate installation of p4est and sc it is important to set the boolean CMake Options "T8CODE_USE_SYSTEM_P4EST" and "T8CODE_USE_SYSTEM_SC" as before. It prevents the triggering of the automatic installation of the libraries. +For further information have a look at our [Installation Guide](https://github.com/DLR-AMR/t8code/wiki/Installation). +For devs: Further dependencies can be managed in our dependencies.json. + + # Updated contribution workflow. The team of main-developers of t8code and contributors to t8code is getting bigger and we needed an improved workflow to manage all of our contributions. @@ -237,7 +245,7 @@ Similarly, the following member variables have been renamed: # Renaming of macros T8_WITH_ to T8_ENABLE_ We renamed the macros T8_WITH_... to T8_ENABLE_... for consistency reasons with the related cmake options (T8CODE_ENABLE...) and other macros. We are currently working on an automatized way to check for wrong usages. -Moreover, we decided to always use #if instead of #ifdef with macros. The #if option allows for more complex conditions and explicitly setting a macro to 0, which is why we chose this option. An incorrect usage of #if and #ifdef is checked in the check_macros.sh script. +Moreover, we decided to always use #if instead of #ifdef with macros. The #if option allows for more complex conditions and explicitly setting a macro to 0, which is why we chose this option. An incorrect usage of #if and #ifdef is checked in the check_macros.sh script. # Update to MPI 3.0 @@ -271,4 +279,4 @@ For more details, see the pull request https://github.com/DLR-AMR/t8code/pull/19 # Documentation on readthedocs -To improve our documentation, to make it more searchable and to simplify the updating process of our documentation, we now host our documentation on readthedocs, see https://t8code.readthedocs.io/en/latest/ . You can also build it locally, if you have sphinx, breathe and exhale installed on your system. To do so, you have to set the dependent option `T8CODE_BUILD_DOCUMENTATION_SPHINX`. We hope to give you an improved way of searching through t8code and find the functions that you need even faster. +To improve our documentation, to make it more searchable and to simplify the updating process of our documentation, we now host our documentation on readthedocs, see https://t8code.readthedocs.io/en/latest/ . You can also build it locally, if you have sphinx, breathe and exhale installed on your system. To do so, you have to set the dependent option `T8CODE_BUILD_DOCUMENTATION_SPHINX`. We hope to give you an improved way of searching through t8code and find the functions that you need even faster. diff --git a/cmake/thirdparty.cmake b/cmake/thirdparty.cmake new file mode 100644 index 0000000000..34e5b13110 --- /dev/null +++ b/cmake/thirdparty.cmake @@ -0,0 +1,77 @@ +# This file is part of t8code. +# t8code is a C library to manage a collection (a forest) of multiple +# connected adaptive space-trees of general element types in parallel. +# +# Copyright (C) 2026 the developers +# +# t8code is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# t8code is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with t8code; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +include(FetchContent) +set(FETCHCONTENT_QUIET FALSE) + + +# 1. Read and parse the JSON +file(READ "cmake/thirdparty.json" DEPS_JSON) +# 2. Get the number of elements in the "thirdparty" array +string(JSON DEPS_COUNT LENGTH "${DEPS_JSON}" "thirdparty") +# 3. Loop through the array (subtract 1 because it's 0-indexed) +math(EXPR DEPS_RANGE "${DEPS_COUNT} - 1") + +foreach(INDEX RANGE ${DEPS_RANGE}) + # Extract fields + string(JSON DEP_NAME GET "${DEPS_JSON}" "thirdparty" ${INDEX} "name") + string(JSON DEP_CMAKE_OPTION GET "${DEPS_JSON}" "thirdparty" ${INDEX} "depends_on_cmake_option") + string(JSON DEP_TYPE GET "${DEPS_JSON}" "thirdparty" ${INDEX} "source" "type") + string(JSON DEP_URL GET "${DEPS_JSON}" "thirdparty" ${INDEX} "source" "url") + string(JSON DEP_REF GET "${DEPS_JSON}" "thirdparty" ${INDEX} "source" "ref") + string(JSON DEP_SHALLOW GET "${DEPS_JSON}" "thirdparty" ${INDEX} "source" "shallow") + + # If the DEP_CMAKE_OPTION field is non-empty, check the CMake option. + if(NOT DEP_CMAKE_OPTION STREQUAL "") + # If the named option variable does not exist in the CMake cache, abort. + if(NOT DEFINED ${DEP_CMAKE_OPTION}) + message(FATAL_ERROR "Loading thirdparty library ${DEP_NAME} at index ${INDEX} references unknown CMake option '${DEP_CMAKE_OPTION}'. Aborting.") + else() + # If the named option is defined but set to ON, skip this thirdparty library. + if(${${DEP_CMAKE_OPTION}}) + message(STATUS "Skipping FetchContent-step for thirdparty library ${DEP_NAME} because CMake option '${DEP_CMAKE_OPTION}' is '${${DEP_CMAKE_OPTION}}'") + continue() + endif() + endif() + endif() + + message(STATUS "Configuring thirdparty library: ${DEP_NAME} (Type: ${DEP_TYPE}, SHALLOW: ${DEP_SHALLOW})") + + # If Dep_SHALLOW is not a valid boolean, set it to FALSE and print a warning. + if(NOT DEP_SHALLOW STREQUAL "TRUE" AND NOT DEP_SHALLOW STREQUAL "FALSE") + message(STATUS "Invalid value for 'shallow' in thirdparty library ${DEP_NAME}: '${DEP_SHALLOW}'. Expected 'TRUE' or 'FALSE'. Defaulting to 'FALSE'.") + set(DEP_SHALLOW FALSE) + endif() + + # 2. Branch logic based on "type" + if(DEP_TYPE STREQUAL "git") + FetchContent_Declare( + ${DEP_NAME} + GIT_REPOSITORY ${DEP_URL} + GIT_TAG ${DEP_REF} + GIT_SHALLOW ${DEP_SHALLOW} + ) + else() + message(WARNING "Unknown thirdparty library type '${DEP_TYPE}' for ${DEP_NAME}") + endif() + + # 3. Populate the thirdparty library + FetchContent_MakeAvailable(${DEP_NAME}) +endforeach() diff --git a/cmake/thirdparty.json b/cmake/thirdparty.json new file mode 100644 index 0000000000..f3e51f1df7 --- /dev/null +++ b/cmake/thirdparty.json @@ -0,0 +1,34 @@ +{ + "thirdparty": [ + { + "name": "googletest", + "depends_on_cmake_option": "", + "source": { + "type": "git", + "url": "https://github.com/DLR-SC/googletest_mpi.git", + "ref": "98bfff426b057400268a00f97677d749a9e25096", + "shallow": "TRUE" + } + }, + { + "name": "SC", + "depends_on_cmake_option": "T8CODE_USE_SYSTEM_SC", + "source": { + "type": "git", + "url": "https://github.com/cburstedde/libsc.git", + "ref": "f8c5099bd5ad553c1bf6e34dc7b6c290f3cc3cca", + "shallow": "TRUE" + } + }, + { + "name": "P4EST", + "depends_on_cmake_option": "T8CODE_USE_SYSTEM_P4EST", + "source": { + "type": "git", + "url": "https://github.com/cburstedde/p4est.git", + "ref": "2296a990d8b6b54731a63be0ba5bc17b08cd1f3d", + "shallow": "TRUE" + } + } + ] +} diff --git a/p4est b/p4est deleted file mode 160000 index 8399186d4e..0000000000 --- a/p4est +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8399186d4ea214361ce0d183b9bbd340a417075e diff --git a/sc b/sc deleted file mode 160000 index 1b127f01c5..0000000000 --- a/sc +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1b127f01c5e472039e938f61201ae0611fb25bad