Fork from inav at github. Modified for some special functions needs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.4 KiB

3 years ago
  1. cmake_minimum_required(VERSION 3.13...3.18)
  2. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
  3. set(MAIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
  4. set(MAIN_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
  5. set(MAIN_UTILS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/utils")
  6. set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/main")
  7. set(SVD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dev/svd")
  8. set(DOWNLOADS_DIR "${MAIN_DIR}/downloads")
  9. set(TOOLS_DIR "${MAIN_DIR}/tools")
  10. set(TOOLCHAIN_OPTIONS none arm-none-eabi)
  11. set(TOOLCHAIN "arm-none-eabi" CACHE STRING "Toolchain to use. Available: ${TOOLCHAIN_OPTIONS}")
  12. set_property(CACHE TOOLCHAIN PROPERTY STRINGS ${TOOLCHAIN_OPTIONS})
  13. if("" STREQUAL TOOLCHAIN)
  14. set(TOOLCHAIN none)
  15. endif()
  16. if (NOT ${TOOLCHAIN} IN_LIST TOOLCHAIN_OPTIONS)
  17. message(FATAL_ERROR "Invalid toolchain ${TOOLCHAIN}. Valid options are: ${TOOLCHAIN_OPTIONS}")
  18. endif()
  19. option(COMPILER_VERSION_CHECK "Ensure the compiler matches the expected version" ON)
  20. include(GetGitRevisionDescription)
  21. get_git_head_revision(GIT_REFSPEC GIT_SHA1)
  22. string(SUBSTRING ${GIT_SHA1} 0 8 GIT_REV)
  23. # Load settings related functions, so the tests can use them
  24. include(main)
  25. include(settings)
  26. if(TOOLCHAIN STREQUAL none)
  27. add_subdirectory(src/test)
  28. else()
  29. set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TOOLCHAIN}.cmake")
  30. include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TOOLCHAIN}-checks.cmake")
  31. endif()
  32. project(INAV VERSION 5.0.0)
  33. enable_language(ASM)
  34. set(CMAKE_C_STANDARD 99)
  35. set(CMAKE_C_EXTENSIONS ON)
  36. set(CMAKE_C_STANDARD_REQUIRED ON)
  37. set(CMAKE_CXX_STANDARD 11)
  38. set(CMAKE_CXX_EXTENSIONS ON)
  39. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  40. find_program(RUBY_EXECUTABLE ruby)
  41. if (NOT RUBY_EXECUTABLE)
  42. message(FATAL_ERROR "Could not find ruby")
  43. endif()
  44. if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  45. set(IS_RELEASE_BUILD ON)
  46. endif()
  47. set(FIRMWARE_VERSION ${PROJECT_VERSION})
  48. option(WARNINGS_AS_ERRORS "Make all warnings into errors")
  49. message("-- toolchain: ${TOOLCHAIN}, WARNINGS_AS_ERRORS: ${WARNINGS_AS_ERRORS}")
  50. set(COMMON_COMPILE_DEFINITIONS
  51. FC_VERSION_MAJOR=${CMAKE_PROJECT_VERSION_MAJOR}
  52. FC_VERSION_MINOR=${CMAKE_PROJECT_VERSION_MINOR}
  53. FC_VERSION_PATCH_LEVEL=${CMAKE_PROJECT_VERSION_PATCH}
  54. )
  55. include(openocd)
  56. include(svd)
  57. include(stm32)
  58. add_subdirectory(src)
  59. collect_targets()
  60. message("-- Build type: ${CMAKE_BUILD_TYPE}")
  61. include(ci)