|
| 1 | +## ------------------------------------------------------- |
| 2 | +## |
| 3 | +## SHAMROCK code for hydrodynamics |
| 4 | +## Copyright (c) 2021-2024 Timothée David--Cléris <[email protected]> |
| 5 | +## SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1 |
| 6 | +## Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information |
| 7 | +## |
| 8 | +## ------------------------------------------------------- |
| 9 | + |
| 10 | +############################################################################### |
| 11 | +### test git submodules |
| 12 | +############################################################################### |
| 13 | + |
| 14 | +function(_git_submod_is_empty directory) |
| 15 | + file(GLOB files RELATIVE "${directory}" "${directory}/*") |
| 16 | + if(NOT files) |
| 17 | + |
| 18 | + message(FATAL_ERROR |
| 19 | + "The git submodule '${directory}' is empty\n" |
| 20 | + "please do : git submodule update --init --recursive\n" |
| 21 | + ) |
| 22 | + |
| 23 | + endif() |
| 24 | + message(STATUS "The subdirectory '${directory}' contains ${files}") |
| 25 | +endfunction() |
| 26 | + |
| 27 | +_git_submod_is_empty(${CMAKE_CURRENT_SOURCE_DIR}/external/pybind11) |
| 28 | + |
| 29 | +############################################################################### |
| 30 | +### pybind11 |
| 31 | +############################################################################### |
| 32 | +option(SHAMROCK_EXTERNAL_PYBIND11 "use pybind11 lib from the host system" Off) |
| 33 | + |
| 34 | +if(SHAMROCK_EXTERNAL_PYBIND11) |
| 35 | + message(STATUS "Using system pybind11") |
| 36 | + find_package(pybind11 REQUIRED) |
| 37 | +else() |
| 38 | + message(STATUS "Using git submodule pybind11") |
| 39 | + add_subdirectory(external/pybind11) |
| 40 | +endif() |
| 41 | + |
| 42 | +############################################################################### |
| 43 | +### fmt |
| 44 | +############################################################################### |
| 45 | + |
| 46 | +option(SHAMROCK_EXTERNAL_FMTLIB "use fmt lib from the host system" Off) |
| 47 | + |
| 48 | +# LEGACY variable |
| 49 | +if(DEFINED USE_SYSTEM_FMTLIB) |
| 50 | + set(SHAMROCK_EXTERNAL_FMTLIB ${USE_SYSTEM_FMTLIB}) |
| 51 | +endif() |
| 52 | + |
| 53 | +if(NOT SHAMROCK_EXTERNAL_FMTLIB) |
| 54 | + message(STATUS "Using git submodule fmtlib") |
| 55 | + |
| 56 | + option(USE_MANUAL_FMTLIB "Bypass fmt cmake integration" Off) |
| 57 | + |
| 58 | + if(USE_MANUAL_FMTLIB) |
| 59 | + # Completely bypass fmt cmake integration |
| 60 | + # This is sketchy but allows the inclusion of fmt wihout ever having to compile it |
| 61 | + # this solved issue on latest macos |
| 62 | + # on Christiano's laptop (that were due to anaconda, of course ...) |
| 63 | + message(STATUS "You are bypassing fmt cmake integration use it at your own risks !") |
| 64 | + message(STATUS "Manual inclusion path ${CMAKE_CURRENT_LIST_DIR}/external/fmt/include") |
| 65 | + add_library(fmt-header-only INTERFACE) |
| 66 | + add_library(fmt::fmt-header-only ALIAS fmt-header-only) |
| 67 | + target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1) |
| 68 | + target_compile_features(fmt-header-only INTERFACE cxx_std_11) |
| 69 | + target_include_directories(fmt-header-only |
| 70 | + BEFORE INTERFACE |
| 71 | + ${CMAKE_CURRENT_LIST_DIR}external//fmt/include |
| 72 | + ) |
| 73 | + else() |
| 74 | + add_subdirectory(external/fmt) |
| 75 | + endif() |
| 76 | +else() |
| 77 | + message(STATUS "Using system fmtlib") |
| 78 | + find_package(fmt REQUIRED) |
| 79 | +endif() |
| 80 | + |
| 81 | +############################################################################### |
| 82 | +### NVTX |
| 83 | +############################################################################### |
| 84 | + |
| 85 | +if(SHAMROCK_USE_NVTX) |
| 86 | + #include(NVTX/c/nvtxImportedTargets.cmake) |
| 87 | + add_subdirectory(external/NVTX/c) |
| 88 | +endif() |
| 89 | + |
| 90 | +############################################################################### |
| 91 | +### nlohmann_json |
| 92 | +############################################################################### |
| 93 | + |
| 94 | +if(SHAMROCK_EXTERNAL_JSON) |
| 95 | + find_package(nlohmann_json 3.11.3 REQUIRED) |
| 96 | +else() |
| 97 | + set(JSON_BuildTests OFF CACHE INTERNAL "") |
| 98 | + add_subdirectory(external/nlohmann_json) |
| 99 | +endif() |
| 100 | + |
| 101 | +############################################################################### |
| 102 | +### plf_nanotimer |
| 103 | +############################################################################### |
| 104 | + |
| 105 | +include_directories(external/plf_nanotimer) |
0 commit comments