forked from nv-morpheus/Morpheus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
185 lines (143 loc) · 6.24 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# SPDX-FileCopyrightText: Copyright (c) 2018-2023, 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.14 FATAL_ERROR)
list(APPEND CMAKE_MESSAGE_CONTEXT "morpheus")
# Global options
option(BUILD_SHARED_LIBS "Default value for whether or not to build shared or static libraries" ON)
option(MORPHEUS_BUILD_BENCHMARKS "Whether or not to build benchmarks" OFF)
option(MORPHEUS_BUILD_EXAMPLES "Whether or not to build examples" OFF)
option(MORPHEUS_BUILD_TESTS "Whether or not to build tests" OFF)
option(MORPHEUS_BUILD_PYTHON_STUBS "Whether or not to generated .pyi stub files for C++ Python modules. Disable to avoid requiring loading the NVIDIA GPU Driver during build" ON)
option(MORPHEUS_BUILD_PYTHON_WHEEL "Whether or not to build the morpheus .whl file" OFF)
option(MORPHEUS_ENABLE_DEBUG_INFO "Enable printing debug information" OFF)
option(MORPHEUS_USE_CCACHE "Enable caching compilation results with ccache" OFF)
option(MORPHEUS_USE_CLANG_TIDY "Enable running clang-tidy as part of the build process" OFF)
option(MORPHEUS_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" OFF)
option(MORPHEUS_USE_IWYU "Enable running include-what-you-use as part of the build process" OFF)
option(MORPHEUS_BUILD_DOCS "Enable building of API documentation" OFF)
set(MORPHEUS_PY_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/wheel" CACHE STRING "Location to install the python directory")
set(MORPHEUS_RAPIDS_VERSION "22.10" CACHE STRING "Sets default versions for RAPIDS libraries.")
set(MORPHEUS_CACHE_DIR "${CMAKE_SOURCE_DIR}/.cache" CACHE PATH "Directory to contain all CPM and CCache data")
mark_as_advanced(MORPHEUS_CACHE_DIR)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
enable_testing()
if (MORPHEUS_USE_IWYU AND MORPHEUS_USE_CCACHE)
message(FATAL_ERROR "MORPHEUS_USE_IWYU and MORPHEUS_USE_CCACHE cannot be set simultaneously")
endif()
# MRC CMake path and module extensions
set(MORPHEUS_CMAKE_MODULE_PATH_EXTENSIONS
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/external/utilities/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/external/utilities/cmake/morpheus_utils/package_search"
)
set(MORPHEUS_CMAKE_PREFIX_PATH_EXTENSIONS
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
# Prepend path and prefix updates so they take priority in this scope.
list(PREPEND CMAKE_MODULE_PATH "${MORPHEUS_CMAKE_MODULE_PATH_EXTENSIONS}")
list(PREPEND CMAKE_PREFIX_PATH "${MORPHEUS_CMAKE_PREFIX_PATH_EXTENSIONS}")
# Force the MORPHEUS_UTILS_RAPIDS_VERSION to match our value
set(MORPHEUS_UTILS_RAPIDS_VERSION ${MORPHEUS_RAPIDS_VERSION} CACHE STRING "" FORCE)
# Load morpheus utils and update CMake paths
include(morpheus_utils/load)
# Configure project package manager
morpheus_utils_initialize_package_manager(
MORPHEUS_USE_CONDA
BUILD_SHARED_LIBS
)
# Configure CUDA architecture
# NOTE: This MUST occur before any 'project' calls because of rapids_cmake requirements.
if (DEFINED MORPHEUS_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES "${MORPHEUS_CUDA_ARCHITECTURES}")
endif()
morpheus_utils_initialize_cuda_arch(morpheus)
# Set a default build type if none was specified
rapids_cmake_build_type(Release)
# Project definition
project(morpheus
VERSION 23.01.00
LANGUAGES C CXX CUDA)
rapids_cmake_write_version_file(${CMAKE_BINARY_DIR}/autogenerated/include/morpheus/version.hpp)
# Ccache configuration
include(environment/init_ccache)
# Configure all dependencies
include(dependencies)
####################################
# - Post dependencies setup --------
morpheus_utils_compiler_set_defaults(MORPHEUS_USE_CLANG_TIDY)
# Setup IWYU if enabled
include(environment/init_iwyu)
# 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()
##################################
##### Morpheus Python Setup ######
##################################
# Create a custom target to allow preparing for style checks
add_custom_target(${PROJECT_NAME}_style_checks
COMMENT "Building dependencies for style checks"
)
# Include the main morpheus code
morpheus_utils_create_python_package(morpheus
PROJECT_DIRECTORY "${CMAKE_SOURCE_DIR}"
SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/morpheus"
)
add_subdirectory(morpheus)
# Complete the python package
if(MORPHEUS_PYTHON_INPLACE_BUILD)
list(APPEND extra_args "IS_INPLACE")
endif()
if(MORPHEUS_BUILD_PYTHON_WHEEL)
list(APPEND extra_args "BUILD_WHEEL")
endif()
if(MORPHEUS_PYTHON_PERFORM_INSTALL)
list(APPEND extra_args "INSTALL_WHEEL")
endif()
file(GLOB morpheus_data_files "${CMAKE_CURRENT_SOURCE_DIR}/morpheus/data/*")
morpheus_utils_add_python_sources(${morpheus_data_files})
morpheus_utils_build_python_package(morpheus ${extra_args})
if(MORPHEUS_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(MORPHEUS_BUILD_DOCS)
add_subdirectory(docs)
endif()
if(MORPHEUS_ENABLE_DEBUG_INFO)
morpheus_utils_print_all_targets()
morpheus_utils_print_target_properties(
TARGETS
cuda_utils
morpheus
stages
messages
common
WRITE_TO_FILE
)
morpheus_utils_print_global_properties(
WRITE_TO_FILE
)
endif()
# Cleanup the environment after we exit this scope
list(REMOVE_ITEM CMAKE_PREFIX_PATH "${MORPHEUS_CMAKE_PREFIX_PATH_EXTENSIONS}")
list(REMOVE_ITEM CMAKE_MODULE_PATH "${MORPHEUS_CMAKE_MODULE_PATH_EXTENSIONS}")
list(POP_BACK CMAKE_MESSAGE_CONTEXT)