cmake magic

This commit is contained in:
Martin Brodbeck 2024-02-27 13:37:12 +01:00
parent df85ca4267
commit 6f51f5e962
4 changed files with 20 additions and 10 deletions

View file

@ -18,7 +18,7 @@ if (PICO_SDK_VERSION_STRING VERSION_LESS "1.5.0")
message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.5.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
endif()
project(raspi_keyer C CXX ASM)
project(raspi_keyer VERSION "0.0.1" LANGUAGES C CXX ASM)
# Initialise the Raspberry Pi Pico SDK
pico_sdk_init()
@ -29,7 +29,7 @@ add_executable(raspi_keyer)
add_subdirectory(src)
pico_set_program_name(raspi_keyer "raspi_keyer")
pico_set_program_version(raspi_keyer "0.0.1")
pico_set_program_version(raspi_keyer ${PROJECT_VERSION})
pico_enable_stdio_uart(raspi_keyer 1)
pico_enable_stdio_usb(raspi_keyer 0)
@ -46,11 +46,6 @@ target_include_directories(raspi_keyer PRIVATE
${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts or any other standard includes, if required
)
# Make sure TinyUSB can find tusb_config.h
target_include_directories(raspi_keyer PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src
)
# Add any user requested libraries
target_link_libraries(raspi_keyer
hardware_flash
@ -61,8 +56,6 @@ target_link_libraries(raspi_keyer
hardware_adc
tinyusb_device
tinyusb_board
#hardware_pio
#hardware_uart
)
pico_add_extra_outputs(raspi_keyer)

View file

@ -1,3 +1,16 @@
configure_file(config.h.in config.h @ONLY)
# Make sure TinyUSB can find tusb_config.h
target_include_directories(raspi_keyer PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
# Make sure the compiler can find the
# generated config.h
target_include_directories(raspi_keyer PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
)
target_sources(raspi_keyer PRIVATE
raspi_keyer.cpp
settings.cpp

3
src/config.h.in Normal file
View file

@ -0,0 +1,3 @@
#pragma once
#cmakedefine PROJECT_VERSION "@PROJECT_VERSION@"

View file

@ -10,6 +10,7 @@
#include "keyer.h"
#include "settings.h"
#include <config.h>
#include "tusb_config.h"
namespace
@ -199,7 +200,7 @@ int main()
board_init();
tud_init(BOARD_TUD_RHPORT);
printf("Hello from core0!\n");
printf("RaspiKeyer Version %s\n", PROJECT_VERSION);
queue_init(&keyerQueue, sizeof(KeyerQueueData), 2);
multicore_reset_core1();