-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
130 lines (108 loc) · 3.43 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
cmake_minimum_required(VERSION 3.16)
option(BUILD_FOR_PI "Build the actual binary for the RPi" ON)
option(BUILD_FOR_CAM "Build the actual binary for the RPi Cam instead of test mode" ON)
if(BUILD_FOR_PI)
set(CMAKE_TOOLCHAIN_FILE cmake/arm-none-linux-gnueabihf.toolchain.cmake)
endif()
set(CMAKE_VERBOSE_MAKEFILE OFF)
include(cmake/git_version.cmake)
project(robotpi VERSION ${GIT_VERSION})
# store GIT version info to file
configure_file(src/git_version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/git_version.h)
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
endif()
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3")
set(CMAKE_C_FLAGS_RELEASE "-Ofast")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
set(CMAKE_ASM_FLAGS "-x assembler-with-cpp -c")
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
if(BUILD_FOR_PI)
find_package(MMAL REQUIRED)
add_compile_options(
-Wall
-fmessage-length=0
-march=armv8-a+crc
-mfpu=neon-fp-armv8
-mtune=cortex-a53
-mfloat-abi=hard
-mhard-float
-munaligned-access
-mvectorize-with-neon-quad
-funroll-loops
-ftree-vectorize
-funsafe-math-optimizations
-Wno-int-in-bool-context
-Wno-psabi
-funroll-loops
)
else()
set(CMAKE_VERBOSE_MAKEFILE 1)
add_compile_options(
-D_USE_MATH_DEFINES
-march=native
-mtune=native
-ftree-vectorize
-funroll-loops
# -fopt-info-vec-optimized-missed
)
endif()
if(BUILD_FOR_CAM)
find_package(MMAL REQUIRED)
list(APPEND app_SOURCES
src/rpi/RPiCamera.cpp
src/rpi/TigerComm.cpp
src/rpi/main.cpp
src/rpi/RobotPi.cpp
src/rpi/StatGenerator.cpp
src/rpi/tests.cpp
)
else()
list(APPEND app_SOURCES
src/pc/test_main.cpp
)
endif()
list(APPEND common_SOURCES
src/steps/CameraCalibration.cpp
src/steps/ColorClassifierYUV.cpp
src/steps/MiniPreview.cpp
src/steps/RegionExtractor.cpp
src/steps/BallLocalisation.cpp
src/steps/RleRecorder.cpp
src/steps/PointDistanceSensor.cpp
src/steps/YPresummer.cpp
src/interface/Command.cpp
src/interface/FrameYUV420.cpp
src/interface/ProcessingStep.cpp
src/interface/RLEFrame.cpp
src/util/BallTracker.cpp
src/util/Camera.cpp
src/util/Circle.cpp
src/util/Color.cpp
src/util/crc.cpp
src/util/Line.cpp
src/util/Presummer.cpp
src/util/RLEFile.cpp
src/util/TimeSync.cpp
src/util/WorkerPool.cpp
src/util/UDPSocket.cpp
src/util/YUVFile.cpp
)
add_executable(robotpi ${app_SOURCES} ${common_SOURCES})
target_include_directories(robotpi PRIVATE src ${MMAL_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
target_link_libraries(robotpi PRIVATE ${MMAL_LIBRARIES} pthread ${OpenCV_LIBS})
install(TARGETS robotpi DESTINATION /usr/local/bin)
install(FILES systemd/robotpi.service DESTINATION /usr/lib/systemd/system)