11function (find_pybind11)
22 if (TARGET pybind11::module)
33 message (STATUS "pybind11::module target already imported" )
4- elseif (pyAMReX_pybind11_src)
5- message (STATUS "Compiling local pybind11 ..." )
6- message (STATUS "pybind11 source path: ${pyAMReX_pybind11_src} " )
7- if (NOT IS_DIRECTORY ${pyAMReX_pybind11_src} )
8- message (FATAL_ERROR "Specified directory pyAMReX_pybind11_src='${pyAMReX_pybind11_src} ' does not exist!" )
9- endif ()
104 elseif (pyAMReX_pybind11_internal)
11- message (STATUS "Downloading pybind11 ..." )
12- message (STATUS "pybind11 repository: ${pyAMReX_pybind11_repo} (${pyAMReX_pybind11_branch} )" )
13- include (FetchContent)
5+ if (pyAMReX_pybind11_src)
6+ message (STATUS "Compiling local pybind11 ..." )
7+ message (STATUS "pybind11 source path: ${pyAMReX_pybind11_src} " )
8+ if (NOT IS_DIRECTORY ${pyAMReX_pybind11_src} )
9+ message (FATAL_ERROR "Specified directory pyAMReX_pybind11_src='${pyAMReX_pybind11_src} ' does not exist!" )
10+ endif ()
11+ elseif (pyAMReX_pybind11_tar)
12+ message (STATUS "Downloading pybind11 ..." )
13+ message (STATUS "pybind11 source: ${pyAMReX_pybind11_tar} " )
14+ elseif (pyAMReX_pybind11_branch)
15+ message (STATUS "Downloading pybind11 ..." )
16+ message (STATUS "pybind11 repository: ${pyAMReX_pybind11_repo} (${pyAMReX_pybind11_branch} )" )
17+ include (FetchContent)
18+ endif ()
1419 endif ()
1520 if (TARGET pybind11::module)
1621 # nothing to do, target already exists in the superbuild
17- elseif (pyAMReX_pybind11_internal OR pyAMReX_pybind11_src )
22+ elseif (pyAMReX_pybind11_internal)
1823 set (CMAKE_POLICY_DEFAULT_CMP0077 NEW)
1924
2025 if (pyAMReX_pybind11_src)
2126 add_subdirectory (${pyAMReX_pybind11_src} _deps/localpybind11-build /)
2227 else ()
23- FetchContent_Declare(fetchedpybind11
24- GIT_REPOSITORY ${pyAMReX_pybind11_repo}
25- GIT_TAG ${pyAMReX_pybind11_branch}
26- BUILD_IN_SOURCE 0
27- )
28+ include (FetchContent)
29+ if (pyAMReX_pybind11_tar)
30+ FetchContent_Declare(fetchedpybind11
31+ URL ${pyAMReX_pybind11_tar}
32+ URL_HASH ${pyAMReX_pybind11_tar_hash}
33+ BUILD_IN_SOURCE OFF
34+ )
35+ else ()
36+ FetchContent_Declare(fetchedpybind11
37+ GIT_REPOSITORY ${pyAMReX_pybind11_repo}
38+ GIT_TAG ${pyAMReX_pybind11_branch}
39+ BUILD_IN_SOURCE 0
40+ )
41+ endif ()
2842 FetchContent_MakeAvailable(fetchedpybind11)
2943
3044 # advanced fetch options
@@ -41,13 +55,22 @@ function(find_pybind11)
4155 endif ()
4256endfunction ()
4357
58+ option (pyAMReX_pybind11_internal "Download & build pybind11" ${pyAMReX_SUPERBUILD} )
59+
4460# local source-tree
4561set (pyAMReX_pybind11_src ""
4662 CACHE PATH
4763 "Local path to pybind11 source directory (preferred if set)" )
4864
65+ # tarball fetcher
66+ set (pyAMReX_pybind11_tar "https://github.com/pybind/pybind11/archive/refs/tags/v2.13.6.tar.gz"
67+ CACHE STRING
68+ "Remote tarball link to pull and build pybind11 from if(pyAMReX_pybind11_internal)" )
69+ set (pyAMReX_pybind11_tar_hash "SHA256=e08cb87f4773da97fa7b5f035de8763abc656d87d5773e62f6da0587d1f0ec20"
70+ CACHE STRING
71+ "Hash checksum of the tarball of pybind11 if(pyAMReX_pybind11_internal)" )
72+
4973# Git fetcher
50- option (pyAMReX_pybind11_internal "Download & build pybind11" ON )
5174set (pyAMReX_pybind11_repo "https://github.com/pybind/pybind11.git"
5275 CACHE STRING
5376 "Repository URI to pull and build pybind11 from if(pyAMReX_pybind11_internal)" )
0 commit comments