Skip to content

Commit 3678a25

Browse files
committed
Fix build issues when building for RP2040 from pico-examples/pico-sdk.
* include_guard requires GLOBAL as family.cmake is included in multiple non child places * the following recently added check is suprfluous (family_configure_host_example for rp2040 should do this already), and breaks if pico_pio_usb is not avaialble, so i have removed # Add pico-pio-usb for rp2040 since user can choose to run on bit-banging host if(FAMILY STREQUAL "rp2040") family_add_pico_pio_usb(${PROJECT}) endif() * added new familt_example_missing_dependency functino to print missing dependency warning, so pico-examples can override it to be less in your face, and also more contextual to pico-examples
1 parent f1e006d commit 3678a25

File tree

7 files changed

+19
-33
lines changed

7 files changed

+19
-33
lines changed

examples/device/net_lwip_webserver/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ cmake_minimum_required(VERSION 3.17)
22

33
include(${CMAKE_CURRENT_LIST_DIR}/../../../hw/bsp/family_support.cmake)
44

5+
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
6+
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
7+
58
set(LWIP ${TOP}/lib/lwip)
69
if (NOT EXISTS ${LWIP}/src)
7-
MESSAGE(WARNING "lib/lwip submodule not found, please run 'python tools/get_deps.py lib/lwip' to fetch it")
10+
family_example_missing_dependency(${PROJECT} "lib/lwip")
811
return()
912
endif()
1013

11-
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
12-
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
13-
1414
project(${PROJECT} C CXX ASM)
1515

1616
# Checks this example is valid for the family and initializes the project

examples/host/bare_api/CMakeLists.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,4 @@ target_include_directories(${PROJECT} PUBLIC
2424

2525
# Configure compilation flags and libraries for the example without RTOS.
2626
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
27-
family_configure_host_example(${PROJECT} noos)
28-
29-
# Add pico-pio-usb for rp2040 since user can choose to run on bit-banging host
30-
if(FAMILY STREQUAL "rp2040")
31-
family_add_pico_pio_usb(${PROJECT})
32-
endif()
27+
family_configure_host_example(${PROJECT} noos)

examples/host/cdc_msc_hid/CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,3 @@ target_include_directories(${PROJECT} PUBLIC
2828
# Configure compilation flags and libraries for the example without RTOS.
2929
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
3030
family_configure_host_example(${PROJECT} noos)
31-
32-
# Add pico-pio-usb for rp2040 since user can choose to run on bit-banging host
33-
if(FAMILY STREQUAL "rp2040")
34-
family_add_pico_pio_usb(${PROJECT})
35-
endif()

examples/host/hid_controller/CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,3 @@ target_include_directories(${PROJECT} PUBLIC
2626
# Configure compilation flags and libraries for the example without RTOS.
2727
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
2828
family_configure_host_example(${PROJECT} noos)
29-
30-
# Add pico-pio-usb for rp2040 since user can choose to run on bit-banging host
31-
if(FAMILY STREQUAL "rp2040")
32-
family_add_pico_pio_usb(${PROJECT})
33-
endif()

examples/host/msc_file_explorer/CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,3 @@ target_include_directories(${PROJECT} PUBLIC
3838
# Configure compilation flags and libraries for the example without RTOS.
3939
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
4040
family_configure_host_example(${PROJECT} noos)
41-
42-
# Add pico-pio-usb for rp2040 since user can choose to run on bit-banging host
43-
if(FAMILY STREQUAL "rp2040")
44-
family_add_pico_pio_usb(${PROJECT})
45-
endif()

hw/bsp/family_support.cmake

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include_guard()
1+
include_guard(GLOBAL)
22

33
include(CMakePrintHelpers)
44

@@ -36,12 +36,14 @@ if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${FAMILY}/family.cmake)
3636
message(FATAL_ERROR "Family '${FAMILY}' is not known/supported")
3737
endif()
3838

39-
# enable LTO if supported
40-
include(CheckIPOSupported)
41-
check_ipo_supported(RESULT IPO_SUPPORTED)
42-
if (IPO_SUPPORTED)
43-
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
44-
endif ()
39+
if (NOT TINYUSB_OPT_SKIP_CHECK_IPO_SUPPORTED)
40+
# enable LTO if supported
41+
include(CheckIPOSupported)
42+
check_ipo_supported(RESULT IPO_SUPPORTED)
43+
if (IPO_SUPPORTED)
44+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
45+
endif()
46+
endif()
4547

4648
set(WARNING_FLAGS_GNU
4749
-Wall
@@ -278,6 +280,10 @@ function(family_configure_dual_usb_example TARGET RTOS)
278280
family_configure_example(${TARGET} ${RTOS})
279281
endfunction()
280282

283+
function(family_example_missing_dependency TARGET DEPENDENCY)
284+
message(WARNING "${DEPENDENCY} submodule needed by ${TARGET} not found, please run 'python tools/get_deps.py ${DEPENDENCY}' to fetch it")
285+
endfunction()
286+
281287
#----------------------------------
282288
# RPI specific: refactor later
283289
#----------------------------------

hw/bsp/rp2040/family.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.13)
2-
include_guard()
2+
include_guard(GLOBAL)
33

44
if (NOT BOARD)
55
message("BOARD not specified, defaulting to pico_sdk")

0 commit comments

Comments
 (0)