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