CMakeLists.txt 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. cmake_minimum_required(VERSION 3.13...3.27)
  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. pico_register_common_scope_var(PICO_SDK_VERSION_MAJOR)
  16. pico_register_common_scope_var(PICO_SDK_VERSION_MINOR)
  17. pico_register_common_scope_var(PICO_SDK_VERSION_REVISION)
  18. pico_register_common_scope_var(PICO_SDK_VERSION_PRE_RELEASE_ID)
  19. pico_register_common_scope_var(PICO_SDK_VERSION_STRING)
  20. message("Build type is ${CMAKE_BUILD_TYPE}")
  21. if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  22. if (PICO_DEOPTIMIZED_DEBUG)
  23. message("Using fully de-optimized debug build (set PICO_DEOPTIMIZED_DEBUG=0 to optimize)")
  24. else()
  25. message("Using regular optimized debug build (set PICO_DEOPTIMIZED_DEBUG=1 to de-optimize)")
  26. endif()
  27. endif()
  28. pico_is_top_level_project(PICO_SDK_TOP_LEVEL_PROJECT)
  29. set(CMAKE_C_STANDARD 11)
  30. set(CMAKE_CXX_STANDARD 11)
  31. if (NOT PICO_SDK_TOP_LEVEL_PROJECT)
  32. set(PICO_SDK 1 PARENT_SCOPE)
  33. endif()
  34. # allow customization
  35. add_sub_list_dirs(PICO_SDK_PRE_LIST_DIRS)
  36. add_sub_list_files(PICO_SDK_PRE_LIST_FILES)
  37. # needed by certain functions
  38. set(PICO_TOOLS_DIR "${CMAKE_CURRENT_LIST_DIR}/tools" CACHE INTERNAL "")
  39. add_subdirectory(tools)
  40. add_subdirectory(src)
  41. # allow customization
  42. add_sub_list_dirs(PICO_SDK_POST_LIST_DIRS)
  43. add_sub_list_files(PICO_SDK_POST_LIST_FILES)
  44. if (PICO_SDK_TOP_LEVEL_PROJECT AND NOT DEFINED PICO_SDK_TESTS_ENABLED)
  45. set(PICO_SDK_TESTS_ENABLED 1)
  46. endif()
  47. if (PICO_SDK_TESTS_ENABLED)
  48. add_subdirectory(test)
  49. endif ()
  50. set(PICO_SDK_TESTS_ENABLED "${PICO_SDK_TESTS_ENABLED}" CACHE INTERNAL "Enable build of SDK tests")
  51. # add docs at the end, as we gather documentation dirs as we go
  52. add_subdirectory(docs)
  53. if (NOT PICO_SDK_TOP_LEVEL_PROJECT)
  54. pico_promote_common_scope_vars()
  55. endif()
  56. endif()