From 39371b90b8bfe23f3d190b1606f5264ddaa55915 Mon Sep 17 00:00:00 2001 From: Patrick Cook Date: Wed, 5 Jul 2023 11:46:42 -0700 Subject: [PATCH 1/2] Fix circular dependency in cmake project Fix for https://github.com/FreeRTOS/FreeRTOS-Kernel/issues/687 In order for custom ports to also break the cycle, they must link against freertos_kernel_include instead of freertos_kernel. --- CMakeLists.txt | 12 +++--------- include/CMakeLists.txt | 16 ++++++++++++++++ portable/CMakeLists.txt | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 include/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 46a9e180796..a68b652cada 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,7 +225,7 @@ elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_ " .)\n" " target_link_libraries(freertos_kernel_port\n" " PRIVATE\n" - " freertos_kernel)") + " freertos_kernel_include)") endif() ######################################################################## @@ -264,6 +264,7 @@ add_compile_options( ######################################################################## +add_subdirectory(include) add_subdirectory(portable) add_library(freertos_kernel STATIC @@ -279,17 +280,10 @@ add_library(freertos_kernel STATIC $>,${FREERTOS_HEAP},portable/MemMang/heap_${FREERTOS_HEAP}.c> ) -target_include_directories(freertos_kernel - PUBLIC - include - # Note: DEPRECATED but still supported, may be removed in a future release. - $<$>:${FREERTOS_CONFIG_FILE_DIRECTORY}> -) - target_link_libraries(freertos_kernel PUBLIC - $<$:freertos_config> freertos_kernel_port + freertos_kernel_include ) ######################################################################## diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 00000000000..039356c6a39 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,16 @@ +# FreeRTOS internal cmake file. Do not use it in user top-level project + +add_library(freertos_kernel_include INTERFACE) + +target_include_directories(freertos_kernel_include + INTERFACE + $ + $ + # Note: DEPRECATED but still supported, may be removed in a future release. + $<$>:${FREERTOS_CONFIG_FILE_DIRECTORY}> +) + +target_link_libraries(freertos_kernel_include + INTERFACE + $<$:freertos_config> +) diff --git a/portable/CMakeLists.txt b/portable/CMakeLists.txt index 2824df05dc0..988be152406 100644 --- a/portable/CMakeLists.txt +++ b/portable/CMakeLists.txt @@ -1035,7 +1035,7 @@ target_link_libraries(freertos_kernel_port $<$:pico_base_headers> $<$:idf::esp32> PRIVATE - freertos_kernel + freertos_kernel_include $<$:Threads::Threads> "$<$:hardware_clocks;hardware_exception>" $<$:winmm> # Windows library which implements timers From 9aba99d145b07a6a6022806ab6bc115552fe770c Mon Sep 17 00:00:00 2001 From: Patrick Cook <114708437+cookpate@users.noreply.github.com> Date: Wed, 5 Jul 2023 14:28:41 -0700 Subject: [PATCH 2/2] Simplify include path --- include/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 039356c6a39..46a1c3e7f5f 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -4,8 +4,7 @@ add_library(freertos_kernel_include INTERFACE) target_include_directories(freertos_kernel_include INTERFACE - $ - $ + . # Note: DEPRECATED but still supported, may be removed in a future release. $<$>:${FREERTOS_CONFIG_FILE_DIRECTORY}> )