From 96da4d00e1397955ebc06e420e22e72e9f9635bf Mon Sep 17 00:00:00 2001 From: Awawa <69086569+awawa-dev@users.noreply.github.com> Date: Mon, 4 Dec 2023 21:16:49 +0100 Subject: [PATCH] Update CMakeLists.txt --- CMakeLists.txt | 63 ++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29cd7a5..d66a0ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,27 +1,29 @@ -# User configuration section starts here +if (NOT PICO_PROGRAM_MAIN_ENTRY) + # User configuration for HyperSerialPico section starts here -# Some boards, such as the first Adafruit revisions, may have trouble booting properly -# due to bad componets used in the design. -# Turn this setting to ON if your rp2040 is not detected after firmware upload and reset -set(BOOT_WORKAROUND OFF) + # Some boards, such as the first Adafruit revisions, may have trouble booting properly + # due to bad componets used in the design. + # Turn this setting to ON if your rp2040 is not detected after firmware upload and reset + set(BOOT_WORKAROUND OFF) -# Default output data pin for the non-SPI LED strips (only for sk6812/ws2812b) -set(OUTPUT_DATA_PIN 2) + # Default output data pin for the non-SPI LED strips (only for sk6812/ws2812b) + set(OUTPUT_DATA_PIN 2) -# Default output data/clocks pin for the SPI LED strips (only for apa102, not for sk6812/ws2812b) -# only certain pairs of pins are allowed for selected SPI interface (refer to "readme.md") -set(OUTPUT_SPI_DATA_PIN 3) -set(OUTPUT_SPI_CLOCK_PIN 2) -set(OUTPUT_SPI_INTERFACE spi0) + # Default output data/clocks pin for the SPI LED strips (only for apa102, not for sk6812/ws2812b) + # only certain pairs of pins are allowed for selected SPI interface (refer to "readme.md") + set(OUTPUT_SPI_DATA_PIN 3) + set(OUTPUT_SPI_CLOCK_PIN 2) + set(OUTPUT_SPI_INTERFACE spi0) -# Use multi-segment, starting index of second led strip or OFF to disable -set(SECOND_SEGMENT_INDEX OFF) + # Use multi-segment, starting index of second led strip or OFF to disable + set(SECOND_SEGMENT_INDEX OFF) -# If multi-segment is used and it's reversed, set this option to ON to enable reversing -set(SECOND_SEGMENT_REVERSED OFF) + # If multi-segment is used and it's reversed, set this option to ON to enable reversing + set(SECOND_SEGMENT_REVERSED OFF) -# User configuration section ends here -# Usually you don't need to change anything below this section + # User configuration section ends here + # Usually you don't need to change anything below this section +endif() cmake_minimum_required(VERSION 3.13) @@ -30,13 +32,14 @@ add_definitions ( -DPICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE=0 ) # initialize the SDK based on PICO_SDK_PATH # note: this must happen before project() -set(PICO_SDK_PATH ${CMAKE_SOURCE_DIR}/sdk/pico) -set(FREERTOS_KERNEL_PATH ${CMAKE_SOURCE_DIR}/sdk/freertos) +set(PICO_SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/sdk/pico) +set(FREERTOS_KERNEL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/sdk/freertos) include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake) include(${FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake) -project(HyperSerialPico C CXX ASM) +project("HyperSerialPico" C CXX ASM) + set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) @@ -52,9 +55,9 @@ pico_sdk_init() # generic HyperSerialPico settings set(HyperSerialPicoCompanionLibs FreeRTOS-Kernel FreeRTOS-Kernel-Heap1 pico_stdlib pico_multicore hardware_pio hardware_dma hardware_spi) -set(HyperSerialPicoCompanionIncludes ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sdk/config) -file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/generated) -file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/firmware) +set(HyperSerialPicoCompanionIncludes ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/sdk/config) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/generated) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/firmware) if(NOT CMAKE_HOST_WIN32) string(ASCII 27 EscChar) @@ -99,7 +102,11 @@ message( STATUS "---------------------------") add_compile_options(-ftrack-macro-expansion=0 -fno-diagnostics-show-caret -fdiagnostics-color=auto) macro(HyperSerialPicoTarget HyperSerialPicoTargetName) - add_executable(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/source/main.cpp) + if (PICO_PROGRAM_MAIN_ENTRY) + add_executable(${HyperSerialPicoTargetName} ${PICO_PROGRAM_MAIN_ENTRY}) + else() + add_executable(${HyperSerialPicoTargetName} ${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp) + endif() if (BOOT_WORKAROUND) target_compile_definitions(${HyperSerialPicoTargetName} PUBLIC -DBOOT_WORKAROUND -DPICO_XOSC_STARTUP_DELAY_MULTIPLIER=64) endif() @@ -108,9 +115,9 @@ macro(HyperSerialPicoTarget HyperSerialPicoTargetName) pico_add_extra_outputs(${HyperSerialPicoTargetName}) pico_enable_stdio_usb(${HyperSerialPicoTargetName} 1) pico_enable_stdio_uart(${HyperSerialPicoTargetName} 0) - pico_generate_pio_header(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/pio/neopixel.pio OUTPUT_DIR ${CMAKE_SOURCE_DIR}/generated) - pico_generate_pio_header(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/pio/neopixel_ws2812b.pio OUTPUT_DIR ${CMAKE_SOURCE_DIR}/generated) - add_custom_command(TARGET ${HyperSerialPicoTargetName} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/${HyperSerialPicoTargetName}.uf2 ${CMAKE_SOURCE_DIR}/firmware) + pico_generate_pio_header(${HyperSerialPicoTargetName} ${CMAKE_CURRENT_SOURCE_DIR}/pio/neopixel.pio OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/generated) + pico_generate_pio_header(${HyperSerialPicoTargetName} ${CMAKE_CURRENT_SOURCE_DIR}/pio/neopixel_ws2812b.pio OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/generated) + add_custom_command(TARGET ${HyperSerialPicoTargetName} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${HyperSerialPicoTargetName}.uf2 ${CMAKE_CURRENT_SOURCE_DIR}/firmware) endmacro() # targets for different LED strips