Some cmake build improvements (#376)
* Change some cmake output to DEBUG level Make SDK build more consistent with other libraries (use an INTERFACE marker library for inclusion tests) Add PICO_SDK_PRE_LIST_FILES, PICO_SDK_POST_LIST_FILES build vars * fix typo * remove leftover debugging message
This commit is contained in:
parent
929ede7482
commit
18c39856bd
@ -1,6 +1,10 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
# Note: this CMakeLists.txt can be used as a top-level CMakeLists.txt for the SDK itself. For all other uses
|
||||||
|
# it is included as a subdirectory via the pico_sdk_init() method provided by pico_sdk_init.cmake
|
||||||
if (NOT TARGET _pico_sdk_inclusion_marker)
|
if (NOT TARGET _pico_sdk_inclusion_marker)
|
||||||
add_library(_pico_sdk_inclusion_marker INTERFACE)
|
add_library(_pico_sdk_inclusion_marker INTERFACE)
|
||||||
|
# This is a no-op unless we are the top-level CMakeLists.txt
|
||||||
include(pico_sdk_init.cmake)
|
include(pico_sdk_init.cmake)
|
||||||
|
|
||||||
project(pico_sdk C CXX ASM)
|
project(pico_sdk C CXX ASM)
|
||||||
@ -24,6 +28,7 @@ if (NOT TARGET _pico_sdk_inclusion_marker)
|
|||||||
|
|
||||||
# allow customization
|
# allow customization
|
||||||
add_sub_list_dirs(PICO_SDK_PRE_LIST_DIRS)
|
add_sub_list_dirs(PICO_SDK_PRE_LIST_DIRS)
|
||||||
|
add_sub_list_files(PICO_SDK_PRE_LIST_FILES)
|
||||||
|
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
@ -32,6 +37,7 @@ if (NOT TARGET _pico_sdk_inclusion_marker)
|
|||||||
|
|
||||||
# allow customization
|
# allow customization
|
||||||
add_sub_list_dirs(PICO_SDK_POST_LIST_DIRS)
|
add_sub_list_dirs(PICO_SDK_POST_LIST_DIRS)
|
||||||
|
add_sub_list_files(PICO_SDK_POST_LIST_FILES)
|
||||||
|
|
||||||
if (PICO_SDK_TOP_LEVEL_PROJECT AND NOT DEFINED PICO_SDK_TESTS_ENABLED)
|
if (PICO_SDK_TOP_LEVEL_PROJECT AND NOT DEFINED PICO_SDK_TESTS_ENABLED)
|
||||||
set(PICO_SDK_TESTS_ENABLED 1)
|
set(PICO_SDK_TESTS_ENABLED 1)
|
||||||
|
@ -12,7 +12,7 @@ if (NOT PICO_GCC_TRIPLE)
|
|||||||
message("PICO_GCC_TRIPLE set from environment: $ENV{PICO_GCC_TRIPLE}")
|
message("PICO_GCC_TRIPLE set from environment: $ENV{PICO_GCC_TRIPLE}")
|
||||||
else()
|
else()
|
||||||
set(PICO_GCC_TRIPLE arm-none-eabi)
|
set(PICO_GCC_TRIPLE arm-none-eabi)
|
||||||
message("PICO_GCC_TRIPLE defaulted to arm-none-eabi")
|
message(DEBUG "PICO_GCC_TRIPLE defaulted to arm-none-eabi")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,54 +1,63 @@
|
|||||||
# Initialize the Raspberry Pi Pico SDK
|
# Pre-initialize the Raspberry Pi Pico SDK, setting up the platform and toolchain and some CMake utility functions
|
||||||
# This file must be included prior to the project() call
|
# This file must be included prior to the project() call
|
||||||
|
|
||||||
if (_PICO_SDK_INIT)
|
# Note: this file is perhaps named badly, as it provides a method pico_sdk_init which
|
||||||
return()
|
# the enclosing project calls LATER to actually "initialize" the SDK (by including the CMakeLists.txt from this
|
||||||
endif ()
|
# same directory)
|
||||||
set(_PICO_SDK_INIT 1)
|
|
||||||
|
|
||||||
function(pico_is_top_level_project VAR)
|
if (NOT TARGET _pico_sdk_pre_init_marker)
|
||||||
string(TOLOWER ${CMAKE_CURRENT_LIST_DIR} __list_dir)
|
add_library(_pico_sdk_pre_init_marker INTERFACE)
|
||||||
string(TOLOWER ${CMAKE_SOURCE_DIR} __source_dir)
|
|
||||||
if (__source_dir STREQUAL __list_dir)
|
|
||||||
set(${VAR} 1 PARENT_SCOPE)
|
|
||||||
else()
|
|
||||||
set(${VAR} 0 PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
if (NOT PICO_SDK_PATH)
|
function(pico_is_top_level_project VAR)
|
||||||
set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR})
|
string(TOLOWER ${CMAKE_CURRENT_LIST_DIR} __list_dir)
|
||||||
endif ()
|
string(TOLOWER ${CMAKE_SOURCE_DIR} __source_dir)
|
||||||
|
if (__source_dir STREQUAL __list_dir)
|
||||||
|
set(${VAR} 1 PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${VAR} 0 PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
if (NOT PICO_SDK_PATH)
|
||||||
|
set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
|
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${PICO_SDK_PATH}/cmake)
|
set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_version.cmake)
|
list(APPEND CMAKE_MODULE_PATH ${PICO_SDK_PATH}/cmake)
|
||||||
include(pico_utils)
|
|
||||||
|
|
||||||
message("PICO_SDK_PATH is ${CMAKE_CURRENT_LIST_DIR}")
|
include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_version.cmake)
|
||||||
|
include(pico_utils)
|
||||||
|
|
||||||
include(pico_pre_load_platform)
|
message("PICO_SDK_PATH is ${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
|
||||||
# todo perhaps this should be included by the platform instead?
|
include(pico_pre_load_platform)
|
||||||
# We want to configure correct toolchain prior to project load
|
|
||||||
include(pico_pre_load_toolchain)
|
|
||||||
|
|
||||||
macro(pico_sdk_init)
|
# todo perhaps this should be included by the platform instead?
|
||||||
if (NOT CMAKE_PROJECT_NAME)
|
# We want to configure correct toolchain prior to project load
|
||||||
message(WARNING "pico_sdk_init() should be called after the project is created (and languages added)")
|
include(pico_pre_load_toolchain)
|
||||||
endif()
|
|
||||||
add_subdirectory(${PICO_SDK_PATH} pico-sdk)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(add_sub_list_dirs var)
|
macro(pico_sdk_init)
|
||||||
foreach(LIST_DIR IN LISTS ${var})
|
if (NOT CMAKE_PROJECT_NAME)
|
||||||
get_filename_component(SHORT_NAME "${LIST_DIR}" NAME)
|
message(WARNING "pico_sdk_init() should be called after the project is created (and languages added)")
|
||||||
message("Including custom CMakeLists.txt ${SHORT_NAME}")
|
endif()
|
||||||
add_subdirectory(${LIST_DIR} ${SHORT_NAME})
|
add_subdirectory(${PICO_SDK_PATH} pico-sdk)
|
||||||
endforeach()
|
endmacro()
|
||||||
endmacro()
|
|
||||||
|
|
||||||
|
macro(add_sub_list_dirs var)
|
||||||
|
foreach(LIST_DIR IN LISTS ${var})
|
||||||
|
get_filename_component(SHORT_NAME "${LIST_DIR}" NAME)
|
||||||
|
message(DEBUG "Including custom CMakeLists.txt ${SHORT_NAME}")
|
||||||
|
add_subdirectory(${LIST_DIR} ${SHORT_NAME})
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(add_sub_list_files var)
|
||||||
|
foreach(LIST_FILE IN LISTS ${var})
|
||||||
|
message(DEBUG "Including custom CMake file ${LIST_FILE}")
|
||||||
|
include(${LIST_FILE})
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
endif()
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "pico/sem.h"
|
#include "pico/sem.h"
|
||||||
#include "pico/time.h"
|
#include "pico/time.h"
|
||||||
|
#include "sys/select.h"
|
||||||
|
|
||||||
void sem_init(semaphore_t *sem, int16_t initial_permits, int16_t max_permits) {
|
void sem_init(semaphore_t *sem, int16_t initial_permits, int16_t max_permits) {
|
||||||
lock_init(&sem->core, next_striped_spin_lock_num());
|
lock_init(&sem->core, next_striped_spin_lock_num());
|
||||||
|
Loading…
Reference in New Issue
Block a user