-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
119 lines (97 loc) · 4.25 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
cmake_minimum_required(VERSION 3.0.0)
project(RenderAndCompare CXX)
########################### Misc. Configs ##############################
message(STATUS "=============================================================")
message(STATUS "============= Configuring RenderAndCompare ==================")
# Add custom cmake files folder
set (PROJECT_CMAKE_DIR ${PROJECT_SOURCE_DIR}/cmake)
set (CMAKE_MODULE_PATH "${PROJECT_CMAKE_DIR}" "${CMAKE_MODULE_PATH}")
# Add custom Compile Settings and flags
include(CompileSettings)
# Use solution folders.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
message(STATUS "=============================================================")
message(STATUS "================= Look for Dependencies =====================")
# Find Eigen dependencies
find_package(Eigen REQUIRED)
# Find CuteGL Dependencies
find_package(CuteGL REQUIRED)
# Find Caffe Dependencies
find_package(Caffe REQUIRED)
# Find JSON Dependencies
option (WITH_JSON "Use JSON" ON)
if(WITH_JSON)
find_package(nlohmann_json)
if(NOT nlohmann_json_FOUND)
set(WITH_JSON OFF)
message(STATUS "nlohmann_json Not Found")
endif()
endif()
# Add OpenCV dependencies
find_package(OpenCV REQUIRED)
if (${OpenCV_VERSION_MAJOR} EQUAL 2)
set(REQUIRED_OpenCV_LIBS opencv_core opencv_highgui)
else()
set(REQUIRED_OpenCV_LIBS opencv_core opencv_highgui opencv_imgcodecs)
endif()
# Add Boost dependencies
find_package(Boost
REQUIRED
COMPONENTS
filesystem
system
program_options
serialization
timer
)
# Find HDF5 dependencies
find_package(HDF5 1.8.12
REQUIRED
COMPONENTS
CXX
)
find_package(CUDA REQUIRED)
cuda_include_directories("${CMAKE_SOURCE_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}/include")
# Make sure to compile without the -pedantic, -Wundef, -Wnon-virtual-dtor
# and -fno-check-new flags since they trigger thousands of compilation warnings
# in the CUDA runtime
# Also remove -ansi that is incompatible with std=c++11.
string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-Wundef" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-Wnon-virtual-dtor" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-fno-check-new" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-ansi" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
include(CudaHelper) # Add custom CUDA helper functions
select_nvcc_arch_flags(CUDA_NVCC_FLAGS)
list(APPEND CUDA_NVCC_FLAGS "--default-stream per-thread")
list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
list(APPEND CUDA_NVCC_FLAGS "--expt-relaxed-constexpr")
list(APPEND CUDA_NVCC_FLAGS "-Xcudafe \"--display_error_number\"")
message(STATUS "Found Cuda. Using CUDA_NVCC_FLAGS=${CUDA_NVCC_FLAGS}")
message(STATUS "=============================================================")
message(STATUS "========== Adding RenderAndCompare Library ==================")
add_subdirectory(RenderAndCompare)
message(STATUS "=============================================================")
message(STATUS "====================== Adding Tools =========================")
add_subdirectory(tools)
message(STATUS "=============================================================")
message(STATUS "================ Configuration Summary ====================")
message(STATUS "Project Name: ${PROJECT_NAME}")
message(STATUS "C++ Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "C++ Standard: C++ ${CMAKE_CXX_STANDARD}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Build type Flags: ${CMAKE_BUILD_TYPE_FLAGS}")
message(STATUS "C++ compile flags: ${CMAKE_CXX_FLAGS}")
message(STATUS "Install Path: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Eigen Version: ${EIGEN_VERSION}")
message(STATUS "Caffe: ${Caffe_DIR} CUDA:${Caffe_HAVE_CUDA} CUDNN:${Caffe_HAVE_CUDNN}")
message(STATUS "OpenCV Version: ${OpenCV_VERSION}")
message(STATUS "HDF5 Version: ${HDF5_VERSION}")
message(STATUS "CUDA Version: ${CUDA_VERSION}")
message(STATUS "Boost Version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
if (WITH_JSON)
message(STATUS "Json: YES (${nlohmann_json_VERSION})")
else()
message(STATUS "Json: NO")
endif()
message(STATUS "=============================================================")