Skip to content

Commit 88089bc

Browse files
authored
CMake Superbuild: Tarball (#1668)
Cloning whole repos can be quite slow and CMake does not support shallow clones yet. We can use release tarballs instead.
1 parent ff0c669 commit 88089bc

File tree

6 files changed

+124
-35
lines changed

6 files changed

+124
-35
lines changed

CMakeLists.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ include(${openPMD_SOURCE_DIR}/cmake/openPMDFunctions.cmake)
1212

1313
# CMake policies ##############################################################
1414
#
15-
# not needed right now
15+
# CMake 3.24+ tarball download robustness
16+
# https://cmake.org/cmake/help/latest/module/ExternalProject.html#url
17+
if(POLICY CMP0135)
18+
cmake_policy(SET CMP0135 NEW)
19+
endif()
1620

1721

1822
# No in-Source builds #########################################################
@@ -566,14 +570,8 @@ if(openPMD_HAVE_PYTHON)
566570
endif()
567571
endif()
568572
message(STATUS "Python LTO/IPO: ${_USE_PY_LTO}")
569-
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
570-
set_target_properties(openPMD.py PROPERTIES
571-
INTERPROCEDURAL_OPTIMIZATION ${_USE_PY_LTO})
572-
else()
573-
if(_USE_PY_LTO)
574-
target_link_libraries(openPMD.py PRIVATE pybind11::lto)
575-
endif()
576-
endif()
573+
set_target_properties(openPMD.py PROPERTIES
574+
INTERPROCEDURAL_OPTIMIZATION ${_USE_PY_LTO})
577575
unset(_USE_PY_LTO)
578576

579577
if(EMSCRIPTEN)

cmake/dependencies/catch.cmake

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,33 @@ function(find_catch2)
77
if(NOT IS_DIRECTORY ${openPMD_catch_src})
88
message(FATAL_ERROR "Specified directory openPMD_catch_src='${openPMD_catch_src}' does not exist!")
99
endif()
10+
elseif(openPMD_catch_tar)
11+
message(STATUS "Downloading Catch2 ...")
12+
message(STATUS "Catch2 source: ${openPMD_catch_tar}")
1013
elseif(openPMD_USE_INTERNAL_CATCH)
1114
message(STATUS "Downloading Catch2 ...")
1215
message(STATUS "Catch2 repository: ${openPMD_catch_repo} (${openPMD_catch_branch})")
13-
include(FetchContent)
1416
endif()
1517
if(TARGET Catch2::Catch2)
1618
# nothing to do, target already exists in the superbuild
17-
elseif(openPMD_USE_INTERNAL_CATCH OR openPMD_catch_src)
19+
elseif(openPMD_USE_INTERNAL_CATCH OR openPMD_catch_src OR openPMD_catch_tar)
1820
if(openPMD_catch_src)
1921
add_subdirectory(${openPMD_catch_src} _deps/localCatch2-build/)
2022
else()
21-
FetchContent_Declare(fetchedCatch2
22-
GIT_REPOSITORY ${openPMD_catch_repo}
23-
GIT_TAG ${openPMD_catch_branch}
24-
BUILD_IN_SOURCE 0
25-
)
23+
include(FetchContent)
24+
if(openPMD_catch_tar)
25+
FetchContent_Declare(fetchedCatch2
26+
URL ${openPMD_catch_tar}
27+
URL_HASH ${openPMD_catch_tar_hash}
28+
BUILD_IN_SOURCE OFF
29+
)
30+
else()
31+
FetchContent_Declare(fetchedCatch2
32+
GIT_REPOSITORY ${openPMD_catch_repo}
33+
GIT_TAG ${openPMD_catch_branch}
34+
BUILD_IN_SOURCE OFF
35+
)
36+
endif()
2637
FetchContent_MakeAvailable(fetchedCatch2)
2738

2839
# advanced fetch options
@@ -44,6 +55,14 @@ set(openPMD_catch_src ""
4455
CACHE PATH
4556
"Local path to Catch2 source directory (preferred if set)")
4657

58+
# tarball fetcher
59+
set(openPMD_catch_tar "https://github.com/catchorg/Catch2/archive/refs/tags/v2.13.10.tar.gz"
60+
CACHE STRING
61+
"Remote tarball link to pull and build Catch2 from if(openPMD_USE_INTERNAL_CATCH)")
62+
set(openPMD_catch_tar_hash "SHA256=d54a712b7b1d7708bc7a819a8e6e47b2fde9536f487b89ccbca295072a7d9943"
63+
CACHE STRING
64+
"Hash checksum of the tarball of Catch2 if(openPMD_USE_INTERNAL_CATCH)")
65+
4766
# Git fetcher
4867
set(openPMD_catch_repo "https://github.com/catchorg/Catch2.git"
4968
CACHE STRING

cmake/dependencies/json.cmake

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,33 @@ function(find_json)
77
if(NOT IS_DIRECTORY ${openPMD_json_src})
88
message(FATAL_ERROR "Specified directory openPMD_json_src='${openPMD_json_src}' does not exist!")
99
endif()
10+
elseif(openPMD_json_tar)
11+
message(STATUS "Downloading nlohmann_json ...")
12+
message(STATUS "nlohmann_json source: ${openPMD_json_tar}")
1013
elseif(openPMD_USE_INTERNAL_JSON)
1114
message(STATUS "Downloading nlohmann_json ...")
1215
message(STATUS "nlohmann_json repository: ${openPMD_json_repo} (${openPMD_json_branch})")
13-
include(FetchContent)
1416
endif()
1517
if(TARGET nlohmann_json::nlohmann_json)
1618
# nothing to do, target already exists in the superbuild
17-
elseif(openPMD_USE_INTERNAL_JSON OR openPMD_json_src)
19+
elseif(openPMD_USE_INTERNAL_JSON OR openPMD_json_src OR openPMD_json_tar)
1820
if(openPMD_json_src)
1921
add_subdirectory(${openPMD_json_src} _deps/localnlohmann_json-build/)
2022
else()
21-
FetchContent_Declare(fetchednlohmann_json
22-
GIT_REPOSITORY ${openPMD_json_repo}
23-
GIT_TAG ${openPMD_json_branch}
24-
BUILD_IN_SOURCE 0
25-
)
23+
include(FetchContent)
24+
if(openPMD_json_tar)
25+
FetchContent_Declare(fetchednlohmann_json
26+
URL ${openPMD_json_tar}
27+
URL_HASH ${openPMD_json_tar_hash}
28+
BUILD_IN_SOURCE OFF
29+
)
30+
else()
31+
FetchContent_Declare(fetchednlohmann_json
32+
GIT_REPOSITORY ${openPMD_json_repo}
33+
GIT_TAG ${openPMD_json_branch}
34+
BUILD_IN_SOURCE OFF
35+
)
36+
endif()
2637
FetchContent_MakeAvailable(fetchednlohmann_json)
2738

2839
# advanced fetch options
@@ -44,6 +55,14 @@ set(openPMD_json_src ""
4455
CACHE PATH
4556
"Local path to nlohmann_json source directory (preferred if set)")
4657

58+
# tarball fetcher
59+
set(openPMD_json_tar "https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz"
60+
CACHE STRING
61+
"Remote tarball link to pull and build nlohmann_json from if(openPMD_USE_INTERNAL_JSON)")
62+
set(openPMD_json_tar_hash "SHA256=0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406"
63+
CACHE STRING
64+
"Hash checksum of the tarball of nlohmann_json if(openPMD_USE_INTERNAL_JSON)")
65+
4766
# Git fetcher
4867
set(openPMD_json_repo "https://github.com/nlohmann/json.git"
4968
CACHE STRING

cmake/dependencies/pybind11.cmake

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,33 @@ function(find_pybind11)
77
if(NOT IS_DIRECTORY ${openPMD_pybind11_src})
88
message(FATAL_ERROR "Specified directory openPMD_pybind11_src='${openPMD_pybind11_src}' does not exist!")
99
endif()
10+
elseif(openPMD_pybind11_tar)
11+
message(STATUS "Downloading pybind11 ...")
12+
message(STATUS "pybind11 source: ${openPMD_pybind11_tar}")
1013
elseif(openPMD_USE_INTERNAL_PYBIND11)
1114
message(STATUS "Downloading pybind11 ...")
1215
message(STATUS "pybind11 repository: ${openPMD_pybind11_repo} (${openPMD_pybind11_branch})")
13-
include(FetchContent)
1416
endif()
1517
if(TARGET pybind11::module)
1618
# nothing to do, target already exists in the superbuild
1719
elseif(openPMD_USE_INTERNAL_PYBIND11 OR openPMD_pybind11_src)
1820
if(openPMD_pybind11_src)
1921
add_subdirectory(${openPMD_pybind11_src} _deps/localpybind11-build/)
2022
else()
21-
FetchContent_Declare(fetchedpybind11
22-
GIT_REPOSITORY ${openPMD_pybind11_repo}
23-
GIT_TAG ${openPMD_pybind11_branch}
24-
BUILD_IN_SOURCE 0
25-
)
23+
include(FetchContent)
24+
if(openPMD_pybind11_tar)
25+
FetchContent_Declare(fetchedpybind11
26+
URL ${openPMD_pybind11_tar}
27+
URL_HASH ${openPMD_pybind11_tar_hash}
28+
BUILD_IN_SOURCE OFF
29+
)
30+
else()
31+
FetchContent_Declare(fetchedpybind11
32+
GIT_REPOSITORY ${openPMD_pybind11_repo}
33+
GIT_TAG ${openPMD_pybind11_branch}
34+
BUILD_IN_SOURCE OFF
35+
)
36+
endif()
2637
FetchContent_MakeAvailable(fetchedpybind11)
2738

2839
# advanced fetch options
@@ -50,6 +61,14 @@ set(openPMD_pybind11_src ""
5061
CACHE PATH
5162
"Local path to pybind11 source directory (preferred if set)")
5263

64+
# tarball fetcher
65+
set(openPMD_pybind11_tar "https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.tar.gz"
66+
CACHE STRING
67+
"Remote tarball link to pull and build pybind11 from if(openPMD_USE_INTERNAL_PYBIND11)")
68+
set(openPMD_pybind11_tar_hash "SHA256=bf8f242abd1abcd375d516a7067490fb71abd79519a282d22b6e4d19282185a7"
69+
CACHE STRING
70+
"Hash checksum of the tarball of pybind11 if(openPMD_USE_INTERNAL_PYBIND11)")
71+
5372
# Git fetcher
5473
set(openPMD_pybind11_repo "https://github.com/pybind/pybind11.git"
5574
CACHE STRING

cmake/dependencies/toml11.cmake

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,33 @@ function(find_toml11)
77
if(NOT IS_DIRECTORY ${openPMD_toml11_src})
88
message(FATAL_ERROR "Specified directory openPMD_toml11_src='${openPMD_toml11_src}' does not exist!")
99
endif()
10+
elseif(openPMD_toml11_tar)
11+
message(STATUS "Downloading toml11 ...")
12+
message(STATUS "toml11 source: ${openPMD_toml11_tar}")
1013
elseif(openPMD_USE_INTERNAL_TOML11)
1114
message(STATUS "Downloading toml11 ...")
1215
message(STATUS "toml11 repository: ${openPMD_toml11_repo} (${openPMD_toml11_branch})")
13-
include(FetchContent)
1416
endif()
1517
if(TARGET toml11::toml11)
1618
# nothing to do, target already exists in the superbuild
1719
elseif(openPMD_USE_INTERNAL_TOML11 OR openPMD_toml11_src)
1820
if(openPMD_toml11_src)
1921
add_subdirectory(${openPMD_toml11_src} _deps/localtoml11-build/)
2022
else()
21-
FetchContent_Declare(fetchedtoml11
22-
GIT_REPOSITORY ${openPMD_toml11_repo}
23-
GIT_TAG ${openPMD_toml11_branch}
24-
BUILD_IN_SOURCE 0
25-
)
23+
include(FetchContent)
24+
if(openPMD_toml11_tar)
25+
FetchContent_Declare(fetchedtoml11
26+
URL ${openPMD_toml11_tar}
27+
URL_HASH ${openPMD_toml11_tar_hash}
28+
BUILD_IN_SOURCE OFF
29+
)
30+
else()
31+
FetchContent_Declare(fetchedtoml11
32+
GIT_REPOSITORY ${openPMD_toml11_repo}
33+
GIT_TAG ${openPMD_toml11_branch}
34+
BUILD_IN_SOURCE OFF
35+
)
36+
endif()
2637
FetchContent_MakeAvailable(fetchedtoml11)
2738

2839
# advanced fetch options
@@ -52,6 +63,14 @@ set(openPMD_toml11_src ""
5263
CACHE PATH
5364
"Local path to toml11 source directory (preferred if set)")
5465

66+
# tarball fetcher
67+
set(openPMD_toml11_tar "https://github.com/ToruNiina/toml11/archive/refs/tags/v4.2.0.tar.gz"
68+
CACHE STRING
69+
"Remote tarball link to pull and build toml11 from if(openPMD_USE_INTERNAL_TOML11)")
70+
set(openPMD_toml11_tar_hash "SHA256=9287971cd4a1a3992ef37e7b95a3972d1ae56410e7f8e3f300727ab1d6c79c2c"
71+
CACHE STRING
72+
"Hash checksum of the tarball of toml11 if(openPMD_USE_INTERNAL_TOML11)")
73+
5574
# Git fetcher
5675
set(openPMD_toml11_repo "https://github.com/ToruNiina/toml11.git"
5776
CACHE STRING

docs/source/dev/buildoptions.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,34 @@ Developers can also use a local copy of the source directories or control the ex
8080
CMake Option Default & Values Description
8181
============================= ============================================== ===========================================================
8282
``openPMD_catch_src`` *None* Path to Catch2 source directory (preferred if set)
83+
``openPMD_catch_tar`` *we set and maintain a compatible version* Remote tarball link to pull and build Catch2 from
84+
``openPMD_catch_tar_hash`` *we set and maintain a compatible version* Hash checksum of the tarball of Catch2
8385
``openPMD_catch_repo`` ``https://github.com/catchorg/Catch2.git`` Repository URI to pull and build Catch2 from
8486
``openPMD_catch_branch`` *we set and maintain a compatible commit* Repository branch for ``openPMD_catch_repo``
8587
``openPMD_pybind11_src`` *None* Path to pybind11 source directory (preferred if set)
88+
``openPMD_pybind11_tar`` *we set and maintain a compatible version* Remote tarball link to pull and build pybind11 from
89+
``openPMD_pybind11_tar_hash`` *we set and maintain a compatible version* Hash checksum of the tarball of pybind11
8690
``openPMD_pybind11_repo`` ``https://github.com/pybind/pybind11.git`` Repository URI to pull and build pybind11 from
8791
``openPMD_pybind11_branch`` *we set and maintain a compatible commit* Repository branch for ``openPMD_pybind11_repo``
8892
``openPMD_json_src`` *None* Path to NLohmann JSON source directory (preferred if set)
93+
``openPMD_json_tar`` *we set and maintain a compatible version* Remote tarball link to pull and build NLohmann JSON from
94+
``openPMD_json_tar_hash`` *we set and maintain a compatible version* Hash checksum of the tarball of NLohmann JSON
8995
``openPMD_json_repo`` ``https://github.com/nlohmann/json.git`` Repository URI to pull and build NLohmann JSON from
9096
``openPMD_json_branch`` *we set and maintain a compatible commit* Repository branch for ``openPMD_json_repo``
9197
``openPMD_toml11_src`` *None* Path to TOML11 source directory (preferred if set)
98+
``openPMD_toml11_tar`` *we set and maintain a compatible version* Remote tarball link to pull and build TOML11 from
99+
``openPMD_toml11_tar_hash`` *we set and maintain a compatible version* Hash checksum of the tarball of TOML11
92100
``openPMD_toml11_repo`` ``https://github.com/ToruNiina/toml11.git`` Repository URI to pull and build TOML11 from
93101
``openPMD_toml11_branch`` *we set and maintain a compatible commit* Repository branch for ``openPMD_toml11_repo``
94102
============================= ============================================== ===========================================================
95103

104+
The precedence for these options is:
105+
106+
#. existing targets found in a superbuild (from another project)
107+
#. ``_src`` is specified
108+
#. ``_tar`` is specified
109+
#. ``_repo`` + ``_branch`` are specified
110+
96111

97112
Tests, Examples and Command Line Tools
98113
--------------------------------------

0 commit comments

Comments
 (0)