-
Notifications
You must be signed in to change notification settings - Fork 79
/
CMakeLists.txt
117 lines (104 loc) · 4.22 KB
/
CMakeLists.txt
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
#=============================================================================
# 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.
#=============================================================================
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
endif()
if(POLICY CMP0096)
cmake_policy(SET CMP0096 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0096 NEW)
endif()
if(POLICY CMP0135)
# make the timestamps of ExternalProject_ADD match the download time
# https://cmake.org/cmake/help/latest/policy/CMP0135.html
cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
endif()
if(POLICY CMP0132)
# Avoid an inconsistency, where cmake would only set the CC/CXX env vars on
# the first run, but not subsequent ones. This would come up when building
# TBLIS.
cmake_policy(SET CMP0132 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0132 NEW)
endif()
set(CMAKE_CXX_STANDARD 17 CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE STRING "" FORCE)
set(CMAKE_CUDA_STANDARD 17 CACHE STRING "" FORCE)
set(CMAKE_CUDA_STANDARD_REQUIRED ON CACHE STRING "" FORCE)
##############################################################################
# - Download and initialize RAPIDS CMake helpers -----------------------------
set(rapids-cmake-version 24.04)
set(rapids-cmake-sha "365322aca32fd6ecd7027f5d7ec7be50b7f3cc2a")
if(NOT EXISTS ${CMAKE_BINARY_DIR}/RAPIDS.cmake)
file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${rapids-cmake-version}/RAPIDS.cmake
${CMAKE_BINARY_DIR}/RAPIDS.cmake)
endif()
include(${CMAKE_BINARY_DIR}/RAPIDS.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
include(rapids-export)
include(rapids-find)
set(cupynumeric_version 24.11.02)
# For now we want the optimization flags to match on both normal make and cmake
# builds so we override the cmake defaults here for release, this changes
# -O3 to -O2 and removes -DNDEBUG
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CUDA_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CUDA_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
set(CMAKE_CUDA_FLAGS_MINSIZEREL "-Os")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-O2 -g")
if(NOT SKBUILD)
project(cupynumeric VERSION ${cupynumeric_version} LANGUAGES C CXX)
include(cupynumeric_cpp.cmake)
else()
project(
cupynumeric_python
VERSION ${cupynumeric_version}
LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C
# language to be enabled here. The test project that is built in scikit-build to verify
# various linking options for the python library is hardcoded to build with C, so until
# that is fixed we need to keep C.
C CXX)
include(cupynumeric_python.cmake)
endif()
if(CMAKE_GENERATOR STREQUAL "Ninja")
function(add_touch_cupynumeric_ninja_build_target)
set(_suf )
if(SKBUILD)
set(_suf "_python")
endif()
add_custom_target("touch_cupynumeric${_suf}_ninja_build" ALL
COMMAND ${CMAKE_COMMAND} -E touch_nocreate "${CMAKE_CURRENT_BINARY_DIR}/build.ninja"
COMMENT "touch build.ninja so ninja doesn't re-run CMake on rebuild"
VERBATIM
)
foreach(_dep IN ITEMS cupynumeric cupynumeric_python
legate legate_python
Legion LegionRuntime
Realm RealmRuntime
Regent)
if(TARGET ${_dep})
add_dependencies("touch_cupynumeric${_suf}_ninja_build" ${_dep})
endif()
endforeach()
endfunction()
add_touch_cupynumeric_ninja_build_target()
endif()