-
Notifications
You must be signed in to change notification settings - Fork 70
Feature: Reintroduce FetchContent #2303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0097a30
f3cce7a
da7660f
eb061dd
000aa1a
43d8e04
84b85ee
4118df9
f60b819
48e5ac5
449bf65
9250bb9
4c8a84b
d750d68
762093d
ad4c88e
0b08e59
50a1de9
37f54fa
da96b61
7a7843b
254c5d5
9961d39
01bbd66
9e1db72
05860a7
3b5e8d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: 8 # Increase this number to force a new installation of sc and p4est and to update the cache once | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 8 is king? |
||
| MPI: ${{ matrix.MPI }} | ||
|
|
||
| # Run parallel tests for sc and p4est with and without MPI | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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) | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this include the FETCHCONTENT variables, which are already marked in thirdparty.cmake? |
||||||
| 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 ) | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower case GITHUB_ENV vars vs. upper case above.
Is this ok?