forked from dziedada/467Final
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (55 loc) · 1.96 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
cmake_minimum_required (VERSION 3.5)
project(467-final-project)
# 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_VISION "Build the vision system" ON)
option(BUILD_TESTS "Build test cases" OFF)
option(BUILD_HOUGH_CIRCLE "Build test cases" OFF)
option(BUILD_PLANNER "Build planner system" 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)
find_package(LCM REQUIRED)
# Include generated zcm messages and include folder
include_directories(SYSTEM
${PROJECT_SOURCE_DIR}/generated
${PROJECT_SOURCE_DIR}/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)
# Setup testing options
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
message(STATUS "")
message(STATUS "Building a ${CMAKE_BUILD_TYPE} build")
message(STATUS "")