From 14c0496f507b923d1a125dac62f6c37d6aacdf31 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Mon, 5 May 2025 13:47:16 -0500 Subject: [PATCH] CMake: C++ module preparation: collect a full list of header and source files --- ...acro_collect_source_and_header_files.cmake | 42 +++++++++++++++++++ source/algorithms/CMakeLists.txt | 2 + source/arborx/CMakeLists.txt | 2 + source/base/CMakeLists.txt | 2 + source/cgal/CMakeLists.txt | 2 + source/differentiation/ad/CMakeLists.txt | 2 + source/differentiation/sd/CMakeLists.txt | 2 + source/distributed/CMakeLists.txt | 3 +- source/dofs/CMakeLists.txt | 2 + source/fe/CMakeLists.txt | 2 + source/gmsh/CMakeLists.txt | 2 + source/grid/CMakeLists.txt | 2 + source/hp/CMakeLists.txt | 2 + source/integrators/CMakeLists.txt | 2 + source/lac/CMakeLists.txt | 2 + source/matrix_free/CMakeLists.txt | 2 + source/meshworker/CMakeLists.txt | 2 + source/multigrid/CMakeLists.txt | 2 + source/non_matching/CMakeLists.txt | 2 + source/numerics/CMakeLists.txt | 2 + source/opencascade/CMakeLists.txt | 2 + source/optimization/rol/CMakeLists.txt | 2 + source/particles/CMakeLists.txt | 2 + source/physics/CMakeLists.txt | 2 + source/physics/elasticity/CMakeLists.txt | 2 + source/sundials/CMakeLists.txt | 2 + source/trilinos/CMakeLists.txt | 2 + 27 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 cmake/macros/macro_collect_source_and_header_files.cmake diff --git a/cmake/macros/macro_collect_source_and_header_files.cmake b/cmake/macros/macro_collect_source_and_header_files.cmake new file mode 100644 index 0000000000..3a2ba9682c --- /dev/null +++ b/cmake/macros/macro_collect_source_and_header_files.cmake @@ -0,0 +1,42 @@ +## ------------------------------------------------------------------------ +## +## SPDX-License-Identifier: LGPL-2.1-or-later +## Copyright (C) 2012 - 2023 by the deal.II authors +## +## This file is part of the deal.II library. +## +## Part of the source code is dual licensed under Apache-2.0 WITH +## LLVM-exception OR LGPL-2.1-or-later. Detailed license information +## governing the source code and code contributions can be found in +## LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +## +## ------------------------------------------------------------------------ + +# +# collect_source_and_header_files("" "
") +# +# This macro appends a list of sources and header files to the global +# properties DEAL_II_SOURCE_FILES and DEAL_II_HEADER_FILES. +# + +function(collect_source_and_header_files _sources _headers) + + # + # Drop empty strings and check whether the first list element is an + # absolute path. If not, then prepend the CMAKE_CURRENT_SOURCE_DIR to the + # path: + # + foreach(_list_name _sources _headers) + list(REMOVE_ITEM ${_list_name} "") + + if(NOT "${${_list_name}}" STREQUAL "") + list(GET ${_list_name} 0 _first_element) + if(NOT IS_ABSOLUTE ${_first_element}) + list(TRANSFORM ${_list_name} PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") + endif() + endif() + endforeach() + + set_property(GLOBAL APPEND PROPERTY DEAL_II_SOURCE_FILES ${_sources}) + set_property(GLOBAL APPEND PROPERTY DEAL_II_HEADER_FILES ${_headers}) +endfunction() diff --git a/source/algorithms/CMakeLists.txt b/source/algorithms/CMakeLists.txt index 172d3db83f..ca18830e7c 100644 --- a/source/algorithms/CMakeLists.txt +++ b/source/algorithms/CMakeLists.txt @@ -28,3 +28,5 @@ file(GLOB _header define_object_library(object_algorithms OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_algorithms "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/arborx/CMakeLists.txt b/source/arborx/CMakeLists.txt index 18278b5913..e87af2d181 100644 --- a/source/arborx/CMakeLists.txt +++ b/source/arborx/CMakeLists.txt @@ -36,3 +36,5 @@ file(GLOB _header define_object_library(object_arborx OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_arborx "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/base/CMakeLists.txt b/source/base/CMakeLists.txt index de3cca75d6..9f1cd08127 100644 --- a/source/base/CMakeLists.txt +++ b/source/base/CMakeLists.txt @@ -169,3 +169,5 @@ define_object_library(object_base OBJECT ${_src} ${_header} ${_inst} ${CMAKE_BINARY_DIR}/include/deal.II/base/config.h ) expand_instantiations(object_base "${_inst}") + +collect_source_and_header_files("${_unity_include_src};${_separate_src}" "${_header}") diff --git a/source/cgal/CMakeLists.txt b/source/cgal/CMakeLists.txt index 6e4dfef9bf..d1658c39df 100644 --- a/source/cgal/CMakeLists.txt +++ b/source/cgal/CMakeLists.txt @@ -46,3 +46,5 @@ file(GLOB _header define_object_library(object_cgal OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_cgal "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/differentiation/ad/CMakeLists.txt b/source/differentiation/ad/CMakeLists.txt index 6b099c3aa8..941b5c7afa 100644 --- a/source/differentiation/ad/CMakeLists.txt +++ b/source/differentiation/ad/CMakeLists.txt @@ -66,3 +66,5 @@ file(GLOB _header define_object_library(object_differentiation_ad OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_differentiation_ad "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/differentiation/sd/CMakeLists.txt b/source/differentiation/sd/CMakeLists.txt index f4b45801bf..4192ad5c13 100644 --- a/source/differentiation/sd/CMakeLists.txt +++ b/source/differentiation/sd/CMakeLists.txt @@ -41,3 +41,5 @@ file(GLOB _header define_object_library(object_differentiation_sd OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_differentiation_sd "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/distributed/CMakeLists.txt b/source/distributed/CMakeLists.txt index 70b6ac8a97..9fe0810890 100644 --- a/source/distributed/CMakeLists.txt +++ b/source/distributed/CMakeLists.txt @@ -62,10 +62,11 @@ setup_source_list("${_unity_include_src}" ) - file(GLOB _header ${CMAKE_SOURCE_DIR}/include/deal.II/distributed/*.h ) define_object_library(object_distributed OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_distributed "${_inst}") + +collect_source_and_header_files("${_unity_include_src};${_separate_src}" "${_header}") diff --git a/source/dofs/CMakeLists.txt b/source/dofs/CMakeLists.txt index 944ba3ea6b..8cd9a594c4 100644 --- a/source/dofs/CMakeLists.txt +++ b/source/dofs/CMakeLists.txt @@ -60,3 +60,5 @@ file(GLOB _header define_object_library(object_dofs OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_dofs "${_inst}") + +collect_source_and_header_files("${_unity_include_src};${_separate_src}" "${_header}") diff --git a/source/fe/CMakeLists.txt b/source/fe/CMakeLists.txt index e2cdbc0f7f..96be15caee 100644 --- a/source/fe/CMakeLists.txt +++ b/source/fe/CMakeLists.txt @@ -152,3 +152,5 @@ file(GLOB _header define_object_library(object_fe OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_fe "${_inst}") + +collect_source_and_header_files("${_unity_include_src};${_separate_src}" "${_header}") diff --git a/source/gmsh/CMakeLists.txt b/source/gmsh/CMakeLists.txt index 6b44f2ebf8..18b506a69e 100644 --- a/source/gmsh/CMakeLists.txt +++ b/source/gmsh/CMakeLists.txt @@ -35,3 +35,5 @@ file(GLOB _header define_object_library(object_gmsh OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_gmsh "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/grid/CMakeLists.txt b/source/grid/CMakeLists.txt index ae776887fd..2f5d864651 100644 --- a/source/grid/CMakeLists.txt +++ b/source/grid/CMakeLists.txt @@ -99,3 +99,5 @@ file(GLOB _header define_object_library(object_grid OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_grid "${_inst}") + +collect_source_and_header_files("${_unity_include_src};${_separate_src}" "${_header}") diff --git a/source/hp/CMakeLists.txt b/source/hp/CMakeLists.txt index 934171430a..2e0d052b1d 100644 --- a/source/hp/CMakeLists.txt +++ b/source/hp/CMakeLists.txt @@ -44,3 +44,5 @@ file(GLOB _header define_object_library(object_hp OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_hp "${_inst}") + +collect_source_and_header_files("${_unity_include_src};${_separate_src}" "${_header}") diff --git a/source/integrators/CMakeLists.txt b/source/integrators/CMakeLists.txt index 0d6051c21c..93f9b8367f 100644 --- a/source/integrators/CMakeLists.txt +++ b/source/integrators/CMakeLists.txt @@ -20,3 +20,5 @@ file(GLOB _header ) define_object_library(object_integrators OBJECT ${_src} ${_header}) + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/lac/CMakeLists.txt b/source/lac/CMakeLists.txt index 857ad51577..4c667cbe0d 100644 --- a/source/lac/CMakeLists.txt +++ b/source/lac/CMakeLists.txt @@ -197,3 +197,5 @@ file(GLOB _header define_object_library(object_lac OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_lac "${_inst}") + +collect_source_and_header_files("${_unity_include_src};${_separate_src}" "${_header}") diff --git a/source/matrix_free/CMakeLists.txt b/source/matrix_free/CMakeLists.txt index 2df929bcdb..d52319c8a3 100644 --- a/source/matrix_free/CMakeLists.txt +++ b/source/matrix_free/CMakeLists.txt @@ -54,3 +54,5 @@ file(GLOB _header define_object_library(object_matrix_free OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_matrix_free "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/meshworker/CMakeLists.txt b/source/meshworker/CMakeLists.txt index 98930fa1b6..9f6381b541 100644 --- a/source/meshworker/CMakeLists.txt +++ b/source/meshworker/CMakeLists.txt @@ -31,3 +31,5 @@ file(GLOB _header define_object_library(object_meshworker OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_meshworker "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/multigrid/CMakeLists.txt b/source/multigrid/CMakeLists.txt index f32bfe5172..5dd429fff2 100644 --- a/source/multigrid/CMakeLists.txt +++ b/source/multigrid/CMakeLists.txt @@ -58,3 +58,5 @@ file(GLOB _header define_object_library(object_multigrid OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_multigrid "${_inst}") + +collect_source_and_header_files("${_unity_include_src};${_separate_src}" "${_header}") diff --git a/source/non_matching/CMakeLists.txt b/source/non_matching/CMakeLists.txt index a20c81933f..91d1f26355 100644 --- a/source/non_matching/CMakeLists.txt +++ b/source/non_matching/CMakeLists.txt @@ -35,3 +35,5 @@ file(GLOB _header define_object_library(object_non_matching OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_non_matching "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/numerics/CMakeLists.txt b/source/numerics/CMakeLists.txt index 4190495b48..aa5b52eee2 100644 --- a/source/numerics/CMakeLists.txt +++ b/source/numerics/CMakeLists.txt @@ -111,3 +111,5 @@ file(GLOB _header define_object_library(object_numerics OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_numerics "${_inst}") + +collect_source_and_header_files("${_unity_include_src};${_separate_src}" "${_header}") diff --git a/source/opencascade/CMakeLists.txt b/source/opencascade/CMakeLists.txt index 3fa8a78a93..1004bc8d96 100644 --- a/source/opencascade/CMakeLists.txt +++ b/source/opencascade/CMakeLists.txt @@ -35,3 +35,5 @@ file(GLOB _header define_object_library(object_opencascade OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_opencascade "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/optimization/rol/CMakeLists.txt b/source/optimization/rol/CMakeLists.txt index efefbd08f0..e870da4cc6 100644 --- a/source/optimization/rol/CMakeLists.txt +++ b/source/optimization/rol/CMakeLists.txt @@ -24,3 +24,5 @@ file(GLOB _header define_object_library(object_rol OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_rol "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/particles/CMakeLists.txt b/source/particles/CMakeLists.txt index 2b633a4f97..9e7392b51e 100644 --- a/source/particles/CMakeLists.txt +++ b/source/particles/CMakeLists.txt @@ -35,3 +35,5 @@ file(GLOB _header define_object_library(object_particles OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_particles "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/physics/CMakeLists.txt b/source/physics/CMakeLists.txt index 6695433cd1..758646c1ed 100644 --- a/source/physics/CMakeLists.txt +++ b/source/physics/CMakeLists.txt @@ -29,3 +29,5 @@ file(GLOB _header define_object_library(object_physics OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_physics "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/physics/elasticity/CMakeLists.txt b/source/physics/elasticity/CMakeLists.txt index fd19f5fad0..b0782f13e4 100644 --- a/source/physics/elasticity/CMakeLists.txt +++ b/source/physics/elasticity/CMakeLists.txt @@ -28,3 +28,5 @@ file(GLOB _header define_object_library(object_physics_elasticity OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_physics_elasticity "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/sundials/CMakeLists.txt b/source/sundials/CMakeLists.txt index 58fd205345..e8f91d5d4c 100644 --- a/source/sundials/CMakeLists.txt +++ b/source/sundials/CMakeLists.txt @@ -38,3 +38,5 @@ file(GLOB _header define_object_library(object_sundials OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_sundials "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") diff --git a/source/trilinos/CMakeLists.txt b/source/trilinos/CMakeLists.txt index b60e84345c..eb373a2fb2 100644 --- a/source/trilinos/CMakeLists.txt +++ b/source/trilinos/CMakeLists.txt @@ -34,3 +34,5 @@ file(GLOB _header define_object_library(object_trilinos OBJECT ${_src} ${_header} ${_inst}) expand_instantiations(object_trilinos "${_inst}") + +collect_source_and_header_files("${_src}" "${_header}") -- 2.39.5