CMakeLists.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. cmake_minimum_required(VERSION 3.13)
  2. # Note: this CMakeLists.txt can be used as a top-level CMakeLists.txt for the SDK itself. For all other uses
  3. # it is included as a subdirectory via the pico_sdk_init() method provided by pico_sdk_init.cmake
  4. if (NOT TARGET _pico_sdk_inclusion_marker)
  5. add_library(_pico_sdk_inclusion_marker INTERFACE)
  6. # This is a no-op unless we are the top-level CMakeLists.txt
  7. include(pico_sdk_init.cmake)
  8. project(pico_sdk C CXX ASM)
  9. string(REGEX MATCH "Clang" PICO_C_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}")
  10. string(REGEX MATCH "GNU" PICO_C_COMPILER_IS_GNU "${CMAKE_C_COMPILER_ID}")
  11. string(REGEX MATCH "IAR" PICO_C_COMPILER_IS_IAR "${CMAKE_C_COMPILER_ID}")
  12. pico_register_common_scope_var(PICO_C_COMPILER_IS_CLANG)
  13. pico_register_common_scope_var(PICO_C_COMPILER_IS_GNU)
  14. pico_register_common_scope_var(PICO_C_COMPILER_IS_IAR)
  15. message("Build type is ${CMAKE_BUILD_TYPE}")
  16. if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  17. if (PICO_DEOPTIMIZED_DEBUG)
  18. message("Using fully de-optimized debug build (set PICO_DEOPTIMIZED_DEBUG=0 to optimize)")
  19. else()
  20. message("Using regular optimized debug build (set PICO_DEOPTIMIZED_DEBUG=1 to de-optimize)")
  21. endif()
  22. endif()
  23. pico_is_top_level_project(PICO_SDK_TOP_LEVEL_PROJECT)
  24. set(CMAKE_C_STANDARD 11)
  25. set(CMAKE_CXX_STANDARD 11)
  26. if (NOT PICO_SDK_TOP_LEVEL_PROJECT)
  27. set(PICO_SDK 1 PARENT_SCOPE)
  28. endif()
  29. # allow customization
  30. add_sub_list_dirs(PICO_SDK_PRE_LIST_DIRS)
  31. add_sub_list_files(PICO_SDK_PRE_LIST_FILES)
  32. add_subdirectory(tools)
  33. add_subdirectory(src)
  34. # allow customization
  35. add_sub_list_dirs(PICO_SDK_POST_LIST_DIRS)
  36. add_sub_list_files(PICO_SDK_POST_LIST_FILES)
  37. if (PICO_SDK_TOP_LEVEL_PROJECT AND NOT DEFINED PICO_SDK_TESTS_ENABLED)
  38. set(PICO_SDK_TESTS_ENABLED 1)
  39. endif()
  40. if (PICO_SDK_TESTS_ENABLED)
  41. add_subdirectory(test)
  42. endif ()
  43. set(PICO_SDK_TESTS_ENABLED "${PICO_SDK_TESTS_ENABLED}" CACHE INTERNAL "Enable build of SDK tests")
  44. # add docs at the end, as we gather documentation dirs as we go
  45. add_subdirectory(docs)
  46. if (NOT PICO_SDK_TOP_LEVEL_PROJECT)
  47. pico_promote_common_scope_vars()
  48. endif()
  49. endif()