Skip to content

Commit

Permalink
CMake Superbuild: Tarball
Browse files Browse the repository at this point in the history
Cloning whole repos can be quite slow and CMake does not support
shallow clones yet. We can use release tarballs instead.
  • Loading branch information
ax3l committed Sep 6, 2024
1 parent c6a70cb commit 83e2b03
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ include(${openPMD_SOURCE_DIR}/cmake/openPMDFunctions.cmake)

# CMake policies ##############################################################
#
# not needed right now
# CMake 3.24+ tarball download robustness
# https://cmake.org/cmake/help/latest/module/ExternalProject.html#url
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()


# No in-Source builds #########################################################
Expand Down Expand Up @@ -566,14 +570,8 @@ if(openPMD_HAVE_PYTHON)
endif()
endif()
message(STATUS "Python LTO/IPO: ${_USE_PY_LTO}")
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
set_target_properties(openPMD.py PROPERTIES
INTERPROCEDURAL_OPTIMIZATION ${_USE_PY_LTO})
else()
if(_USE_PY_LTO)
target_link_libraries(openPMD.py PRIVATE pybind11::lto)
endif()
endif()
set_target_properties(openPMD.py PROPERTIES
INTERPROCEDURAL_OPTIMIZATION ${_USE_PY_LTO})
unset(_USE_PY_LTO)

if(EMSCRIPTEN)
Expand Down
33 changes: 26 additions & 7 deletions cmake/dependencies/json.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,33 @@ function(find_json)
if(NOT IS_DIRECTORY ${openPMD_json_src})
message(FATAL_ERROR "Specified directory openPMD_json_src='${openPMD_json_src}' does not exist!")
endif()
elseif(openPMD_json_tar)
message(STATUS "Downloading nlohmann_json ...")
message(STATUS "nlohmann_json source: ${openPMD_json_tar}")
elseif(openPMD_USE_INTERNAL_JSON)
message(STATUS "Downloading nlohmann_json ...")
message(STATUS "nlohmann_json repository: ${openPMD_json_repo} (${openPMD_json_branch})")
include(FetchContent)
endif()
if(TARGET nlohmann_json::nlohmann_json)
# nothing to do, target already exists in the superbuild
elseif(openPMD_USE_INTERNAL_JSON OR openPMD_json_src)
elseif(openPMD_USE_INTERNAL_JSON OR openPMD_json_src OR openPMD_json_tar)
if(openPMD_json_src)
add_subdirectory(${openPMD_json_src} _deps/localnlohmann_json-build/)
else()
FetchContent_Declare(fetchednlohmann_json
GIT_REPOSITORY ${openPMD_json_repo}
GIT_TAG ${openPMD_json_branch}
BUILD_IN_SOURCE 0
)
include(FetchContent)
if(openPMD_json_tar)
FetchContent_Declare(fetchednlohmann_json
URL ${openPMD_json_tar}
URL_HASH ${openPMD_json_tar_hash}
BUILD_IN_SOURCE 0
)
else()
FetchContent_Declare(fetchednlohmann_json
GIT_REPOSITORY ${openPMD_json_repo}
GIT_TAG ${openPMD_json_branch}
BUILD_IN_SOURCE 0
)
endif()
FetchContent_MakeAvailable(fetchednlohmann_json)

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

# tarball fetcher
set(openPMD_json_tar "https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz"
CACHE STRING
"Remote tarball link link to pull and build nlohmann_json from if(openPMD_USE_INTERNAL_JSON)")
set(openPMD_json_tar_hash "SHA256=0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406"
CACHE STRING
"Remote tarball link link to pull and build nlohmann_json from if(openPMD_USE_INTERNAL_JSON)")

# Git fetcher
set(openPMD_json_repo "https://github.com/nlohmann/json.git"
CACHE STRING
Expand Down

0 comments on commit 83e2b03

Please sign in to comment.