fixed pitot sensor
[inav.git] / CMakeLists.txt
blobdb06e1a7183a1455968a16b558041ee8ad76159d
1 cmake_minimum_required(VERSION 3.13...3.18)
3 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
5 set(MAIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
6 set(MAIN_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
7 set(MAIN_UTILS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/utils")
8 set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/main")
9 set(SVD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dev/svd")
10 set(DOWNLOADS_DIR "${MAIN_DIR}/downloads")
11 set(TOOLS_DIR "${MAIN_DIR}/tools")
13 option(SITL "SITL build for host system" OFF)
15 set(TOOLCHAIN_OPTIONS none arm-none-eabi host)
16 if (SITL)
17     set(TOOLCHAIN "host" CACHE STRING "Toolchain to use. Available: ${TOOLCHAIN_OPTIONS}")
18 else()
19     set(TOOLCHAIN "arm-none-eabi" CACHE STRING "Toolchain to use. Available: ${TOOLCHAIN_OPTIONS}")
20 endif()
22 set_property(CACHE TOOLCHAIN PROPERTY STRINGS ${TOOLCHAIN_OPTIONS})
23 if("" STREQUAL TOOLCHAIN)
24     set(TOOLCHAIN none)
25 endif()
26 if (NOT ${TOOLCHAIN} IN_LIST TOOLCHAIN_OPTIONS)
27     message(FATAL_ERROR "Invalid toolchain ${TOOLCHAIN}. Valid options are: ${TOOLCHAIN_OPTIONS}")
28 endif()
30 option(COMPILER_VERSION_CHECK "Ensure the compiler matches the expected version" ON)
32 include(GetGitRevisionDescription)
33 get_git_head_revision(GIT_REFSPEC GIT_SHA1)
34 string(SUBSTRING ${GIT_SHA1} 0 8 GIT_REV)
36 # Load settings related functions, so the tests can use them
37 include(main)
38 include(settings)
40 if(TOOLCHAIN STREQUAL none)
41     add_subdirectory(src/test)
42 else()
43     if (SITL)
44         include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TOOLCHAIN}.cmake")
45     else()
46         set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TOOLCHAIN}.cmake")
47         include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TOOLCHAIN}-checks.cmake")
48     endif()
49 endif()
51 project(INAV VERSION 7.0.0)
53 enable_language(ASM)
55 set(CMAKE_C_STANDARD 99)
56 set(CMAKE_C_EXTENSIONS ON)
57 set(CMAKE_C_STANDARD_REQUIRED ON)
58 set(CMAKE_CXX_STANDARD 11)
59 set(CMAKE_CXX_EXTENSIONS ON)
60 set(CMAKE_CXX_STANDARD_REQUIRED ON)
62 if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
63     set(IS_RELEASE_BUILD ON)
64 endif()
66 set(FIRMWARE_VERSION ${PROJECT_VERSION})
68 option(WARNINGS_AS_ERRORS "Make all warnings into errors")
69 message("-- toolchain: ${TOOLCHAIN}, WARNINGS_AS_ERRORS: ${WARNINGS_AS_ERRORS}")
71 set(COMMON_COMPILE_DEFINITIONS
72     FC_VERSION_MAJOR=${CMAKE_PROJECT_VERSION_MAJOR}
73     FC_VERSION_MINOR=${CMAKE_PROJECT_VERSION_MINOR}
74     FC_VERSION_PATCH_LEVEL=${CMAKE_PROJECT_VERSION_PATCH}
77 if (NOT SITL)
78     include(openocd)
79     include(svd)
80 endif()
82 include(stm32)
83 include(at32)
84 include(sitl)
86 add_subdirectory(src)
88 collect_targets()
90 message("-- Build type: ${CMAKE_BUILD_TYPE}")
91 include(ci)