1- cmake_minimum_required (VERSION 3.18 ...3.22 )
1+ cmake_minimum_required (VERSION 3.15 ...3.26 )
22
33project (nanobind_example LANGUAGES CXX)
44
@@ -17,28 +17,14 @@ if (NOT SKBUILD)
1717 in your environment once and use the following command that avoids
1818 a costly creation of a new virtual environment at every compilation:
1919 =====================================================================
20- $ python setup.py install
20+ $ pip install --no-build-isolation -v .
2121 =====================================================================" )
2222endif ()
2323
24- # Perform a release build by default
25- if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
26- set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
27- set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
28- endif ()
29-
30- # Create CMake targets for all Python components needed by nanobind
31- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.26 AND Python_INTERPRETER_ID STREQUAL "Python" )
32- find_package (Python 3.8 COMPONENTS Interpreter Development.Module Development.SABIModule REQUIRED)
33- else ()
34- find_package (Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
35- endif ()
36-
37- # Determine the nanobind CMake include path and register it
38- execute_process (
39- COMMAND "${Python_EXECUTABLE} " -m nanobind --cmake_dir
40- OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_DIR)
41- list (APPEND CMAKE_PREFIX_PATH "${NB_DIR} " )
24+ # Try to import all Python components potentially needed by nanobind
25+ find_package (Python 3.8
26+ REQUIRED COMPONENTS Interpreter Development.Module
27+ OPTIONAL_COMPONENTS Development.SABIModule)
4228
4329# Import nanobind through CMake's find_package mechanism
4430find_package (nanobind CONFIG REQUIRED)
@@ -66,4 +52,4 @@ nanobind_add_module(
6652)
6753
6854# Install directive for scikit-build
69- install (TARGETS nanobind_example_ext LIBRARY DESTINATION . )
55+ install (TARGETS nanobind_example_ext LIBRARY DESTINATION nanobind_example )
0 commit comments