From 951578d64d71e983d795e56b3530419358add353 Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 5 Sep 2024 16:31:39 +0200 Subject: [PATCH] simpler dep handling + versions (#887) --- res/cmake/dep.cmake | 18 ++++++++++++++++++ res/cmake/dep/caliper.cmake | 11 +---------- res/cmake/dep/cppdict.cmake | 12 ++---------- res/cmake/dep/highfive.cmake | 13 ++----------- res/cmake/dep/phlop.cmake | 14 +------------- res/cmake/dep/pybind.cmake | 12 ++---------- res/cmake/dep/samrai.cmake | 12 ++---------- 7 files changed, 28 insertions(+), 64 deletions(-) diff --git a/res/cmake/dep.cmake b/res/cmake/dep.cmake index aa7f1de55..803634af3 100644 --- a/res/cmake/dep.cmake +++ b/res/cmake/dep.cmake @@ -1,4 +1,22 @@ + +function(phare_git_get_or_update name dir url branch) + if (NOT EXISTS ${dir}) + execute_process( + COMMAND ${Git} clone ${url} ${dir} -b ${branch} --recursive --depth 1 --shallow-submodules + ) + else() + if(devMode) + message("downloading latest ${name} updates") + execute_process(COMMAND ${Git} pull origin ${branch} WORKING_DIRECTORY ${dir}) + endif(devMode) + endif() +endfunction(phare_git_get_or_update) + +function(phare_github_get_or_update name dir repo branch) + phare_git_get_or_update(${name} ${dir} https://github.com/${repo} ${branch}) +endfunction(phare_github_get_or_update) + include("${PHARE_PROJECT_DIR}/res/cmake/dep/cppdict.cmake") add_subdirectory(subprojects/cppdict) diff --git a/res/cmake/dep/caliper.cmake b/res/cmake/dep/caliper.cmake index 2bf270920..bb50b4068 100644 --- a/res/cmake/dep/caliper.cmake +++ b/res/cmake/dep/caliper.cmake @@ -18,16 +18,7 @@ if (withCaliper) set(CALIPER_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/caliper) set(CALIPER_BIN ${CMAKE_CURRENT_BINARY_DIR}/subprojects/caliper) - if (NOT EXISTS ${CALIPER_SRCDIR}) - execute_process( - COMMAND ${Git} clone https://github.com/LLNL/Caliper ${CALIPER_SRCDIR} -b master --recursive --depth 10 - ) - else() - if(devMode) - message("downloading latest Caliper updates") - execute_process(COMMAND ${Git} pull origin master WORKING_DIRECTORY ${CALIPER_SRCDIR}) - endif(devMode) - endif() + phare_github_get_or_update(Caliper ${CALIPER_SRCDIR} LLNL/Caliper master) option(CALIPER_OPTION_PREFIX ON) set(CALIPER_OPTION_PREFIX ON) diff --git a/res/cmake/dep/cppdict.cmake b/res/cmake/dep/cppdict.cmake index c471a5043..44b5fdedc 100644 --- a/res/cmake/dep/cppdict.cmake +++ b/res/cmake/dep/cppdict.cmake @@ -1,14 +1,6 @@ set(CPPDICT_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/cppdict) +set(CPPDICT_VERSION master) +phare_github_get_or_update(cppdict ${CPPDICT_SRCDIR} LaboratoryOfPlasmaPhysics/cppdict ${CPPDICT_VERSION}) -if (NOT EXISTS ${CPPDICT_SRCDIR}) - execute_process( - COMMAND ${Git} clone https://github.com/LaboratoryOfPlasmaPhysics/cppdict ${CPPDICT_SRCDIR} -b master --recursive --depth 10 - ) -else() - if(devMode) - message("downloading latest cppdict updates") - execute_process(COMMAND ${Git} pull origin master WORKING_DIRECTORY ${CPPDICT_SRCDIR}) - endif(devMode) -endif() diff --git a/res/cmake/dep/highfive.cmake b/res/cmake/dep/highfive.cmake index f27778169..b74081c68 100644 --- a/res/cmake/dep/highfive.cmake +++ b/res/cmake/dep/highfive.cmake @@ -4,18 +4,9 @@ set (PHARE_HAS_HIGHFIVE "0") if(HighFive) set (HIGHFIVE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/highfive) + set (HIGHFIVE_VERSION master) - if (NOT EXISTS ${HIGHFIVE_SRC}) - execute_process( - COMMAND ${Git} clone https://github.com/BlueBrain/HighFive ${HIGHFIVE_SRC} -b master --depth 1 - ) - - else() - if(devMode) - message("downloading latest HighFive updates") - execute_process(COMMAND ${Git} pull origin master WORKING_DIRECTORY ${HIGHFIVE_SRC}) - endif(devMode) - endif() + phare_github_get_or_update(HighFive ${HIGHFIVE_SRC} BlueBrain/HighFive ${HIGHFIVE_VERSION}) include_directories( ${HIGHFIVE_SRC}/include diff --git a/res/cmake/dep/phlop.cmake b/res/cmake/dep/phlop.cmake index 431f94e51..0ab992705 100644 --- a/res/cmake/dep/phlop.cmake +++ b/res/cmake/dep/phlop.cmake @@ -2,19 +2,7 @@ if (withPhlop) set(PHLOP_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/phlop) - - if (NOT EXISTS ${PHLOP_SRCDIR}) - execute_process( - COMMAND ${Git} clone https://github.com/PhilipDeegan/phlop ${PHLOP_SRCDIR} -b master --recursive --depth 1 - ) - else() - if(devMode) - message("downloading latest phlop updates") - execute_process(COMMAND ${Git} pull origin master WORKING_DIRECTORY ${PHLOP_SRCDIR}) - endif(devMode) - endif() - + phare_github_get_or_update(phlop ${PHLOP_SRCDIR} PhilipDeegan/phlop master) include_directories(${PHLOP_SRCDIR}/inc) endif(withPhlop) - diff --git a/res/cmake/dep/pybind.cmake b/res/cmake/dep/pybind.cmake index 3f09f2de8..fb2e90135 100644 --- a/res/cmake/dep/pybind.cmake +++ b/res/cmake/dep/pybind.cmake @@ -11,17 +11,9 @@ function(get_pybind) message("downloading subproject pybind11") set(PYBIND11_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/pybind11) + set(PYBIND11_VERSION master) - if (NOT EXISTS ${PYBIND11_SRCDIR}) - execute_process( - COMMAND ${Git} clone https://github.com/pybind/pybind11 ${PYBIND11_SRCDIR} --depth 1 -b master - ) - else() - if(devMode) - message("downloading latest pybind11 updates") - execute_process(COMMAND ${Git} pull origin master WORKING_DIRECTORY ${PYBIND11_SRCDIR}) - endif(devMode) - endif() + phare_github_get_or_update(pybind11 ${PYBIND11_SRCDIR} pybind/pybind11 ${PYBIND11_VERSION}) add_subdirectory(${PYBIND11_SRCDIR}) diff --git a/res/cmake/dep/samrai.cmake b/res/cmake/dep/samrai.cmake index 7d53ee0db..d4cc3354f 100644 --- a/res/cmake/dep/samrai.cmake +++ b/res/cmake/dep/samrai.cmake @@ -10,19 +10,11 @@ if (NOT SAMRAI_FOUND) if(DEFINED SAMRAI_ROOT) find_package(SAMRAI PATHS ${SAMRAI_ROOT} REQUIRED) else() + set(SAMRAI_VERSION develop) set(SAMRAI_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/samrai) set(SAMRAI_BIN ${CMAKE_CURRENT_BINARY_DIR}/subprojects/samrai) - if (NOT EXISTS ${SAMRAI_SRCDIR}) - execute_process( - COMMAND ${Git} clone https://github.com/LLNL/SAMRAI ${SAMRAI_SRCDIR} -b develop --recursive --depth 10 - ) - else() - if(devMode) - message("downloading latest SAMRAI updates") - execute_process(COMMAND ${Git} pull origin master WORKING_DIRECTORY ${SAMRAI_SRCDIR}) - endif(devMode) - endif() + phare_github_get_or_update(SAMRAI ${SAMRAI_SRCDIR} LLNL/SAMRAI ${SAMRAI_VERSION}) if (NOT CMAKE_BUILD_TYPE STREQUAL "Release") # enable samrai assertions if not in release mode