-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·177 lines (158 loc) · 4.5 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
cmake_minimum_required(VERSION 3.10)
project(chernobot)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${chernobot_SOURCE_DIR}/cmake")
set(BIN_DIR ${chernobot_SOURCE_DIR})
if(APPLE)
if (EXISTS "/usr/local/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/local/bin/clang")
include_directories("/usr/local/include")
endif()
endif()
# Set warning levels and debug/release specific flags
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
endif()
find_package(SDL2 REQUIRED)
find_package(FFMPEG REQUIRED)
# Build executable
include_directories(${Boost_INCLUDE_DIR})
include_directories(${SDL2_INCLUDE_DIR})
include_directories(${chernobot_SOURCE_DIR}/ext/glad/include)
include_directories(${chernobot_SOURCE_DIR}/ext/imgui)
include_directories(${chernobot_SOURCE_DIR}/ext/serial/include)
include_directories(${chernobot_SOURCE_DIR}/ext)
include_directories(${chernobot_SOURCE_DIR}/ext/expected/tl)
include_directories(${chernobot_SOURCE_DIR}/ext/stb)
add_executable(chernobot src/main.cpp)
if(APPLE)
add_definitions(-x objective-c++)
set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework AVFoundation -w")
set(
PLATFORM_FILES
src/advd/streamref_avfoundation.mm
)
endif()
target_sources(chernobot PUBLIC ${PLATFORM_FILES})
find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h)
find_path(AVFORMAT_INCLUDE_DIR libavformat/avformat.h)
find_path(AVUTIL_INCLUDE_DIR libavutil/avutil.h)
find_path(AVDEVICE_INCLUDE_DIR libavdevice/avdevice.h) #TODO dont be lazy, include swscale and avfilter
target_include_directories(chernobot PRIVATE "/usr/local/include/SDL2" ${AVCODEC_INCLUDE_DIR} ${AVFORMAT_INCLUDE_DIR} ${AVUTIL_INCLUDE_DIR} ${AVDEVICE_INCLUDE_DIR})
find_library( AVUTIL_LIBRARY
NAMES avutil
HINTS
$ENV{AVUTILDIR}
PATH_SUFFIXES lib64 lib bin
PATHS
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
/mingw
)
find_library( AVDEVICE_LIBRARY
NAMES avdevice
HINTS
$ENV{AVUTILDIR}
PATH_SUFFIXES lib64 lib bin
PATHS
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
/mingw
)
find_library( AVCODEC_LIBRARY
NAMES avcodec
HINTS
$ENV{AVUTILDIR}
PATH_SUFFIXES lib64 lib bin
PATHS
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
/mingw
)
find_library( AVFORMAT_LIBRARY
NAMES avformat
HINTS
$ENV{AVUTILDIR}
PATH_SUFFIXES lib64 lib bin
PATHS
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
/mingw
)
find_library( AVFILTER_LIBRARY
NAMES avfilter
HINTS
$ENV{AVUTILDIR}
PATH_SUFFIXES lib64 lib bin
PATHS
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
/mingw
)
find_library( SWSCALE_LIBRARY
NAMES swscale
HINTS
$ENV{AVUTILDIR}
PATH_SUFFIXES lib64 lib bin
PATHS
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
/mingw
)
add_definitions(-DIMGUI_IMPL_OPENGL_LOADER_GLAD)
file(GLOB_RECURSE chernobot_SRC "src/*.cpp")
target_sources(chernobot PUBLIC ${chernobot_SRC})
file(GLOB Imgui_SRC "ext/imgui/*.cpp")
target_sources(chernobot PUBLIC ${Imgui_SRC})
target_sources(chernobot PUBLIC "ext/imgui/examples/imgui_impl_sdl.cpp" "ext/imgui/examples/imgui_impl_opengl3.cpp")
file(GLOB_RECURSE Serial_SRC "ext/serial/src/*.cc")
target_sources(chernobot PUBLIC ${Serial_SRC})
target_sources(chernobot PUBLIC ${chernobot_SOURCE_DIR}/ext/glad/src/glad.c)
target_link_libraries(chernobot ${SDL2_LIBRARY})
find_package(OpenCV REQUIRED)
target_link_libraries(chernobot ${OpenCV_LIBS})
target_link_libraries(chernobot ${AVUTIL_LIBRARY} ${AVDEVICE_LIBRARY} ${AVCODEC_LIBRARY} ${AVFORMAT_LIBRARY} ${AVFILTER_LIBRARY} ${SWSCALE_LIBRARY})
#target_link_libraries(chernobot "-lavutil" "-lavdevice" "-lavcodec" "-lavformat" "-lavfilter" "-lswscale")
message( "AVUTIL_LIBRARY is ${AVDEVICE_LIBRARY}" )
#dependencies for serial lib - replace with rs232 also incomplete for linux and windows
if(APPLE)
find_library(IOKIT_LIBRARY IOKit)
find_library(FOUNDATION_LIBRARY Foundation)
target_link_libraries(chernobot ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(chernobot dl stdc++fs)
endif()
install(TARGETS chernobot RUNTIME DESTINATION ${BIN_DIR})