-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
119 lines (103 loc) · 4.09 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
cmake_minimum_required (VERSION 2.8.11)
#--------------------------------------------------------------------------
# must go before the project command
#--------------------------------------------------------------------------
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
if(DEFINED CMAKE_BUILD_TYPE)
set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
endif()
#--------------------------------------------------------------------------
# project name
#--------------------------------------------------------------------------
project(ROAM)
#--------------------------------------------------------------------------
# options
#--------------------------------------------------------------------------
option(WITH_CUDA "Use Cuda?" OFF)
option(WITH_OPENMP "Enable OpenMP support?" ON)
option(WITH_TEST "Compile tests? (requires gtest)" OFF)
option(WITH_DOCUMENTATION "Create documentation? (requires doxygen)" OFF)
#--------------------------------------------------------------------------
# cmake
#--------------------------------------------------------------------------
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 14)
#--------------------------------------------------------------------------
# overcome issues caused by our friends from MS
#--------------------------------------------------------------------------
if(MSVC)
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # parallel build
add_definitions(-D_CRT_SECURE_NO_WARNINGS) # blah
add_definitions(-DUSING_CMAKE=1)
endif()
#--------------------------------------------------------------------------
# Save libs and executables in the same place
#--------------------------------------------------------------------------
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Output directory for applications" )
#--------------------------------------------------------------------------
# add packages
#--------------------------------------------------------------------------
macro(CANONIFY_BOOL var)
if (${var})
set(${var} TRUE)
else()
set(${var} FALSE)
endif()
endmacro()
# openmp
IF(WITH_OPENMP)
FIND_PACKAGE(OpenMP)
CANONIFY_BOOL(OPENMP_FOUND)
message(STATUS "OpenMP found: " ${OPENMP_FOUND})
IF(OPENMP_FOUND)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
ENDIF()
ADD_DEFINITIONS(-DWITH_OPENMP)
ENDIF()
# opencv
find_package(OpenCV REQUIRED)
CANONIFY_BOOL(OpenCV_FOUND)
message(STATUS "OpenCV found: " ${OpenCV_FOUND})
# cuda
if(WITH_CUDA)
find_package(CUDA REQUIRED)
CANONIFY_BOOL(CUDA_FOUND)
message(STATUS "CUDA found: " ${CUDA_FOUND})
if (CUDA_FOUND)
message("CUDA FOUND!")
set(CUDA_CHECK ON)
endif()
endif()
# check if Doxygen is installed
if(WITH_DOCUMENTATION)
find_package(Doxygen)
CANONIFY_BOOL(DOXYGEN_FOUND)
message(STATUS "Doxygen found: " ${DOXYGEN_FOUND})
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")
# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif()
#--------------------------------------------------------------------------
# projects
#--------------------------------------------------------------------------
add_subdirectory(roam)
add_subdirectory(roam_apps)
add_subdirectory(tools)