forked from smartsenselab/ssiglib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
167 lines (132 loc) · 6.1 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#root/CMakeLists.txt
#CMake Version Minimum Required
cmake_minimum_required (VERSION 2.8.11)
###############################################################################
# DEFINITION
###############################################################################
set(PROJECT_ACRONYM_STR "SSIGLib")
set(PROJECT_NAME_STR "Smart Surveillance Interest Group Library")
project(${PROJECT_ACRONYM_STR} CXX)
set(CMAKE_DEBUG_POSTFIX "_ssiglib_d")
#set(IMPORT_PREFIX , "ssiglib_")
set(CMAKE_RELEASE_POSTFIX "_ssiglib")
###############################################################################
# USER OPTIONS
###############################################################################
set(VERSION_MAJOR 0 CACHE STRING "Project major version number.")
set(VERSION_MINOR 1 CACHE STRING "Project minor version number.")
set(VERSION_PATCH 0 CACHE STRING "Project patch version number.")
#Option to check if 'test' will be available
option(BUILD_TESTS "Build tests" ON)
#Option to check if 'app' will be available
option(BUILD_APPS "Build APP's" ON)
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
# make it prominent in the GUI.
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." ON)
#Option to check if 'docs' will be build
option(BUILD_DOCS "Create and install the HTML based API documentation (requires Doxygen)" OFF)
option(ENABLE_COVERAGE "Enable coverage collection with GCov." OFF)
option(WITH_OPENMP "Enable OpenMP." ON)
option(WITH_CUDA "Enable Cuda." OFF)
mark_as_advanced(VERSION_MAJOR VERSION_MINOR VERSION_PATCH ENABLE_COVERAGE)
mark_as_advanced(CMAKE_CONFIGURATION_TYPES CMAKE_INSTALL_PREFIX)
###############################################################################
# CMake OPTIONS
###############################################################################
#Remove Warning CMP0054 from gtest cmake build
if(POLICY CMP0054)
cmake_policy(SET CMP0054 OLD)
endif()
if(POLICY CMP0042)
cmake_policy(SET CMP0042 OLD)
endif()
#Check compilers version
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE TEMP_COMPILER_VERSION)
if(TEMP_COMPILER_VERSION VERSION_LESS 4.7)
message(FATAL_ERROR "${PROJECT_NAME_STR} requires g++ 4.7 or greater. Installed version: ${CMAKE_CXX_COMPILER_VERSION}")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE TEMP_COMPILER_VERSION)
if (TEMP_COMPILER_VERSION VERSION_LESS 3.4)
message(FATAL_ERROR "${PROJECT_NAME_STR} requires Clang 3.4 or greater. Installed version: ${CMAKE_CXX_COMPILER_VERSION}")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
message(FATAL_ERROR "${PROJECT_NAME_STR} requires MSVC 1700 (MSVC 2012) or greater. Installed version: ${CMAKE_CXX_COMPILER_VERSION}")
endif()
else()
message(WARNING "You are using an unsupported compiler! ${PROJECT_NAME_STR} has only been tested with Clang, GCC and MSVC.")
endif()
#Definitions
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
if(WITH_OPENMP)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
endif()
if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
#if (OPENMP_FOUND)
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -Wall -std=c++11 -std=gnu++11")
#elseif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -std=gnu++11")#
#endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O4 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g")
#Solve plugin problem for some linux versions
set (CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
#if (OPENMP_FOUND)
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} /W3 /WX")
#elseif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX")
#endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
endif()
#Disable C4996
if(MSVC)
add_definitions(/D_SCL_SECURE_NO_WARNINGS=1)
add_definitions(/D_CRT_SECURE_NO_WARNINGS=1)
endif()
#Allows the solution folder utilization (for MSVC)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# If install location is default, set new default to "build/install"
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE )
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
#Enable tests if BUILD_TEST was checked by user
if(BUILD_TESTS)
enable_testing()
endif()
if(ENABLE_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 --coverage")
endif()
###############################################################################
# CMake Auxiliary Files
###############################################################################
include(cmake/SSIGOpenCVUtil.cmake)
include(cmake/SSIGCudaUtil.cmake)
include(cmake/SSIGModules.cmake)
include(cmake/SSIGUtil.cmake)
###############################################################################
# SUBDIRECTORIES
###############################################################################
#Add 3rdparty
add_subdirectory(3rdparty)
#Add modules
add_subdirectory(modules)
#Add documentation
add_subdirectory(doc)