forked from jtanx/omxcv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
92 lines (75 loc) · 2.85 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
#omxcv cmake configuration file
cmake_minimum_required (VERSION 2.8)
project (omxcv)
include (FindPkgConfig)
#Versioning
execute_process (COMMAND git rev-parse --short HEAD
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE OMXCV_VERSION
)
execute_process (COMMAND git show -s --format=%ci HEAD
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE OMXCV_DATE
)
#Required libraries
find_package (OpenCV 2.4 REQUIRED)
include_directories (${OpenCV_INCLUDE_DIR})
find_package (Threads REQUIRED) # For pthreads
pkg_check_modules (LIBAVFORMAT libavformat REQUIRED)
pkg_check_modules (LIBAVCODEC libavcodec REQUIRED)
pkg_check_modules (LIBAVUTIL libavutil REQUIRED)
include_directories (${LIBAVFORMAT_INCLUDE_DIRS})
link_directories (${LIBAVFORMAT_LIBRARY_DIRS})
include_directories (${LIBAVCODEC_INCLUDE_DIRS})
link_directories (${LIBAVCODEC_LIBRARY_DIRS})
include_directories (${LIBAVUTIL_INCLUDE_DIRS})
link_directories (${LIBAVUTIL_LIBRARY_DIRS})
#Optional libraries
CHECK_LIBRARY_EXISTS(tcmalloc malloc "" HAVE_LIBTCMALLOC)
CHECK_LIBRARY_EXISTS(profiler malloc "" HAVE_LIBPROFILER)
#Raspberry Pi specific includes.
#Requires the installation of the userland package.
include_directories (/opt/vc/include /opt/vc/src/hello_pi/libs/ilclient)
include_directories (/opt/vc/include/interface/vcos/pthreads)
include_directories (/opt/vc/include/IL /opt/vc/include/interface/vmcs_host/linux)
link_directories (/opt/vc/lib /opt/vc/src/hello_pi/libs/ilclient)
#Compile options
if (CMAKE_COMPILER_IS_GNUCXX)
set (CMAKE_CXX_FLAGS "-Wall -Wno-variadic-macros -std=c++11 -pedantic -g")
endif (CMAKE_COMPILER_IS_GNUCXX)
#Source files
set (HEADERS
omxcv-config.h
omxcv.h
image_gpu.h
)
set (SOURCE
image_gpu.cpp
omxcv.cpp
omxcv_jpeg.cpp
)
#Enable NEON extensions
if (ENABLE_NEON)
set (SOURCE ${SOURCE} bgr2rgb.s)
set_property (SOURCE bgr2rgb.s PROPERTY LANGUAGE C)
set_source_files_properties (bgr2rgb.s PROPERTIES COMPILE_FLAGS "-mfpu=neon -mcpu=cortex-a7 -g")
endif (ENABLE_NEON)
#Generate config header
configure_file (omxcv-config.h.in omxcv-config.h)
#Library creation
add_library (omxcv ${HEADERS} ${SOURCE})
target_link_libraries (omxcv LINK_PRIVATE EGL GLESv2)
target_link_libraries (omxcv LINK_PRIVATE ${LIBAVFORMAT_LIBRARIES} ${LIBAVCODEC_LIBRARIES} ${LIBAVUTIL_LIBRARIES} ${OpenCV_LIBS})
target_link_libraries (omxcv LINK_PRIVATE bcm_host openmaxil bcm_host vcos vchiq_arm ilclient)
target_link_libraries (omxcv LINK_PRIVATE ${CMAKE_THREAD_LIBS_INIT})
if (HAVE_LIBTCMALLOC)
target_link_libraries (omxcv LINK_PUBLIC tcmalloc)
endif (HAVE_LIBTCMALLOC)
if (HAVE_LIBPROFILER)
target_link_libraries (omxcv LINK_PUBLIC profiler)
endif (HAVE_LIBPROFILER)
#Test executable
add_executable (omxcv-test omxcv-test.cpp)
add_executable (glsl-test glsl-test.cpp)
target_link_libraries (omxcv-test LINK_PUBLIC omxcv)
target_link_libraries (glsl-test LINK_PUBLIC omxcv)