From 688750c88d2fb7604e1e2f878c094b358a835185 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 7 Aug 2019 16:42:25 +0300 Subject: [PATCH 1/5] lib: posix: Use "posix_subsys" as the CMake lib for the subsystem. Historically, it used to be "PTHREAD", which is no longer true, as POSIX subsys offers much more functionality than just Pthreads. Use detailed name, like "posix_subsys", to avoid possible confusion with ARCH_POSIX-related matters. Signed-off-by: Paul Sokolovsky --- lib/posix/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/posix/CMakeLists.txt b/lib/posix/CMakeLists.txt index a83dff9296050..19fede849bfc9 100644 --- a/lib/posix/CMakeLists.txt +++ b/lib/posix/CMakeLists.txt @@ -1,9 +1,9 @@ # SPDX-License-Identifier: Apache-2.0 -add_library(PTHREAD INTERFACE) +add_library(posix_subsys INTERFACE) -target_include_directories(PTHREAD INTERFACE ${ZEPHYR_BASE}/include/posix) +target_include_directories(posix_subsys INTERFACE ${ZEPHYR_BASE}/include/posix) zephyr_library() zephyr_library_sources(pthread_common.c) @@ -21,5 +21,5 @@ zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_key.c) zephyr_library_sources_ifdef(CONFIG_POSIX_MQUEUE mqueue.c) zephyr_library_sources_ifdef(CONFIG_POSIX_FS fs.c) -zephyr_library_link_libraries(PTHREAD) -target_link_libraries(PTHREAD INTERFACE zephyr_interface) +zephyr_library_link_libraries(posix_subsys) +target_link_libraries(posix_subsys INTERFACE zephyr_interface) From b94ef4dfd6d24b8ecea3703cbc0ec5fd91cb537b Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 6 Jun 2019 21:12:14 +0300 Subject: [PATCH 2/5] CMakeLists.txt: Call toolchain_cc_nostdinc() at the end To let any other zephyr_system_include_directories() directives act first and get these paths in an order allowing Zephyr's stuff override compiler headers. Signed-off-by: Paul Sokolovsky --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ba96e4bfa95a..b25a885460e82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,9 +214,6 @@ if(CONFIG_MISRA_SANE) zephyr_compile_options($<$:${CPP_MISRA_SANE_FLAG}>) endif() -# @Intent: Set compiler specific flags for standard C includes -toolchain_cc_nostdinc() - # @Intent: Set compiler specific macro inclusion of AUTOCONF_H toolchain_cc_imacros(${AUTOCONF_H}) @@ -1497,3 +1494,8 @@ if(CONFIG_BOARD_DEPRECATED) removed in version ${CONFIG_BOARD_DEPRECATED}" ) endif() + +# @Intent: Set compiler specific flags for standard C includes +# Done at the very end, so any other system includes which may +# be added by Zephyr components were first in list. +toolchain_cc_nostdinc() From 988fbaf2d8ac994a82acfe4b69ed5d4ff113fa1a Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 6 Jun 2019 16:58:56 +0300 Subject: [PATCH 3/5] libc: minimal: Add headers as system includes This is consistent with how newlib headers are treated, and will have effect of ninlibc headers to be further down in the include order. This is important, because some POSIX subsys headers override those of libc. Without this change, we can't streamline POSIX build config using zephyr_interface_library_named() cmake directive, because includes will be in wrong order. Signed-off-by: Paul Sokolovsky --- lib/libc/minimal/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/minimal/CMakeLists.txt b/lib/libc/minimal/CMakeLists.txt index 3ac2ebade1c5b..036a4f139c09e 100644 --- a/lib/libc/minimal/CMakeLists.txt +++ b/lib/libc/minimal/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 -zephyr_include_directories(include) +zephyr_system_include_directories(include) zephyr_library() zephyr_library_sources( From ef8def8787fb0531e7b808189aa2d8d0772eb43c Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 6 May 2019 16:50:24 +0300 Subject: [PATCH 4/5] lib: posix: Switch to use zephyr_interface_library_named cmake directive Similar to how other sub-libraries are defined in Zephyr tree, e.g. "fs", "lgvl", etc. This is supposed to help with the need to explicitly add posix include path to each and every application using POSIX subsys. Fixes: #15627 Signed-off-by: Paul Sokolovsky --- lib/posix/CMakeLists.txt | 2 +- lib/posix/Kconfig | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/posix/CMakeLists.txt b/lib/posix/CMakeLists.txt index 19fede849bfc9..ed9a7c416eb94 100644 --- a/lib/posix/CMakeLists.txt +++ b/lib/posix/CMakeLists.txt @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 -add_library(posix_subsys INTERFACE) +zephyr_interface_library_named(posix_subsys) target_include_directories(posix_subsys INTERFACE ${ZEPHYR_BASE}/include/posix) diff --git a/lib/posix/Kconfig b/lib/posix/Kconfig index ef8e60638764d..268a22a26f2d5 100644 --- a/lib/posix/Kconfig +++ b/lib/posix/Kconfig @@ -96,4 +96,12 @@ config POSIX_MAX_OPEN_FILES endif endif # FILE_SYSTEM +# The name of this option is mandated by zephyr_interface_library_named +# cmake directive. +config APP_LINK_WITH_POSIX_SUBSYS + bool "Make POSIX headers available to application" + default y + help + Add POSIX subsystem header files to the 'app' include path. + endif # POSIX_API From a40cc0d18b07e410125517e3abb1116257b77433 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 6 May 2019 16:54:30 +0300 Subject: [PATCH 5/5] tests: posix: No longer use target_include_directories This is no longer needed after using zephyr_interface_library_named cmake directive in the POSIX subsys source itself. Signed-off-by: Paul Sokolovsky --- tests/posix/common/CMakeLists.txt | 1 - tests/posix/fs/CMakeLists.txt | 2 -- 2 files changed, 3 deletions(-) diff --git a/tests/posix/common/CMakeLists.txt b/tests/posix/common/CMakeLists.txt index dcc43da1ef63b..8ad20ac3515a0 100644 --- a/tests/posix/common/CMakeLists.txt +++ b/tests/posix/common/CMakeLists.txt @@ -4,6 +4,5 @@ cmake_minimum_required(VERSION 3.13.1) include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) project(posix_common) -target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/include/posix) FILE(GLOB app_sources src/*.c) target_sources(app PRIVATE ${app_sources}) diff --git a/tests/posix/fs/CMakeLists.txt b/tests/posix/fs/CMakeLists.txt index 8d7c60607bb63..863e2231b4792 100644 --- a/tests/posix/fs/CMakeLists.txt +++ b/tests/posix/fs/CMakeLists.txt @@ -4,7 +4,5 @@ cmake_minimum_required(VERSION 3.13.1) include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) project(fs) -target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/include/) - FILE(GLOB app_sources src/*.c) target_sources(app PRIVATE ${app_sources})