-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathCMakeLists.txt
163 lines (126 loc) · 5.16 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
# 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.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_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)
set(MORPHEUS_PY_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/wheel" CACHE STRING "Location to install the python directory")
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 17)
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_BUILD_RPATH_USE_ORIGIN TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
enable_testing()
# CMake path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Add the RAPIDS cmake helper scripts
include(import-rapids-cmake)
# Configure CUDA architecture
include(configure_cuda_architecture)
# Set a default build type if none was specified
rapids_cmake_build_type(Release)
# Toolchain selection (Conda/VCPKG/custom) and configuration
include(cmake/configure_toolchain.cmake)
# Project definition
project(morpheus LANGUAGES C CXX CUDA)
# Ccache configuration
include(setup_cache)
# Configure all dependencies
include(cmake/dependencies.cmake)
####################################
# - Post dependencies setup --------
include(cmake/setup_compiler.cmake)
# Setup IWYU if enabled
include(cmake/setup_iwyu.cmake)
# 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
add_subdirectory(morpheus)
if(MORPHEUS_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# Get all of the python files to copy to the build directory
file(GLOB_RECURSE MORPHEUS_PYTHON_FILES
RELATIVE ${PROJECT_SOURCE_DIR}
LIST_DIRECTORIES FALSE
CONFIGURE_DEPENDS
"morpheus/*.py"
"morpheus/py.typed"
)
set(MORPHEUS_ROOT_PYTHON_FILES
"pyproject.toml"
"setup.cfg"
"setup.py"
"versioneer.py"
"MANIFEST.in"
)
# Add the root python files to the list
list(PREPEND MORPHEUS_PYTHON_FILES ${MORPHEUS_ROOT_PYTHON_FILES})
set(OUTPUT_PYTHON_FILES "")
# For each file, copy if its different
foreach(py_file ${MORPHEUS_PYTHON_FILES})
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/${py_file}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/${py_file} ${PROJECT_BINARY_DIR}/${py_file}
DEPENDS ${PROJECT_SOURCE_DIR}/${py_file}
COMMENT "Copying ${py_file} to ${PROJECT_BINARY_DIR}/${py_file}"
)
list(APPEND OUTPUT_PYTHON_FILES ${PROJECT_BINARY_DIR}/${py_file})
endforeach()
add_custom_target(copy_python_source ALL
DEPENDS ${OUTPUT_PYTHON_FILES}
)
# Manually install the below files. install(DIRECTORY) doesnt work well and
# makes it impossible to get these files and MORPHEUS_PYTHON_FILES in one command.
install(
FILES ${MORPHEUS_ROOT_PYTHON_FILES}
DESTINATION ${MORPHEUS_PY_INSTALL_DIR}
COMPONENT Wheel
)
# Use the install(DIRECTORY) to keep the files tructure
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/morpheus
DESTINATION ${MORPHEUS_PY_INSTALL_DIR}
COMPONENT Wheel
FILES_MATCHING
PATTERN "*.py"
PATTERN "py.typed"
PATTERN "data/*"
)
list(POP_BACK CMAKE_MESSAGE_CONTEXT)