-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
86 lines (68 loc) · 2.59 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
cmake_minimum_required (VERSION 3.5)
project(maav-software)
# Add path to search for modules
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")
# Set software source dir
set(SOFTWARE_SOURCE_DIR ${PROJECT_SOURCE_DIR})
# Set C++ standard to C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS ON)
# Add option to build modules
option(BUILD_GNC "Build the GNC module" ON)
option(BUILD_GCS "Build the GCS module" OFF)
option(BUILD_VISION "Build the vision module" ON)
option(BUILD_MISSION_PLANNING "Build the mission planning module" ON)
option(BUILD_GCS_CLIENT "Build the ground control station client" ON)
option(BUILD_TANFAN "Build the TivA nuc Network Forwarding ApplicatioN (TANFAN)" ON)
option(BUILD_IMU "Build the IMU driver" ON)
option(BUILD_TESTS "Build test cases" ON)
option(BUILD_OBSTACLES "Build obstacle detector" OFF)
option(BUILD_PLOTTER "Build plotting tool" ON)
option(BUILD_VISUALIZER "Build localization visualization tool" OFF)
option(BUILD_SIM "Build sim sensors and plugins (Note: this will not build Px4 Firmware or Gazebo" ON)
# Set all compiled libraries to be placed in software/lib
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
# Set all compiled executables to be placed in software/bin
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
# Find all globally required libraries
find_package(YAMLCPP REQUIRED)
find_package(ZCM REQUIRED)
find_package(libusb-1.0 REQUIRED)
# Include generated zcm messages and mavlink headers
include_directories(SYSTEM
${PROJECT_SOURCE_DIR}/generated
${PROJECT_SOURCE_DIR}/thirdparty/mavlink/include
${LIBUSB_1_INCLUDE_DIRS}
)
# Set include directory
set(SW_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
# Set the build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Find headers
include(CheckIncludeFiles)
# Set global C++ flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wall -Wextra -pedantic -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++17")
# Set global debug flags
# Helps with debugging memory and thread issues
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
# Add source directory
add_subdirectory(src)
add_subdirectory(drivers)
if(BUILD_SIM)
add_subdirectory(sim)
endif()
if(BUILD_VISUALIZER OR BUILD_PLOTTER)
add_subdirectory(tools)
endif()
# Setup testing options
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
message(STATUS "")
message(STATUS "Building a ${CMAKE_BUILD_TYPE} build")
message(STATUS "")