From c565fd45c19c7c5b0d7a6cfa288039051a017b53 Mon Sep 17 00:00:00 2001 From: barnatahmed <101841699+barnatahmed@users.noreply.github.com> Date: Tue, 30 Jan 2024 20:44:27 +0100 Subject: [PATCH] Cmake: Create a single static library including port Modify portable/CMakeLists.txt to create only one static library containing both the common kernel code and kernel port. Change the freertos_kernel_port target from a STATIC library to an OBJECT library and introduce a new freertos_kernel_port_headers INTERFACE library target. --------- Co-authored-by: ABARNAT Co-authored-by: Soren Ptak Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- CMakeLists.txt | 12 ++++++++---- portable/CMakeLists.txt | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5323ec19bf..07eeec471d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,16 +217,17 @@ elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_ " port.c\n" " portmacro.h\n" " Where FreeRTOSCustomPort/CMakeLists.txt is a modified version of:\n" - " add_library(freertos_kernel_port STATIC)\n" + " add_library(freertos_kernel_port OBJECT)\n" " target_sources(freertos_kernel_port\n" " PRIVATE\n" " port.c\n" " portmacro.h)\n" - " target_include_directories(freertos_kernel_port\n" - " PUBLIC\n" + " add_library(freertos_kernel_port_headers INTERFACE)\n" + " target_include_directories(freertos_kernel_port_headers INTERFACE \n" " .)\n" " target_link_libraries(freertos_kernel_port\n" " PRIVATE\n" + " freertos_kernel_port_headers\n" " freertos_kernel_include)") endif() @@ -257,8 +258,11 @@ endif() target_link_libraries(freertos_kernel PUBLIC - freertos_kernel_port freertos_kernel_include + freertos_kernel_port_headers + PRIVATE + freertos_kernel_port + ) ######################################################################## diff --git a/portable/CMakeLists.txt b/portable/CMakeLists.txt index 9df221d214..98dcf8ed3c 100644 --- a/portable/CMakeLists.txt +++ b/portable/CMakeLists.txt @@ -15,7 +15,7 @@ endif() # FreeRTOS internal cmake file. Do not use it in user top-level project -add_library(freertos_kernel_port STATIC +add_library(freertos_kernel_port OBJECT # TEMPLATE Port $<$: template/port.c> @@ -755,8 +755,9 @@ if( FREERTOS_PORT MATCHES "GCC_ARM_CM(3|4)_MPU" OR Common/mpu_wrappers_v2.c ) endif() +add_library(freertos_kernel_port_headers INTERFACE) -target_include_directories(freertos_kernel_port PUBLIC +target_include_directories(freertos_kernel_port_headers INTERFACE # TEMPLATE Port $<$:${CMAKE_CURRENT_LIST_DIR}/template> @@ -1094,6 +1095,7 @@ target_link_libraries(freertos_kernel_port PUBLIC $<$:pico_base_headers> $<$:idf::esp32> + freertos_kernel_port_headers PRIVATE freertos_kernel_include $<$:Threads::Threads>