forked from slowmoVideo/slowmoVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
255 lines (202 loc) · 7.7 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
cmake_minimum_required(VERSION 3.1)
project(slowmoVideo)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed.")
endif()
set(CMAKE_CXX_STANDARD 14)
# Partly from https://doc.qt.io/qt-5/cmake-get-started.html#build-a-gui-executable
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
set(CMAKE_MODULE_PATH
${slowmoVideo_SOURCE_DIR}/cmake
)
# Make a version file containing the current version from git.
#
include(GetGitRevisionDescription)
git_describe(VERSION --dirty=-dev)
if (VERSION MATCHES "^v([0-9]+)\\.([0-9]+)(\\.([0-9]+))?(-[a-zA-Z0-9]+)?$")
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)(\\.([0-9]+))?(-[a-zA-Z0-9]+)?$" "\\1" PROJECT_VERSION_MAJOR "${VERSION}")
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)(\\.([0-9]+))?(-[a-zA-Z0-9]+)?$" "\\2" PROJECT_VERSION_MINOR "${VERSION}")
if (VERSION MATCHES "^v([0-9]+)\\.([0-9]+)(\\.([0-9]+))(-[a-zA-Z0-9]+)?$")
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)(\\.([0-9]+))(-[a-zA-Z0-9]+)?$" "\\3" PROJECT_VERSION_PATCH "${VERSION}")
else ()
set(PROJECT_VERSION_PATCH "0")
endif ()
if (VERSION MATCHES "^v([0-9]+)\\.([0-9]+)(\\.([0-9]+))(-[a-zA-Z0-9]+)$")
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)(\\.([0-9]+))(-[a-zA-Z0-9]+)$" "\\4" PROJECT_VERSION_SHA1 "${VERSION}")
else ()
set(PROJECT_VERSION_SHA1 "")
endif ()
else ()
set(PROJECT_VERSION_MAJOR "0")
set(PROJECT_VERSION_MINOR "6")
set(PROJECT_VERSION_PATCH "0")
endif ()
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
message(STATUS "Building slowmoVideo ${PROJECT_VERSION}")
configure_file(src/version.h.in version.h)
### Compiler options ###
if (APPLE)
# To compile with clang:
#set(CMAKE_CXX_COMPILER "clang++")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall --verbose")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -mtune=corei7")
# Set additional project information
set(COMPANY "granjow")
set(COPYRIGHT "Copyright (c) 2011 Simon A. Eugster (Granjow). All rights reserved.")
set(IDENTIFIER "net.granjow.slomoui")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g")
endif()
if(CMAKE_TOOLCHAIN_FILE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMXE")
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -DMXE")
endif(CMAKE_TOOLCHAIN_FILE)
### CMake Configuration ###
option (ENABLE_TESTS "Build the unit tests" FALSE)
set(ADDITIONAL_LIBS "")
if(MSYS)
message(STATUS "MSYS system detected.")
include("${PROJECT_SOURCE_DIR}/cmake/MingwCrossEnv.cmake")
endif(MSYS)
### Find packages ###
# Check if environment variable QTDIR is set.
# needed for Qt5
# Extra security for windows environment as well.
if (DEFINED ENV{QTDIR})
set(CMAKE_PREFIX_PATH $ENV{QTDIR} ${CMAKE_PREFIX_PATH})
endif ()
if (APPLE)
set(DEST "slowmoUI.app/Contents/Tools/bin")
else()
set(DEST "bin")
endif()
include(cmake/macros.cmake)
find_package(Qt5Core QUIET)
if (Qt5Core_FOUND)
message(STATUS "Using Qt5")
set(USE_QT TRUE)
# go on with other packages
find_package(Qt5 COMPONENTS Core Widgets Gui Xml Script REQUIRED)
if (Qt5_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif (Qt5_POSITION_INDEPENDENT_CODE)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
# ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
include_directories(${Qt5Core_INCLUDES})
include_directories(${Qt5Widgets_INCLUDES})
include_directories(${Qt5Gui_INCLUDES})
include_directories(${Qt5Xml_INCLUDES})
include_directories(${Qt5Script_INCLUDES})
# set up a mapping so that the Release configuration for the Qt imported target is
# used in the COVERAGE CMake configuration.
#set_target_properties(Qt5::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "DEBUG")
endif (Qt5Core_FOUND)
message("Qt libraries found at : ${Qt5Gui_LIBRARIES} / ${QT_LIBRARIES}" )
set (USE_QTKIT OFF CACHE BOOL "Build with the QTKit encoder")
set (USE_FFMPEG ON CACHE BOOL "Build with the FFMPEG encoder")
set (USE_DBUS OFF CACHE BOOL "Build with the DBUS notification support")
if(NOT MSYS)
find_package(FFMPEG)
else(NOT MSYS)
# Handled by MingwCrossEnv.cmake to avoid errors like:
# libavformat.a(avisynth.o):avisynth.c:(.text+0x6b): undefined reference to `AVIStreamRelease@4'
endif(NOT MSYS)
# not here anymore
#include_directories(${FFMPEG_INCLUDE_DIR})
#include_directories("/usr/include/ffmpeg/")
#link_directories(${FFMPEG_LIBRARY_DIR})
if (APPLE AND USE_QTKIT)
find_package(QTKIT)
message(STATUS "QTKIT find at ${QTKIT_LIBRARY} ")
set(ADDITIONAL_LIBS "-framework Cocoa -framework QTKit -framework QuartzCore -framework AppKit -framework OpenCL")
endif()
# Find OpenCV, you may need to set OpenCV_DIR variable
# to the absolute path to the directory containing OpenCVConfig.cmake file
# via the command line or GUI
find_package(OpenCV REQUIRED)
# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
if (${OpenCV_VERSION_MAJOR} EQUAL 3)
set(HAS_OCV_VERSION_3 ON)
else()
set(HAS_OCV_VERSION_3 OFF)
endif()
include_directories(${OPENCV_INCLUDE_DIRS})
# for config.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
### Set up libraries ###
if(MSYS)
set(EXTERNAL_LIBS ${FFMPEG_LIBRARIES} ${QT_LIBRARIES} ${OpenCV_LIBS_OPT} ${OpenCV_EXTRA_LIBS_OPT} ${ADDITIONAL_LIBS})
else(MSYS)
set(EXTERNAL_LIBS ${QT_LIBRARIES} ${OpenCV_LIBS} ${ADDITIONAL_LIBS} ${FFMPEG_LIBRARIES})
endif(MSYS)
### Information output
set(BUILD_SLOWMO "NO")
#if(QT_LIBRARIES AND FFMPEG_FOUND)
if(USE_QT AND FFMPEG_FOUND)
set(BUILD_SLOWMO "YES")
#endif(QT_LIBRARIES AND FFMPEG_FOUND)
endif()
if(NOT FFMPEG_SWSCALE_FOUND)
if(CMAKE_TOOLCHAIN_FILE)
else(CMAKE_TOOLCHAIN_FILE)
set(BUILD_SLOWMO "NO")
endif(CMAKE_TOOLCHAIN_FILE)
endif(NOT FFMPEG_SWSCALE_FOUND)
## Include projects to build ##
include_directories(src/tr)
add_subdirectory(src/lib)
add_subdirectory(src/lib/libsvflow)
add_subdirectory(src/libgui)
add_subdirectory(src/project)
add_subdirectory(src/slowmoCLI)
add_subdirectory(src/slowmoUI)
add_subdirectory(src/slowmoFlowEdit)
add_subdirectory(src/slowmoRenderer)
add_subdirectory(src/visualizeFlow)
if(ENABLE_TESTS)
SET(QT_USE_QTTEST TRUE)
## add_subdirectory(slowmoVideo/test)
add_subdirectory(slowmoVideo/unittests)
endif(ENABLE_TESTS)
##### SV END #####
message("==================slowmoVideo========================")
message("* (info) slowmoVideo installation goes to ${CMAKE_INSTALL_PREFIX}.")
message(" (Can be adjusted with -DCMAKE_INSTALL_PREFIX=your_path. Default is ${SV_INST_DIR}.)")
#if(NOT QT_LIBRARIES)
if (NOT USE_QT)
message("Qt5 libraries could not be found.")
#endif(NOT QT_LIBRARIES)
endif(NOT USE_QT)
if(NOT FFMPEG_FOUND)
message("x ffmpeg libraries could not be found.")
else(NOT FFMPEG_FOUND)
message("* (ok) ffmpeg found at ${FFMPEG_LIBRARY_DIR}")
endif(NOT FFMPEG_FOUND)
if(NOT FFMPEG_SWSCALE_FOUND)
message("x libswscale could not be found.")
endif(NOT FFMPEG_SWSCALE_FOUND)
if(NOT OpenCV_VERSION)
message("x OpenCV could not be found.")
else(NOT OpenCV_VERSION)
message("* (ok) OpenCV ${OpenCV_VERSION} found at ${OpenCV_INCLUDE_DIRS}.")
endif(NOT OpenCV_VERSION)
message("* slowmoVideo will be built: ---${BUILD_SLOWMO}---")
message("=======================END===========================")
message("")
if(NOT BUILD_SLOWMO)
message(FATAL_ERROR "Cannot build slowmoVideo, please install the missing packages first.")
endif(NOT BUILD_SLOWMO)
configure_file(src/config.h.in config.h)