Skip to content

Commit

Permalink
fix(mcknly#20): helps if I remember how scoping works in CMake, doesn…
Browse files Browse the repository at this point in the history
…'t it?
  • Loading branch information
Kintar committed Jun 27, 2024
1 parent df0844c commit b5a7fd6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 34 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ set(hardware_dir ${CMAKE_CURRENT_SOURCE_DIR}/hardware/${PLATFORM})
if(EXISTS ${hardware_dir}/prebuild.cmake)
include(${hardware_dir}/prebuild.cmake)
endif()
if(DEFINED WIFI_ENABLED)
include(wifi_optional.cmake)
endif()

project(${PROJ_NAME} C CXX ASM)

add_definitions(-DPROJECT_NAME=${PROJ_NAME}) # pass the project name to the preprocessor for use in the code
Expand All @@ -32,10 +30,16 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/littlefs littlefs)
# add git version library subdirectory (submodule)
add_subdirectory(${PROJECT_SOURCE_DIR}/git_version cmake_git_version_tracking)

if(DEFINED WIFI_ENABLED)
add_subdirectory(${PROJECT_SOURCE_DIR}/services/wifi)
list(APPEND optional_libs WIFI_INTERFACE)
endif()

# create the main executable
add_executable(${PROJ_NAME}
main.c
)

target_link_libraries(${PROJ_NAME} PUBLIC
FreeRTOS-Kernel
FreeRTOS-Kernel-Heap4
Expand All @@ -49,7 +53,9 @@ target_link_libraries(${PROJ_NAME} PUBLIC
cmsis_core
tinyusb_device
${hardware_libs}
${optional_libs}
)

target_include_directories(${PROJ_NAME} PUBLIC
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/rtos
Expand Down
7 changes: 4 additions & 3 deletions services/wifi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ message(STATUS "wifi requested")

if(${BOARD} STREQUAL pico_w)
# pico_w specific configuration
message(STATUS "configuring pico-w wifi support")

# set up path for WIFI_INTERFACE library
set(WIFI_INCLUDE_PATH ${hardware_dir}/lwip_config)
Expand All @@ -19,14 +20,14 @@ endif()
# bundle the necessary wifi includes and append that library to the hardware libs list and
# add in the wifi service code
add_library(WIFI_INTERFACE INTERFACE)

target_include_directories(WIFI_INTERFACE INTERFACE
${WIFI_INCLUDE_PATH}
${CMAKE_CURRENT_LIST_DIR}/include
)

target_sources(WIFI_INTERFACE INTERFACE
${CMAKE_CURRENT_LIST_DIR}/wifi_service.c)

list(APPEND hardware_libs WIFI_INTERFACE)
${CMAKE_CURRENT_LIST_DIR}/wifi_service.c
)

add_compile_definitions(WIFI_ENABLED)
1 change: 1 addition & 0 deletions services/wifi/wifi_service.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "wifi_service.h"
28 changes: 0 additions & 28 deletions wifi_optional.cmake

This file was deleted.

0 comments on commit b5a7fd6

Please sign in to comment.