Skip to content

Commit 711d587

Browse files
committed
fallback to fetchcontent if nanobind 2.5.0 is not found.
we mimic the upstream behavior, but using fetchcontent instead of submodules
1 parent 10fcf21 commit 711d587

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

CMakeLists.txt

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,21 @@ endif()
2828
jrl_find_package(Eigen3 CONFIG REQUIRED)
2929

3030
jrl_find_python(3.8 REQUIRED COMPONENTS Interpreter Development.Module)
31-
jrl_find_nanobind(2.5.0 CONFIG REQUIRED)
31+
jrl_find_nanobind(2.5.0 CONFIG QUIET)
32+
33+
# On Ubuntu 24.04, the nanobind-dev package ships nanobind 1.9.2.
34+
# We require >=2.5.0 for nanobind_add_stub,
35+
# NB_SUPPRESS_WARNINGS, and visitor pattern (c++)
36+
if(NOT nanobind_FOUND)
37+
include(FetchContent)
38+
FetchContent_Declare(
39+
nanobind
40+
GIT_REPOSITORY https://github.com/wjakob/nanobind.git
41+
GIT_TAG v2.10.1
42+
GIT_SHALLOW True
43+
)
44+
FetchContent_MakeAvailable(nanobind)
45+
endif()
3246

3347
if(BUILD_WITH_CHOLMOD_SUPPORT)
3448
jrl_find_package(CHOLMOD CONFIG REQUIRED)
@@ -167,16 +181,14 @@ if(BUILD_WITH_ACCELERATE_SUPPORT AND APPLE)
167181
target_compile_definitions(nanoeigenpy PRIVATE NANOEIGENPY_HAS_ACCELERATE)
168182
endif()
169183

170-
if(COMMAND nanobind_add_stub)
171-
nanobind_add_stub(
172-
nanoeigenpy_stub
173-
VERBOSE
174-
MODULE nanoeigenpy
175-
OUTPUT ${CMAKE_BINARY_DIR}/lib/site-packages/nanoeigenpy.pyi
176-
PYTHON_PATH $<TARGET_FILE_DIR:nanoeigenpy>
177-
DEPENDS nanoeigenpy
178-
)
179-
endif()
184+
nanobind_add_stub(
185+
nanoeigenpy_stub
186+
VERBOSE
187+
MODULE nanoeigenpy
188+
OUTPUT ${CMAKE_BINARY_DIR}/lib/site-packages/nanoeigenpy.pyi
189+
PYTHON_PATH $<TARGET_FILE_DIR:nanoeigenpy>
190+
DEPENDS nanoeigenpy
191+
)
180192

181193
jrl_python_compute_install_dir(python_install_dir)
182194
# NOTE: install the whole binary dir, we need the "/" at the end to copy the content.

0 commit comments

Comments
 (0)