1
- #
2
- # Copyright (C) 2024 Autodesk, Inc. All Rights Reserved.
3
- #
4
- # SPDX-License-Identifier: Apache-2.0
5
- #
6
-
7
- INCLUDE (ProcessorCount) # require CMake 3.15+
8
- PROCESSORCOUNT(_cpu_count)
9
-
10
- RV_CREATE_STANDARD_DEPS_VARIABLES("RV_DEPS_NANOBIND" "2.7.0" "" "" )
11
- RV_SHOW_STANDARD_DEPS_VARIABLES()
12
-
13
-
14
- SET (_download_url
15
- "https://github.com/wjakob/nanobind.git"
16
- )
17
-
18
- SET (_git_commit
19
- "44ad9a9e5729abda24ef8dc9d76233d801e651e9"
20
- )
21
-
22
- SET (_patch_command_nanobind_windows_debug "" )
23
- IF (RV_TARGET_WINDOWS AND CMAKE_BUILD_TYPE MATCHES "^Debug$" )
24
- SET (_patch_command_nanobind_windows_debug
25
- patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR} /patch/nanobind.windows.debug.patch
26
- )
27
- ENDIF ()
28
-
29
- IF (RV_TARGET_WINDOWS)
30
- IF (CMAKE_BUILD_TYPE MATCHES "^Debug$" )
31
- SET (_nanobind_python_executable
32
- ${RV_DEPS_BASE_DIR} /RV_DEPS_PYTHON3/install /bin/python_d.exe
33
- )
34
- ELSE ()
35
- SET (_nanobind_python_executable
36
- ${RV_DEPS_BASE_DIR} /RV_DEPS_PYTHON3/install /bin/python3.exe
37
- )
38
- ENDIF ()
39
- ELSE ()
40
- SET (_nanobind_python_executable
41
- ${RV_DEPS_BASE_DIR} /RV_DEPS_PYTHON3/install /bin/python3
42
- )
43
- ENDIF ()
44
-
45
- # Set up dependencies - start with Python, add extra packages for CY2023.
46
- SET (_nanobind_dependencies Python::Python)
47
-
48
- IF (RV_VFX_PLATFORM STREQUAL CY2023)
49
- SET (_nanobind_python_extra_packages
50
- "${_nanobind_python_executable} " -m pip install typing_extensions
51
- )
52
-
53
- # Create a stamp file to track nanobind installation
54
- SET (_nanobind_stamp
55
- ${CMAKE_CURRENT_BINARY_DIR} /${_target} -extra-packages-stamp
56
- )
57
-
58
- ADD_CUSTOM_COMMAND (
59
- OUTPUT ${_nanobind_stamp}
60
- COMMAND ${_nanobind_python_extra_packages}
61
- COMMAND ${CMAKE_COMMAND} -E touch ${_nanobind_stamp}
62
- COMMENT "Installing extra Python package for Python <3.11 and creating stamp file"
63
- DEPENDS Python::Python
64
- )
65
-
66
- # Add a custom target that depends on the stamp file
67
- ADD_CUSTOM_TARGET (
68
- ${_target} -extra-packages
69
- DEPENDS ${_nanobind_stamp}
70
- COMMENT "Ensuring Python packages are installed for ${_target} "
71
- )
72
-
73
- # Add extra packages to dependencies
74
- LIST (APPEND _nanobind_dependencies ${_target} -extra-packages)
75
- ENDIF ()
76
-
77
- EXTERNALPROJECT_ADD(
78
- ${_target}
79
- GIT_REPOSITORY "${_download_url} "
80
- GIT_TAG "${_git_commit} "
81
- DOWNLOAD_DIR ${RV_DEPS_DOWNLOAD_DIR}
82
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE
83
- SOURCE_DIR ${_source_dir}
84
- BINARY_DIR ${_build_dir}
85
- INSTALL_DIR ${_install_dir}
86
- UPDATE_COMMAND ""
87
- PATCH_COMMAND ${_patch_command_nanobind_windows_debug}
88
- CONFIGURE_COMMAND
89
- ${CMAKE_COMMAND} ${_configure_options} -DPython_ROOT=${RV_DEPS_BASE_DIR} /RV_DEPS_PYTHON3/install -DPython_EXECUTABLE=${_nanobind_python_executable}
90
- BUILD_COMMAND ${_cmake_build_command}
91
- INSTALL_COMMAND ${_cmake_install_command}
92
- BUILD_IN_SOURCE FALSE
93
- BUILD_ALWAYS FALSE
94
- BUILD_BYPRODUCTS ${_install_dir} /nanobind/cmake/nanobind-config.cmake
95
- USES_TERMINAL_BUILD TRUE
96
- DEPENDS ${_nanobind_dependencies}
97
- )
98
-
99
-
100
-
101
- ADD_DEPENDENCIES (dependencies RV_DEPS_NANOBIND)
1
+ #
2
+ # Copyright (C) 2024 Autodesk, Inc. All Rights Reserved.
3
+ #
4
+ # SPDX-License-Identifier: Apache-2.0
5
+ #
6
+
7
+ INCLUDE (ProcessorCount) # require CMake 3.15+
8
+ PROCESSORCOUNT(_cpu_count)
9
+
10
+ RV_CREATE_STANDARD_DEPS_VARIABLES("RV_DEPS_NANOBIND" "2.7.0" "" "" )
11
+ RV_SHOW_STANDARD_DEPS_VARIABLES()
12
+
13
+ SET (_download_url
14
+ "https://github.com/wjakob/nanobind.git"
15
+ )
16
+
17
+ SET (_git_commit
18
+ "44ad9a9e5729abda24ef8dc9d76233d801e651e9"
19
+ )
20
+
21
+ SET (_patch_command_nanobind_windows_debug
22
+ ""
23
+ )
24
+ IF (RV_TARGET_WINDOWS
25
+ AND CMAKE_BUILD_TYPE MATCHES "^Debug$"
26
+ )
27
+ SET (_patch_command_nanobind_windows_debug
28
+ patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR} /patch/nanobind.windows.debug.patch
29
+ )
30
+ ENDIF ()
31
+
32
+ IF (RV_TARGET_WINDOWS)
33
+ IF (CMAKE_BUILD_TYPE MATCHES "^Debug$" )
34
+ SET (_nanobind_python_executable
35
+ ${RV_DEPS_BASE_DIR} /RV_DEPS_PYTHON3/install /bin/python_d.exe
36
+ )
37
+ ELSE ()
38
+ SET (_nanobind_python_executable
39
+ ${RV_DEPS_BASE_DIR} /RV_DEPS_PYTHON3/install /bin/python3.exe
40
+ )
41
+ ENDIF ()
42
+ ELSE ()
43
+ SET (_nanobind_python_executable
44
+ ${RV_DEPS_BASE_DIR} /RV_DEPS_PYTHON3/install /bin/python3
45
+ )
46
+ ENDIF ()
47
+
48
+ # Set up dependencies - start with Python, add extra packages for CY2023.
49
+ SET (_nanobind_dependencies
50
+ Python::Python
51
+ )
52
+
53
+ IF (RV_VFX_PLATFORM STREQUAL CY2023)
54
+ SET (_nanobind_python_extra_packages
55
+ "${_nanobind_python_executable} " -m pip install typing_extensions
56
+ )
57
+
58
+ # Create a stamp file to track nanobind installation
59
+ SET (_nanobind_stamp
60
+ ${CMAKE_CURRENT_BINARY_DIR} /${_target} -extra-packages-stamp
61
+ )
62
+
63
+ ADD_CUSTOM_COMMAND (
64
+ OUTPUT ${_nanobind_stamp}
65
+ COMMAND ${_nanobind_python_extra_packages}
66
+ COMMAND ${CMAKE_COMMAND} -E touch ${_nanobind_stamp}
67
+ COMMENT "Installing extra Python package for Python <3.11 and creating stamp file"
68
+ DEPENDS Python::Python
69
+ )
70
+
71
+ # Add a custom target that depends on the stamp file
72
+ ADD_CUSTOM_TARGET (
73
+ ${_target} -extra-packages
74
+ DEPENDS ${_nanobind_stamp}
75
+ COMMENT "Ensuring Python packages are installed for ${_target} "
76
+ )
77
+
78
+ # Add extra packages to dependencies
79
+ LIST (APPEND _nanobind_dependencies ${_target} -extra-packages)
80
+ ENDIF ()
81
+
82
+ LIST (APPEND _configure_options "-DNB_TEST=OFF" )
83
+ LIST (APPEND _configure_options "-DPython_ROOT=${RV_DEPS_BASE_DIR} /RV_DEPS_PYTHON3/install" )
84
+ LIST (APPEND _configure_options "-DPython_EXECUTABLE=${_nanobind_python_executable} " )
85
+
86
+ EXTERNALPROJECT_ADD(
87
+ ${_target}
88
+ GIT_REPOSITORY "${_download_url} "
89
+ GIT_TAG "${_git_commit} "
90
+ DOWNLOAD_DIR ${RV_DEPS_DOWNLOAD_DIR}
91
+ DOWNLOAD_EXTRACT_TIMESTAMP TRUE
92
+ SOURCE_DIR ${_source_dir}
93
+ BINARY_DIR ${_build_dir}
94
+ INSTALL_DIR ${_install_dir}
95
+ UPDATE_COMMAND ""
96
+ PATCH_COMMAND ${_patch_command_nanobind_windows_debug}
97
+ CONFIGURE_COMMAND ${CMAKE_COMMAND} ${_configure_options}
98
+ BUILD_COMMAND ${_cmake_build_command}
99
+ INSTALL_COMMAND ${_cmake_install_command}
100
+ BUILD_IN_SOURCE FALSE
101
+ BUILD_ALWAYS FALSE
102
+ BUILD_BYPRODUCTS ${_install_dir} /nanobind/cmake/nanobind-config.cmake
103
+ USES_TERMINAL_BUILD TRUE
104
+ DEPENDS ${_nanobind_dependencies}
105
+ )
106
+
107
+ ADD_DEPENDENCIES (dependencies RV_DEPS_NANOBIND)
0 commit comments