-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
executable file
·129 lines (108 loc) · 5.57 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
cmake_minimum_required(VERSION 2.6)
#(Minimal benötigte CMake-Version wenn z.B. bestimmte CMake-Kommandos benutzt werden)
cmake_policy (SET CMP0020 NEW)
#cmake_policy(SET CMP0054 NEW)
# Der Projektname
project(bb_imageacquisition)
SET(CMAKE_POSITION_INDEPENDENT_CODE OFF)
set(CMAKE_AUTOMOC ON)
add_definitions( -DBOOST_ALL_NO_LIB )
find_package(Qt5Core REQUIRED) # PATHS "C:\\Qt\\Qt5.4.1\\5.4\\msvc2013_64_opengl"
set(Boost_USE_STATIC_LIBS ON)
find_package( Boost REQUIRED system filesystem program_options date_time)
find_package( OpenCV REQUIRED)
IF (DEFINED NO_ENCODER)
SET(USECUDA "false")
ELSE()
# find_package(CUDA REQUIRED COMPONENTS cuda cudart)
ENDIF()
# project dependecies
#CFLAGS:=-Os -Wall -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer
#CFLAGS+=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using Clang or GCC
# minimal optimmization and debug symbols for debug builds
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -g -rdynamic")
# enable optimization for release builds
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DQT_NO_DEBUG")
# enable C++1y
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -fPIC")
# enable all warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Woverloaded-virtual -Wnon-virtual-dtor -Wsign-promo -Wno-missing-braces") #-pedantic
# warnings are errors
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-error=unused-variable -Wno-error=unused-parameter")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++
# Force to always compile with W3 and treat warnings as errors
# W4 would be preferable, but causes to many warnings in included files
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
endif()
# warnings are errors
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
# disable warning 4503 on visual studio (boost)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4503")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# determine clang version
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
if (CLANG_VERSION_STRING VERSION_GREATER 3.5)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=inconsistent-missing-override")
endif()
# gcc doesn't know about unused-private-field warning
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-private-field")
# use Wdocumentation
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdocumentation")
# enable thread safety analysis
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wthread-safety")
# enable thread safety analysis
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wimplicit-fallthrough")
# implicit conversion warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # -Wfloat-conversion
# osx clang3.6 throw additional warnings
if(${APPLE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override -Wno-deprecated-declarations")
set(CMAKE_CXX_LINK_FLAGS_DEBUG "-lc++abi")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS_DEBUG}")
endif()
endif()
message("${CLANG_VERSION}")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# clang doesnt know about unused-but-set-variable warning
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-but-set-variable")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
# implicit conversion warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ") # -Wfloat-conversion
endif()
endif()
# use runtime analyzers when using clang/gcc in debug mode
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND
(GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9))
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-optimize-sibling-calls")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-optimize-sibling-calls")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=integer")
endif()
endif()
add_subdirectory(ImgAcquisition)
option(WITH_HALIDE "Build with halide support (slightly faster copying of images)." OFF)
if (WITH_HALIDE)
add_subdirectory(halidePreCompile)
endif()