-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
62 lines (51 loc) · 2.97 KB
/
Copy pathCMakeLists.txt
File metadata and controls
62 lines (51 loc) · 2.97 KB
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
cmake_minimum_required(VERSION 2.8)
project (RPI)
# use c++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# use >= gcc/g++7
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7)
message(FATAL_ERROR "Require at least g++-7")
endif()
# set build type based on makefile target
# CMAKE_BUILD_TYPE set in Makefile
# Ignore Pi Specific Warning from JSON lib: -Wno-psabi
message(STATUS "Building in ${CMAKE_BUILD_TYPE} Mode")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-psabi -Wno-cast-function-type")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# =================================== load Dependencies globally for all subdirs ===================================
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/src/c++/cmake")
# Find the packages
# find_package(BoostLib REQUIRED) # (really just finds Boost_* but causes an infinite loop since script searches for Boost)
find_package(JSON REQUIRED) # using https://github.com/nlohmann/json
find_package(CLI11 REQUIRED) # using https://cliutils.gitlab.io/CLI11Tutorial/
find_package(WiringPi REQUIRED) # using https://github.com/WiringPi/WiringPi
find_package(Pistache REQUIRED) # using https://github.com/pistacheio/pistache
find_package(Raspicam REQUIRED) # using https://github.com/cedricve/raspicam
# Include the package's header files
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/c++/include") # contains OUR headers
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/c++/include/helpers")
include_directories(SYSTEM ${JSON_INCLUDE_DIR}) # use system to ingore release warnings from this library
include_directories(${CLI11_INCLUDE_DIR})
include_directories(${WiringPi_INCLUDE_DIR}) # pair with target_link_libraries(<projName> ${WiringPi_LIBS})
include_directories(${Pistache_INCLUDE_DIR}) # pair with Pistache_LIBRARIES
include_directories(${Raspicam_INCLUDE_DIR}) # pair with Raspicam_LIBRARIES
# include_directories(${Boost_INCLUDE_DIRS}) # pair with Boost_LIBRARIES
# ============================================ Build individual subdirs ============================================
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) # store produce binaries in RaspberryPi/bin/*
endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
# add more folders here as needed (order matters, executable last with most independent first)
# these trigger the CMakeLists.txt file to be called in the listed dirs
add_subdirectory(src/c++/version) # Get Git Commit/Revision Info: https://stackoverflow.com/a/21028226/13933174
add_subdirectory(src/c++/camera)
add_subdirectory(src/c++/network)
add_subdirectory(src/c++/gpio)
add_subdirectory(src/c++/CLI)
add_subdirectory(src/c++/UI)
add_subdirectory(src/c++/main) # executable