-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathcupynumeric_python.cmake
More file actions
144 lines (116 loc) · 4.75 KB
/
cupynumeric_python.cmake
File metadata and controls
144 lines (116 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#=============================================================================
# Copyright 2024 NVIDIA Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
##############################################################################
# - User Options ------------------------------------------------------------
option(FIND_CUPYNUMERIC_CPP "Search for existing cuPyNumeric C++ installations before defaulting to local files"
OFF)
##############################################################################
# - Dependencies -------------------------------------------------------------
# If the user requested it we attempt to find cupynumeric.
if(FIND_CUPYNUMERIC_CPP)
include("${rapids-cmake-dir}/export/detail/parse_version.cmake")
rapids_export_parse_version(${cupynumeric_version} cupynumeric parsed_ver)
rapids_find_package(cupynumeric ${parsed_ver} EXACT CONFIG
GLOBAL_TARGETS cupynumeric::cupynumeric
BUILD_EXPORT_SET cupynumeric-python-exports
INSTALL_EXPORT_SET cupynumeric-python-exports)
else()
set(cupynumeric_FOUND OFF)
endif()
if(NOT cupynumeric_FOUND)
set(SKBUILD OFF)
set(Legion_USE_Python ON)
set(Legion_BUILD_BINDINGS ON)
add_subdirectory(. "${CMAKE_CURRENT_SOURCE_DIR}/build")
set(SKBUILD ON)
endif()
add_custom_target("generate_install_info_py" ALL
COMMAND ${CMAKE_COMMAND}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate_install_info_py.cmake"
COMMENT "Generate install_info.py"
VERBATIM
)
add_library(cupynumeric_python INTERFACE)
add_library(cupynumeric::cupynumeric_python ALIAS cupynumeric_python)
target_link_libraries(cupynumeric_python INTERFACE legate::legate)
find_package(
Python
REQUIRED
COMPONENTS Interpreter Development)
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_VARIABLE nanobind_ROOT
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY)
find_package(nanobind CONFIG REQUIRED)
nanobind_add_module(cupynumeric_ufunc_ext
src/cupynumeric/ufunc/native_array_handle.cc
src/cupynumeric/bindings/ufunc_module.cc)
target_include_directories(cupynumeric_ufunc_ext
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(cupynumeric_ufunc_ext
PRIVATE cupynumeric::cupynumeric)
set_target_properties(cupynumeric_ufunc_ext
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/cupynumeric/_lib"
OUTPUT_NAME "ufunc")
# ############################################################################
# - conda environment --------------------------------------------------------
rapids_cmake_support_conda_env(conda_env)
# We're building python extension libraries, which must always be installed
# under lib/, even if the system normally uses lib64/. Rapids-cmake currently
# doesn't realize this when we're going through scikit-build, see
# https://github.com/rapidsai/rapids-cmake/issues/426
if(TARGET conda_env)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
##############################################################################
# - install targets ----------------------------------------------------------
include(CPack)
include(GNUInstallDirs)
rapids_cmake_install_lib_dir(lib_dir)
install(TARGETS cupynumeric_python
DESTINATION ${lib_dir}
EXPORT cupynumeric-python-exports)
install(TARGETS cupynumeric_ufunc_ext
LIBRARY DESTINATION cupynumeric/_lib)
##############################################################################
# - install export -----------------------------------------------------------
set(doc_string
[=[
Provide Python targets for cuPyNumeric.
Imported Targets:
- cupynumeric::cupynumeric_python
]=])
set(code_string "")
rapids_export(
INSTALL cupynumeric_python
EXPORT_SET cupynumeric-python-exports
GLOBAL_TARGETS cupynumeric_python
NAMESPACE cupynumeric::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string)
# build export targets
rapids_export(
BUILD cupynumeric_python
EXPORT_SET cupynumeric-python-exports
GLOBAL_TARGETS cupynumeric_python
NAMESPACE cupynumeric::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string)