Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
83 lines (71 loc) · 2.54 KB
/
Copy pathCMakeLists.txt
File metadata and controls
83 lines (71 loc) · 2.54 KB
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
cmake_minimum_required(VERSION 3.28)
# The current implementation is compiled only for sm_120a. Set and validate the
# architecture before CUDA compiler detection so CMake never injects a generic
# host-toolchain default or accepts an unsupported target.
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 120a CACHE STRING "CUDA architectures to build")
endif()
if(NOT CMAKE_CUDA_ARCHITECTURES STREQUAL "120a")
message(FATAL_ERROR
"NInfer supports only CMAKE_CUDA_ARCHITECTURES=120a; got "
"'${CMAKE_CUDA_ARCHITECTURES}'")
endif()
project(ninfer LANGUAGES C CXX CUDA)
# --- Global settings ---------------------------------------------------------
option(NINFER_BUILD_APPS "Build the NInfer CLI and server" ON)
option(BUILD_TESTING "Build NInfer tests" OFF)
option(NINFER_BUILD_BENCHMARKS "Build NInfer benchmarks" OFF)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_STANDARD 20)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # clangd / IDE tooling
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(CMAKE_GENERATOR MATCHES "Ninja")
set_property(GLOBAL PROPERTY JOB_POOLS cuda_link=1)
set(CMAKE_JOB_POOL_LINK cuda_link)
endif()
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 13.0)
message(FATAL_ERROR
"NInfer requires CUDA 13.1 or newer; found CUDA compiler "
"${CMAKE_CUDA_COMPILER_VERSION}")
endif()
set(NINFER_BUILD_MEDIA_ACQUIRE OFF)
if(NINFER_BUILD_APPS OR BUILD_TESTING)
set(NINFER_BUILD_MEDIA_ACQUIRE ON)
endif()
set(NINFER_BUILD_PROMPT_INPUT OFF)
if(NINFER_BUILD_APPS OR BUILD_TESTING)
set(NINFER_BUILD_PROMPT_INPUT ON)
endif()
set(NINFER_BUILD_SERVE OFF)
if(NINFER_BUILD_APPS OR BUILD_TESTING)
set(NINFER_BUILD_SERVE ON)
endif()
find_package(CUDAToolkit REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
libavformat>=58 libavcodec>=58 libavutil>=56 libswscale>=5)
if(NINFER_BUILD_MEDIA_ACQUIRE)
pkg_check_modules(LIBCURL REQUIRED IMPORTED_TARGET libcurl>=7.81)
endif()
find_package(Threads REQUIRED)
if(NINFER_BUILD_APPS OR BUILD_TESTING)
# Product operational logging is an offline, repository-pinned dependency. Core-only builds do
# not configure or link it.
add_subdirectory(third_party/spdlog)
endif()
# --- Subdirectories ----------------------------------------------------------
add_subdirectory(src)
if(NINFER_BUILD_APPS)
add_subdirectory(apps)
endif()
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
if(NINFER_BUILD_BENCHMARKS)
add_subdirectory(bench)
endif()