summaryrefslogtreecommitdiff
path: root/meta-openembedded/meta-oe/recipes-support/libcereal/files/0001-cmake-Use-idirafter-instead-of-isystem.patch
blob: fc30f0ad7c2a1ebaac96e4ad808154b5f5bd3199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From ac70933783a70d5387a2bb2849c568e33ba52558 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 21 Jan 2023 01:41:32 -0800
Subject: [PATCH] cmake: Use -idirafter instead of -isystem

isystem dirs are searched before the regular system dirs
this exposes an interesting include ordering problem when using
clang + libc++, when including C++ headers like <cstdlib>

cstdlib includes stdlib.h and in case of libc++, this should be coming
from libc++ as well, which is then eventually including system stdlib.h

libc++ has added a check for checking this order recently, which means
if cstlib ends up including system stdlib.h before libc++ provided
stdlib.h it errors out

| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/libcereal/1.3.2+gitAUTOINC+ebef1e9298-r0/recipe-sysroot/usr/include/c++/v1/cwchar:113:5: error: <cwchar> tried including <wchar.h> but didn't find libc++'s <wcha
r.h> header.           This usually means that your header search paths are not configured properly.           The header search paths should contain the C++ Standard Library headers before           any C Standard
 Library, and you are probably using compiler flags that make that           not be the case.                                                                                                                         | #   error <cwchar> tried including <wchar.h> but didn't find libc++'s <wchar.h> header. \
|     ^

The reason is that include_directories with SYSTEM property adds the
directory via -system and some of these directories point to sysroot
e.g. OPENSSL_INCLUDE_DIR which ends up adding -isystem
<sysroot>/usr/include and causes the system stdlib.h to included before
libc++ stdlib.h

A fix is to use -idirafter which preserved the effects of system headers
but instead of prepending, it will append to system headers and the
issue is addressed

Upstream-Status: Submitted [https://github.com/USCiLab/cereal/pull/777]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 unittests/boost/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/unittests/boost/CMakeLists.txt b/unittests/boost/CMakeLists.txt
index 1d733bc7..08e6a169 100644
--- a/unittests/boost/CMakeLists.txt
+++ b/unittests/boost/CMakeLists.txt
@@ -1,6 +1,6 @@
 file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
 
-include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -idirafter ${Boost_INCLUDE_DIRS}")
 
 # Build all of the non-special tests
 foreach(TEST_SOURCE ${TESTS})
-- 
2.39.1