forked from NVIDIA/DALI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDependencies.cmake
136 lines (113 loc) · 4.62 KB
/
Dependencies.cmake
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
# Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
#
# 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.
##################################################################
# CUDA Toolkit libraries (including NVJPEG)
##################################################################
CUDA_find_library(CUDART_LIB cudart_static)
list(APPEND DALI_EXCLUDES libcudart_static.a)
# For NVJPEG
if (BUILD_NVJPEG)
find_package(NVJPEG 9.0 REQUIRED)
if(${CUDA_VERSION} VERSION_LESS ${NVJPEG_VERSION})
message(WARNING "Using nvJPEG ${NVJPEG_VERSION} together with CUDA ${CUDA_VERSION} "
"requires NVIDIA drivers compatible with CUDA ${NVJPEG_VERSION} or later")
endif()
include_directories(SYSTEM ${NVJPEG_INCLUDE_DIR})
list(APPEND DALI_LIBS ${NVJPEG_LIBRARY})
list(APPEND DALI_EXCLUDES libnvjpeg_static.a)
add_definitions(-DDALI_USE_NVJPEG)
if (${NVJPEG_LIBRARY_0_2_0})
add_definitions(-DNVJPEG_LIBRARY_0_2_0)
endif()
if (${NVJPEG_PREALLOCATE_API})
add_definitions(-DNVJPEG_PREALLOCATE_API)
endif()
endif()
if (BUILD_NVJPEG2K)
CUDA_find_library(NVJPEG2K_LIBRARY nvjpeg2k_static)
if (${NVJPEG2K_LIBRARY} STREQUAL "NVJPEG2K_LIBRARY-NOTFOUND")
message(WARNING "nvJPEG2k not found - disabled")
set(BUILD_NVJPEG2K OFF CACHE BOOL INTERNAL)
set(BUILD_NVJPEG2K OFF)
else()
list(APPEND DALI_LIBS ${NVJPEG2K_LIBRARY})
list(APPEND DALI_EXCLUDES libnvjpeg2k_static.a)
endif()
endif (BUILD_NVJPEG2K)
# NVIDIA NPP library
CUDA_find_library(CUDA_nppicc_static_LIBRARY nppicc_static)
CUDA_find_library(CUDA_nppc_static_LIBRARY nppc_static)
list(APPEND DALI_LIBS ${CUDA_nppicc_static_LIBRARY})
list(APPEND DALI_EXCLUDES libnppicc_static.a)
list(APPEND DALI_LIBS ${CUDA_nppc_static_LIBRARY})
list(APPEND DALI_EXCLUDES libnppc_static.a)
# cuFFT library
CUDA_find_library(CUDA_cufft_static_LIBRARY cufft_static)
list(APPEND DALI_EXCLUDES libcufft_static.a)
# CULIBOS needed when using static CUDA libs
CUDA_find_library(CUDA_culibos_LIBRARY culibos)
list(APPEND DALI_LIBS ${CUDA_culibos_LIBRARY})
list(APPEND DALI_EXCLUDES libculibos.a)
if (LINK_LIBCUDA)
CUDA_find_library_stub(CUDA_cuda_LIBRARY cuda)
list(APPEND DALI_LIBS ${CUDA_cuda_LIBRARY})
CUDA_find_library_stub(CUDA_nvml_LIBRARY nvidia-ml)
list(APPEND DALI_LIBS ${CUDA_nvml_LIBRARY})
endif()
# NVTX for profiling
if (NVTX_ENABLED)
if(${CUDA_VERSION} VERSION_LESS "10.0")
CUDA_find_library(CUDA_nvToolsExt_LIBRARY nvToolsExt)
list(APPEND DALI_LIBS ${CUDA_nvToolsExt_LIBRARY})
endif()
endif()
# verbose
if (VERBOSE_LOGS)
add_definitions(-DDALI_VERBOSE_LOGS)
endif()
include(cmake/Dependencies.common.cmake)
##################################################################
# protobuf
##################################################################
# link statically
if (BUILD_PROTOBUF)
if(NOT DEFINED Protobuf_USE_STATIC_LIBS)
set(Protobuf_USE_STATIC_LIBS YES)
endif(NOT DEFINED Protobuf_USE_STATIC_LIBS)
find_package(Protobuf 2.0 REQUIRED)
if(${Protobuf_VERSION} VERSION_LESS "3.0")
message(STATUS "TensorFlow TFRecord file format support is not available with Protobuf 2")
else()
message(STATUS "Enabling TensorFlow TFRecord file format support")
add_definitions(-DDALI_BUILD_PROTO3=1)
set(BUILD_PROTO3 ON CACHE STRING "Build proto3")
endif()
include_directories(SYSTEM ${Protobuf_INCLUDE_DIRS})
list(APPEND DALI_LIBS ${Protobuf_LIBRARY})
# hide things from the protobuf, all we export is only is API generated from our proto files
list(APPEND DALI_EXCLUDES libprotobuf.a)
endif()
set(DALI_SYSTEM_LIBS rt pthread m dl)
list(APPEND DALI_LIBS ${CUDART_LIB} ${DALI_SYSTEM_LIBS})
##################################################################
# Exclude stdlib
##################################################################
list(APPEND DALI_EXCLUDES libsupc++.a;libstdc++.a;libstdc++_nonshared.a;)
##################################################################
# Turing Optical flow API
##################################################################
if(BUILD_NVOF)
include_directories(${PROJECT_SOURCE_DIR}/third_party/turing_of)
endif()
include_directories(SYSTEM ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})