forked from nv-morpheus/MRC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
168 lines (130 loc) · 6.72 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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# SPDX-FileCopyrightText: Copyright (c) 2018-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# 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.24 FATAL_ERROR)
list(APPEND CMAKE_MESSAGE_CONTEXT "mrc")
# Global options.
# Options of the form: MRC_BUILD_XXX, enable library features and use default values targeting average users of the library
# Options of the form: MRC_ENABLE_XXX, alter whether to build using a specific optional third party library. ON by default
# Options of the form: MRC_USE_XXX, enable linting or alter the environment and are OFF by default
option(BUILD_SHARED_LIBS "Default value for whether or not to build shared or static libraries" ON)
option(MRC_BUILD_BENCHMARKS "Whether or not to build MRC benchmarks" OFF)
option(MRC_BUILD_DOCS "Enable building of API documentation" OFF)
option(MRC_BUILD_LIBRARY "Whether the entire MRC library should be built. If set to OFF, only the pieces needed for a target will be built. Set to ON if installing the library" ON)
option(MRC_BUILD_PYTHON "Enable building the python bindings for MRC" ON)
option(MRC_BUILD_TESTS "Whether or not to build MRC tests" ON)
option(MRC_USE_CCACHE "Enable caching compilation results with ccache" OFF)
option(MRC_USE_CLANG_TIDY "Enable running clang-tidy as part of the build process" OFF)
option(MRC_USE_CONDA "Enables finding dependencies via conda instead of vcpkg. Note: This will disable vcpkg. All dependencies must be installed first in the conda environment" ON)
option(MRC_USE_IWYU "Enable running include-what-you-use as part of the build process" OFF)
option(MRC_ENABLE_CODECOV "Enable gcov code coverage" OFF)
set(MRC_RAPIDS_VERSION "22.10" CACHE STRING "Which version of RAPIDS to build for. Sets default versions for RAPIDS CMake and RMM.")
set(MRC_CACHE_DIR "${CMAKE_SOURCE_DIR}/.cache" CACHE PATH "Directory to contain all CPM and CCache data")
mark_as_advanced(MRC_CACHE_DIR)
# CMake path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(cmake/setup_package_manager.cmake)
enable_testing()
# Add the RAPIDS cmake helper scripts
include(cmake/import_rapids_cmake.cmake)
# Default to using "native" (case-sensitive) for CUDA_ARCHITECTURES to build based on GPU in system
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES "native")
message(STATUS "CMAKE_CUDA_ARCHITECTURES was not defined. Defaulting to '${CMAKE_CUDA_ARCHITECTURES}' to build only for local architecture. Specify -DCMAKE_CUDA_ARCHITECTURES='ALL' to build for all archs.")
endif()
rapids_cuda_init_architectures(mrc)
project(mrc
VERSION 23.01.00
LANGUAGES C CXX
)
rapids_cmake_write_version_file(${CMAKE_BINARY_DIR}/autogenerated/include/mrc/version.hpp)
# Delay enabling CUDA until after we have determined our CXX compiler
if(NOT DEFINED CMAKE_CUDA_HOST_COMPILER)
message(STATUS "Setting CUDA host compiler to match CXX compiler: ${CMAKE_CXX_COMPILER}")
# Only set the host compiler if we arent using clang. Using clang > 8ish is
# incompatible with CUDA 11.4/11.5/11.6. See Issue #102
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Our version of NVCC officially only supports clang versions 3.2 - 13, we are now using 14
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -allow-unsupported-compiler")
endif()
# Now enable CUDA
enable_language(CUDA)
# Create a variable for subdirectories to use to reference from the root of the
# project. Also used by ccache
set(MRC_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# Set a default build type if none was specified
rapids_cmake_build_type(Release)
# Once the build type is set, remove any dumb vcpkg debug folders from the
# search paths. Without this FindBoost fails since it defaults to the debug
# binaries
if(DEFINED CACHE{MRC_VCPKG_TOOLCHAIN} AND DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$")
message(STATUS "Release Build: Removing debug Vcpkg paths from CMAKE_PREFIX_PATH and CMAKE_FIND_ROOT_PATH")
list(REMOVE_ITEM CMAKE_PREFIX_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug")
list(REMOVE_ITEM CMAKE_FIND_ROOT_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Setup cache before dependencies
include(cmake/setup_cache.cmake)
# Configure conda
if(MRC_USE_CONDA AND DEFINED ENV{CONDA_PREFIX})
rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND DEFINED ENV{CONDA_PREFIX})
message(STATUS "No CMAKE_INSTALL_PREFIX argument detected, setting to: $ENV{CONDA_PREFIX}")
set(CMAKE_INSTALL_PREFIX "$ENV{CONDA_PREFIX}" CACHE STRING "" FORCE)
endif()
endif()
# Disable exporting compile commands for dependencies
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)
# Create a custom target to allow preparing for style checks
add_custom_target(${PROJECT_NAME}_style_checks
COMMENT "Building dependencies for style checks"
)
# Configure all dependencies
include(cmake/dependencies.cmake)
# Enable for all first party code
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# To make it easier for CI to find output files, set the default executable suffix to .x if not set
if("${CMAKE_EXECUTABLE_SUFFIX}" STREQUAL "")
set(CMAKE_EXECUTABLE_SUFFIX ".x")
endif()
add_subdirectory(protos)
# ###################################
# - Post dependencies setup --------
include(cmake/setup_compiler.cmake)
# Setup code coverage components
include(cmake/setup_coverage.cmake)
# Setup IWYU if enabled
include(cmake/setup_iwyu.cmake)
# ##################################################################################################
# - subdirectories ---------------------------------------------------------------------------------
add_subdirectory(cpp)
if(MRC_BUILD_PYTHON)
add_subdirectory(python)
endif()
if(MRC_BUILD_DOCS)
add_subdirectory(docs)
endif()
# Uncomment the following to print all available targets
# include(debug_utils)
# print_all_targets()
list(POP_BACK CMAKE_MESSAGE_CONTEXT)