Skip to content

Commit

Permalink
Allow use of installed nanobind
Browse files Browse the repository at this point in the history
  • Loading branch information
ManifoldFR committed Aug 27, 2024
1 parent 5cf9a7d commit 85ed48f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,22 @@ else()
${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/${PROJECT_NAME})
endif()

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/nanobind)
add_subdirectory(external/nanobind
${CMAKE_CURRENT_BINARY_DIR}/external/nanobind)
cmake_policy(PUSH)
cmake_policy(SET CMP0074 NEW)
# Detect the installed nanobind package and import it into CMake
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE nanobind_ROOT)
find_package(nanobind CONFIG REQUIRED)
cmake_policy(POP)
if(NOT nanobind_FOUND)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/nanobind)
add_subdirectory(external/nanobind
${CMAKE_CURRENT_BINARY_DIR}/external/nanobind)
else()
message(STATUS "Found installed nanobind.")
endif()

add_custom_target(${PROJECT_NAME}_python)

Expand Down

0 comments on commit 85ed48f

Please sign in to comment.