forked from NVIDIA/DALI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
87 lines (72 loc) · 3.01 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
# Copyright (c) 2017-2018, 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.
cmake_minimum_required(VERSION 3.5)
project(DALI CXX)
# Build options
option(BUILD_TEST "Build googletest test suite" ON)
option(BUILD_BENCHMARK "Build benchmark suite" ON)
option(BUILD_NVTX "Build with NVTX profiling enabled" OFF)
option(BUILD_PYTHON "Build python bindings" ON)
option(BUILD_LMDB "Build LMDB readers" OFF)
option(BUILD_TENSORFLOW "Build TensorFlow plugin" OFF)
option(BUILD_JPEG_TURBO "Build with libjpeg-turbo" ON)
option(BUILD_NVJPEG "Build with nvJPEG" ON)
# Helper function to remove elements from a variable
function (remove TARGET INPUT)
foreach(ITEM ${ARGN})
list(REMOVE_ITEM INPUT "${ITEM}")
endforeach()
set(${TARGET} ${INPUT} PARENT_SCOPE)
endfunction(remove)
# Default to release build
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Build type from [Debug, Release]. For perf testing, build Release" FORCE)
endif()
# Cmake path
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
# Dependencies
include(cmake/Dependencies.cmake)
# add more flags after they are populated by find_package from Dependencies.cmake
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message(STATUS "Building in DEBUG mode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -DDALI_DEBUG=1")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -g -G -DDALI_DEBUG=1")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDALI_DEBUG=0")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -DDALI_DEBUG=0")
endif()
# CXX flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -Wno-unused-variable -Wno-unused-function -fno-strict-aliasing -O2 -fPIC -fvisibility=hidden")
# Add ptx & bin flags for cuda
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 ")
if (${CUDA_VERSION_MAJOR} GREATER 8)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_70,code=compute_70")
endif()
# Project dir
include_directories(BEFORE ${PROJECT_SOURCE_DIR})
include_directories(BEFORE ${PROJECT_BINARY_DIR})
cuda_include_directories(${PROJECT_SOURCE_DIR})
# Project build
add_subdirectory(dali)
# HACK: Add __init__.pys as needed
file(WRITE ${CMAKE_BINARY_DIR}/dali/__init__.py "")
add_custom_target(lint COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lint.cmake)