diff --git a/.gitmodules b/.gitmodules index b851cbc2f66..8aaf27b1c93 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "utils/kokkos-kernels"] path = utils/kokkos-kernels url = https://github.com/kokkos/kokkos-kernels.git +[submodule "utils/pybind11"] + path = utils/pybind11 + url = https://github.com/pybind/pybind11.git diff --git a/CHANGELOG.md b/CHANGELOG.md index d9167046b71..607c5a92104 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Changed (changing behavior/API/variables/...) ### Infrastructure (changes irrelevant to downstream codes) +- [[PR653]](https://github.com/lanl/singularity-eos/pull/653) Move pybind11 to a submodule rather than fetching it via cmake fetchcontent ### Deprecated (soon to be removed behavior/API/variables/...) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18e9c4cc011..bdffedefef6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,6 +183,7 @@ include(singularity-eos/hdf5) include(singularity-eos/kokkos) include(singularity-eos/spiner) include(singularity-eos/ports-of-call) +include(singularity-eos/pybind11) add_library(singularity-eos INTERFACE) add_library(singularity-eos::singularity-eos ALIAS singularity-eos) @@ -294,6 +295,10 @@ endif() # Must happen before building singularity-utils (which needs ports-of-call and spiner) # Dependency order: Kokkos -> ports-of-call -> spiner -> singularity-utils +if (SINGULARITY_BUILD_PYTHON) + find_package(Python COMPONENTS Interpreter Development REQUIRED) +endif() + if(SINGULARITY_SUBMODULE_MODE) # add all submodules message(STATUS "singularity-eos configuring in submodule mode.") @@ -318,6 +323,11 @@ if(SINGULARITY_SUBMODULE_MODE) if(SINGULARITY_USE_EIGEN) singularity_import_eigen() endif() + + # And pybind11 (if needed) + if (SINGULARITY_BUILD_PYTHON) + singularity_import_pybind11() + endif() else() # use system packages @@ -341,6 +351,11 @@ else() if(SINGULARITY_USE_EIGEN) singularity_find_eigen() endif() + + # And pybind11 (if needed) + if (SINGULARITY_BUILD_PYTHON) + singularity_find_pybind11() + endif() endif() # Build singularity-utils first - it's a dependency for both diff --git a/cmake/singularity-eos/pybind11.cmake b/cmake/singularity-eos/pybind11.cmake new file mode 100644 index 00000000000..ead61353008 --- /dev/null +++ b/cmake/singularity-eos/pybind11.cmake @@ -0,0 +1,24 @@ +# ------------------------------------------------------------------------------# +# © 2026. Triad National Security, LLC. All rights reserved. This program +# was produced under U.S. Government contract 89233218CNA000001 for Los Alamos +# National Laboratory (LANL), which is operated by Triad National Security, LLC +# for the U.S. Department of Energy/National Nuclear Security Administration. +# All rights in the program are reserved by Triad National Security, LLC, and +# the U.S. Department of Energy/National Nuclear Security Administration. The +# Government is granted for itself and others acting on its behalf a +# nonexclusive, paid-up, irrevocable worldwide license in this material to +# reproduce, prepare derivative works, distribute copies to the public, perform +# publicly and display publicly, and to permit others to do so. +# ------------------------------------------------------------------------------# + +macro(singularity_import_pybind11) + if(NOT TARGET pybind11::headers) + message(STATUS "Using pybind11 submodule") + add_subdirectory(utils/pybind11) + endif() +endmacro() + +macro(singularity_find_pybind11) + message(STATUS "Searching for system pybind11") + find_package(pybind11 REQUIRED) +endmacro() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index a47517741f8..d3ae70bfda1 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,19 +1,15 @@ -find_package(Python COMPONENTS Interpreter Development REQUIRED) -find_package(pybind11 CONFIG QUIET) - -if(NOT pybind11_FOUND) - message(STATUS "No pybind11 installation found, fetching from GitHub.") - include(FetchContent) - FetchContent_Declare(pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11 - GIT_TAG v2.9.2 - ) - FetchContent_GetProperties(pybind11) - if(NOT pybind11_POPULATED) - FetchContent_Populate(pybind11) - add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR}) - endif() -endif() +# ------------------------------------------------------------------------------# +# © 2022-2026. Triad National Security, LLC. All rights reserved. This program +# was produced under U.S. Government contract 89233218CNA000001 for Los Alamos +# National Laboratory (LANL), which is operated by Triad National Security, LLC +# for the U.S. Department of Energy/National Nuclear Security Administration. +# All rights in the program are reserved by Triad National Security, LLC, and +# the U.S. Department of Energy/National Nuclear Security Administration. The +# Government is granted for itself and others acting on its behalf a +# nonexclusive, paid-up, irrevocable worldwide license in this material to +# reproduce, prepare derivative works, distribute copies to the public, perform +# publicly and display publicly, and to permit others to do so. +# ------------------------------------------------------------------------------# pybind11_add_module(singularity_eos module.cpp diff --git a/utils/pybind11 b/utils/pybind11 new file mode 160000 index 00000000000..d03662f0984 --- /dev/null +++ b/utils/pybind11 @@ -0,0 +1 @@ +Subproject commit d03662f0984f652b60e7ddce53d3868002275197