|
1 |
| -#============================================================================= |
| 1 | +# ============================================================================= |
2 | 2 | # Copyright (c) 2018, NVIDIA CORPORATION.
|
3 | 3 | #
|
4 |
| -# Licensed under the Apache License, Version 2.0 (the "License"); |
5 |
| -# you may not use this file except in compliance with the License. |
6 |
| -# You may obtain a copy of the License at |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
| 5 | +# in compliance with the License. You may obtain a copy of the License at |
7 | 6 | #
|
8 |
| -# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
9 | 8 | #
|
10 |
| -# Unless required by applicable law or agreed to in writing, software |
11 |
| -# distributed under the License is distributed on an "AS IS" BASIS, |
12 |
| -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 |
| -# See the License for the specific language governing permissions and |
14 |
| -# limitations under the License. |
15 |
| -#============================================================================= |
16 |
| -cmake_minimum_required(VERSION 3.17...3.18 FATAL_ERROR) |
| 9 | +# Unless required by applicable law or agreed to in writing, software distributed under the License |
| 10 | +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 11 | +# or implied. See the License for the specific language governing permissions and limitations under |
| 12 | +# the License. |
| 13 | +# ============================================================================= |
| 14 | +cmake_minimum_required(VERSION 3.18...3.18 FATAL_ERROR) |
17 | 15 |
|
18 |
| -project(RMM VERSION 0.17.0 LANGUAGES C CXX CUDA) |
| 16 | +project( |
| 17 | + RMM |
| 18 | + VERSION 0.17.0 |
| 19 | + LANGUAGES CXX) |
19 | 20 |
|
20 |
| -include(cmake/CPM.cmake) |
| 21 | +include(cmake/Modules/CPM.cmake) |
| 22 | +include(cmake/Modules/RMM_thirdparty.cmake) |
21 | 23 |
|
22 |
| -################################################################################################### |
23 |
| -# - build type |
| 24 | +# build type |
24 | 25 |
|
25 | 26 | # Set a default build type if none was specified
|
26 | 27 | set(DEFAULT_BUILD_TYPE "Release")
|
27 | 28 |
|
28 | 29 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
29 |
| - message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' since none specified.") |
30 |
| - set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE |
31 |
| - STRING "Choose the type of build." FORCE) |
| 30 | + message(STATUS "RMM: Setting build type to '${DEFAULT_BUILD_TYPE}' since none specified.") |
| 31 | + set(CMAKE_BUILD_TYPE |
| 32 | + "${DEFAULT_BUILD_TYPE}" |
| 33 | + CACHE STRING "Choose the type of build." FORCE) |
32 | 34 | # Set the possible values of build type for cmake-gui
|
33 |
| - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS |
34 |
| - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") |
| 35 | + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" |
| 36 | + "RelWithDebInfo") |
35 | 37 | endif()
|
36 | 38 |
|
37 |
| -################################################################################################### |
38 |
| -# - compiler options |
39 |
| - |
40 |
| -set(CMAKE_CXX_STANDARD 14) |
41 |
| -set(CMAKE_CXX_STANDARD_REQUIRED ON) |
42 |
| - |
43 |
| -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") |
44 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-error=deprecated-declarations") |
45 |
| -endif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") |
46 |
| - |
47 |
| -################################################################################################### |
48 |
| -# - build options |
| 39 | +# build options |
49 | 40 |
|
50 | 41 | option(BUILD_TESTS "Configure CMake to build tests" ON)
|
51 | 42 | option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF)
|
52 | 43 |
|
53 |
| -option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF) |
54 |
| -if(DISABLE_DEPRECATION_WARNING) |
55 |
| - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -Wno-deprecated-declarations") |
56 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") |
57 |
| -endif(DISABLE_DEPRECATION_WARNING) |
58 |
| - |
59 | 44 | # cudart can be statically linked or dynamically linked the python ecosystem wants dynamic linking
|
60 | 45 | option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF)
|
61 | 46 |
|
62 |
| -################################################################################################### |
63 | 47 | # find packages we depend on
|
64 | 48 |
|
65 | 49 | find_package(CUDAToolkit REQUIRED)
|
66 | 50 |
|
67 |
| -################################################################################################### |
68 |
| -# cmake modules |
69 |
| - |
70 |
| -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) |
71 |
| - |
72 |
| -################################################################################################### |
73 |
| -# third-party dependencies |
74 |
| - |
75 |
| -include(RMM_thirdparty) |
76 |
| - |
77 |
| -################################################################################################### |
78 | 51 | # library targets
|
79 | 52 |
|
80 | 53 | add_library(rmm INTERFACE)
|
81 | 54 | add_library(rmm::rmm ALIAS rmm)
|
82 | 55 |
|
83 |
| -target_include_directories(rmm INTERFACE |
84 |
| - "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" |
85 |
| - "$<INSTALL_INTERFACE:include>" |
86 |
| - ) |
| 56 | +target_include_directories(rmm INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" |
| 57 | + "$<INSTALL_INTERFACE:include>") |
87 | 58 |
|
88 | 59 | if(CUDA_STATIC_RUNTIME)
|
89 |
| - message(STATUS "Enabling static linking of cudart") |
| 60 | + message(STATUS "RMM: Enabling static linking of cudart") |
90 | 61 | target_link_libraries(rmm INTERFACE CUDA::cudart_static)
|
91 | 62 | else()
|
92 | 63 | target_link_libraries(rmm INTERFACE CUDA::cudart)
|
93 | 64 | endif(CUDA_STATIC_RUNTIME)
|
94 | 65 |
|
95 |
| -target_link_libraries(rmm INTERFACE rmm::Thrust spdlog::spdlog_header_only ${CMAKE_DL_LIBS}) |
| 66 | +target_link_libraries(rmm INTERFACE rmm::Thrust) |
| 67 | +target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) |
| 68 | +target_compile_features(rmm INTERFACE cxx_std_14 cuda_std_14) |
96 | 69 |
|
97 |
| -################################################################################################### |
98 |
| -# Set logging level. Must go before including gtests and benchmarks. |
| 70 | +# Set logging level. Must go before including gtests and benchmarks. |
99 | 71 |
|
100 |
| -set(RMM_LOGGING_LEVEL "INFO" CACHE STRING "Choose the logging level.") |
| 72 | +set(RMM_LOGGING_LEVEL |
| 73 | + "INFO" |
| 74 | + CACHE STRING "Choose the logging level.") |
101 | 75 | # Set the possible values of build type for cmake-gui
|
102 |
| -set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS |
103 |
| - "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF") |
104 |
| -message(STATUS "RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.") |
| 76 | +set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" |
| 77 | + "CRITICAL" "OFF") |
| 78 | +message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'") |
105 | 79 |
|
106 |
| -################################################################################################### |
107 |
| -# add gtest |
| 80 | +# optionally build tests |
108 | 81 |
|
109 | 82 | if(BUILD_TESTS)
|
110 |
| - include(CTest) |
111 |
| - add_subdirectory(tests) |
| 83 | + enable_testing() |
| 84 | + add_subdirectory(tests) |
112 | 85 | endif(BUILD_TESTS)
|
113 | 86 |
|
114 |
| -################################################################################################### |
115 | 87 | # add google benchmark
|
116 | 88 |
|
117 | 89 | if(BUILD_BENCHMARKS)
|
118 | 90 | add_subdirectory(benchmarks)
|
119 | 91 | endif(BUILD_BENCHMARKS)
|
120 | 92 |
|
121 |
| -################################################################################################### |
122 | 93 | # install targets
|
123 | 94 |
|
124 | 95 | include(GNUInstallDirs)
|
125 | 96 | set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/rmm)
|
126 | 97 |
|
127 |
| -install(TARGETS rmm |
128 |
| - EXPORT rmm-targets) |
| 98 | +install(TARGETS rmm EXPORT rmm-targets) |
129 | 99 |
|
130 |
| -install(DIRECTORY include/rmm |
131 |
| - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 100 | +install(DIRECTORY include/rmm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
132 | 101 |
|
133 | 102 | include(CMakePackageConfigHelpers)
|
134 |
| -configure_package_config_file( |
135 |
| - cmake/rmm-config.cmake.in |
136 |
| - ${RMM_BINARY_DIR}/rmm-config.cmake |
137 |
| - INSTALL_DESTINATION ${INSTALL_CONFIGDIR} |
138 |
| - ) |
139 |
| - |
140 |
| -write_basic_package_version_file( |
141 |
| - ${RMM_BINARY_DIR}/rmm-config-version.cmake |
142 |
| - COMPATIBILITY SameMinorVersion |
143 |
| - ) |
144 |
| - |
145 |
| -install(EXPORT rmm-targets |
| 103 | +configure_package_config_file(cmake/rmm-config.cmake.in ${RMM_BINARY_DIR}/rmm-config.cmake |
| 104 | + INSTALL_DESTINATION ${INSTALL_CONFIGDIR}) |
| 105 | + |
| 106 | +write_basic_package_version_file(${RMM_BINARY_DIR}/rmm-config-version.cmake |
| 107 | + COMPATIBILITY SameMinorVersion) |
| 108 | + |
| 109 | +install( |
| 110 | + EXPORT rmm-targets |
146 | 111 | FILE rmm-targets.cmake
|
147 | 112 | NAMESPACE rmm::
|
148 |
| - DESTINATION ${INSTALL_CONFIGDIR} |
149 |
| - ) |
150 |
| - |
151 |
| -install(FILES |
152 |
| - ${RMM_BINARY_DIR}/rmm-config.cmake |
153 |
| - ${RMM_BINARY_DIR}/rmm-config-version.cmake |
154 |
| - ${RMM_SOURCE_DIR}/cmake/install/FindThrust.cmake |
155 |
| - DESTINATION ${INSTALL_CONFIGDIR} |
156 |
| - ) |
157 |
| - |
158 |
| -################################################################################################### |
159 |
| -# make documentation |
| 113 | + DESTINATION ${INSTALL_CONFIGDIR}) |
| 114 | + |
| 115 | +install(FILES ${RMM_BINARY_DIR}/rmm-config.cmake ${RMM_BINARY_DIR}/rmm-config-version.cmake |
| 116 | + ${RMM_SOURCE_DIR}/cmake/install/FindThrust.cmake DESTINATION ${INSTALL_CONFIGDIR}) |
160 | 117 |
|
161 |
| -add_custom_command(OUTPUT RMM_DOXYGEN |
162 |
| - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen |
163 |
| - COMMAND doxygen Doxyfile |
164 |
| - VERBATIM) |
| 118 | +# make documentation |
165 | 119 |
|
166 |
| -add_custom_target(rmm_doc DEPENDS RMM_DOXYGEN) |
| 120 | +add_custom_command( |
| 121 | + OUTPUT RMM_DOXYGEN |
| 122 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen |
| 123 | + COMMAND doxygen Doxyfile |
| 124 | + VERBATIM |
| 125 | + COMMENT "Custom command for RMM doxygen docs") |
| 126 | + |
| 127 | +add_custom_target( |
| 128 | + rmm_doc |
| 129 | + DEPENDS RMM_DOXYGEN |
| 130 | + COMMENT "Target for the custom command to build the RMM doxygen docs") |
0 commit comments