Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame^] | 1 | From 04686340c4cd375a17d60d31bf6943367cc33214 Mon Sep 17 00:00:00 2001 |
Andrew Geissler | c5535c9 | 2023-01-27 16:10:19 -0600 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sat, 21 Jan 2023 03:09:08 -0800 |
| 4 | Subject: [PATCH] cmake: Do not use -isystem |
| 5 | |
| 6 | isystem dirs are searched before the regular system dirs |
| 7 | this exposes an interesting include ordering problem when using |
| 8 | clang + libc++, when including C++ headers like <cstdlib> |
| 9 | |
| 10 | cstdlib includes stdlib.h and in case of libc++, this should be coming |
| 11 | from libc++ as well, which is then eventually including system stdlib.h |
| 12 | |
| 13 | libc++ has added a check for checking this order recently, which means |
| 14 | if cstlib ends up including system stdlib.h before libc++ provided |
| 15 | stdlib.h it errors out |
| 16 | |
| 17 | /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/thrift/0.17.0-r0/recipe-sysroot/usr/include/c++/v1/cstdlib:90:5: error: <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.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. |
| 18 | ^ |
| 19 | |
| 20 | The reason is that include_directories with SYSTEM property adds the |
| 21 | directory via -system and some of these directories point to sysroot |
| 22 | e.g. OPENSSL_INCLUDE_DIR which ends up adding -isystem |
| 23 | <sysroot>/usr/include and causes the system stdlib.h to included before |
| 24 | libc++ stdlib.h |
| 25 | |
| 26 | A fix is to use -idirafter which preserved the effects of system headers |
| 27 | but instead of prepending, it will append to system headers and the |
| 28 | issue is addressed |
| 29 | |
| 30 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame^] | 31 | |
Andrew Geissler | c5535c9 | 2023-01-27 16:10:19 -0600 | [diff] [blame] | 32 | --- |
| 33 | CMakeLists.txt | 4 ++-- |
| 34 | glib/CMakeLists.txt | 4 ++-- |
| 35 | qt5/src/CMakeLists.txt | 4 ++-- |
| 36 | qt6/src/CMakeLists.txt | 4 ++-- |
| 37 | test/CMakeLists.txt | 6 +++--- |
| 38 | utils/CMakeLists.txt | 10 +++++----- |
| 39 | 6 files changed, 16 insertions(+), 16 deletions(-) |
| 40 | |
| 41 | diff --git a/CMakeLists.txt b/CMakeLists.txt |
Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame^] | 42 | index c6c757c..5f1c540 100644 |
Andrew Geissler | c5535c9 | 2023-01-27 16:10:19 -0600 | [diff] [blame] | 43 | --- a/CMakeLists.txt |
| 44 | +++ b/CMakeLists.txt |
| 45 | @@ -603,10 +603,10 @@ add_library(poppler ${poppler_SRCS}) |
| 46 | if (OpenJPEG_FOUND) |
| 47 | # check if we can remove this when we depend on newer openjpeg versions, 2.5 seems fixed |
| 48 | # target openjp2 may lack interface include directories |
| 49 | - target_include_directories(poppler SYSTEM PRIVATE ${OPENJPEG_INCLUDE_DIRS}) |
| 50 | + target_include_directories(poppler PRIVATE ${OPENJPEG_INCLUDE_DIRS}) |
| 51 | endif() |
| 52 | if(USE_CMS) |
| 53 | - target_include_directories(poppler SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 54 | + target_include_directories(poppler PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 55 | endif() |
| 56 | generate_export_header(poppler BASE_NAME poppler-private EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/poppler_private_export.h") |
Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame^] | 57 | set_target_properties(poppler PROPERTIES VERSION 127.0.0 SOVERSION 127) |
Andrew Geissler | c5535c9 | 2023-01-27 16:10:19 -0600 | [diff] [blame] | 58 | diff --git a/glib/CMakeLists.txt b/glib/CMakeLists.txt |
| 59 | index 52e8687..08ab39a 100644 |
| 60 | --- a/glib/CMakeLists.txt |
| 61 | +++ b/glib/CMakeLists.txt |
| 62 | @@ -4,7 +4,7 @@ include_directories( |
| 63 | ) |
| 64 | |
| 65 | include_directories( |
| 66 | - SYSTEM |
| 67 | + |
| 68 | ${GLIB2_INCLUDE_DIRS} |
| 69 | ${CAIRO_INCLUDE_DIRS} |
| 70 | ) |
| 71 | @@ -96,7 +96,7 @@ if(MINGW AND BUILD_SHARED_LIBS) |
| 72 | set_target_properties(poppler-glib PROPERTIES SUFFIX "-${POPPLER_GLIB_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}") |
| 73 | endif() |
| 74 | target_link_libraries(poppler-glib poppler PkgConfig::GLIB2 ${CAIRO_LIBRARIES} Freetype::Freetype) |
| 75 | -target_include_directories(poppler-glib SYSTEM PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 76 | +target_include_directories(poppler-glib PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 77 | install(TARGETS poppler-glib RUNTIME DESTINATION bin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 78 | |
| 79 | install(FILES |
| 80 | diff --git a/qt5/src/CMakeLists.txt b/qt5/src/CMakeLists.txt |
| 81 | index 5db3a6c..f242d29 100644 |
| 82 | --- a/qt5/src/CMakeLists.txt |
| 83 | +++ b/qt5/src/CMakeLists.txt |
| 84 | @@ -45,11 +45,11 @@ if(MINGW AND BUILD_SHARED_LIBS) |
| 85 | endif() |
| 86 | target_link_libraries(poppler-qt5 poppler Qt5::Core Qt5::Gui Qt5::Xml Freetype::Freetype) |
| 87 | if (ENABLE_NSS3) |
| 88 | - target_include_directories(poppler-qt5 SYSTEM PRIVATE ${NSS3_INCLUDE_DIRS}) |
| 89 | + target_include_directories(poppler-qt5 PRIVATE ${NSS3_INCLUDE_DIRS}) |
| 90 | endif() |
| 91 | if(USE_CMS) |
| 92 | target_link_libraries(poppler-qt5 poppler ${LCMS2_LIBRARIES}) |
| 93 | - target_include_directories(poppler-qt5 SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 94 | + target_include_directories(poppler-qt5 PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 95 | endif() |
| 96 | install(TARGETS poppler-qt5 RUNTIME DESTINATION bin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 97 | |
| 98 | diff --git a/qt6/src/CMakeLists.txt b/qt6/src/CMakeLists.txt |
| 99 | index cd91975..6c42e12 100644 |
| 100 | --- a/qt6/src/CMakeLists.txt |
| 101 | +++ b/qt6/src/CMakeLists.txt |
| 102 | @@ -45,11 +45,11 @@ if(MINGW AND BUILD_SHARED_LIBS) |
| 103 | endif() |
| 104 | target_link_libraries(poppler-qt6 poppler Qt6::Core Qt6::Gui Freetype::Freetype) |
| 105 | if (ENABLE_NSS3) |
| 106 | - target_include_directories(poppler-qt6 SYSTEM PRIVATE ${NSS3_INCLUDE_DIRS}) |
| 107 | + target_include_directories(poppler-qt6 PRIVATE ${NSS3_INCLUDE_DIRS}) |
| 108 | endif() |
| 109 | if(USE_CMS) |
| 110 | target_link_libraries(poppler-qt6 poppler ${LCMS2_LIBRARIES}) |
| 111 | - target_include_directories(poppler-qt6 SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 112 | + target_include_directories(poppler-qt6 PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 113 | endif() |
| 114 | install(TARGETS poppler-qt6 RUNTIME DESTINATION bin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 115 | |
| 116 | diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt |
| 117 | index afa1352..9bd3b9a 100644 |
| 118 | --- a/test/CMakeLists.txt |
| 119 | +++ b/test/CMakeLists.txt |
| 120 | @@ -23,7 +23,7 @@ if (GTK_FOUND) |
| 121 | ) |
| 122 | poppler_add_test(gtk-test BUILD_GTK_TESTS ${gtk_splash_test_SRCS}) |
| 123 | target_link_libraries(gtk-test ${CAIRO_LIBRARIES} poppler-glib PkgConfig::GTK3) |
| 124 | - target_include_directories(gtk-test SYSTEM PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 125 | + target_include_directories(gtk-test PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 126 | |
| 127 | if (HAVE_CAIRO) |
| 128 | |
| 129 | @@ -35,7 +35,7 @@ if (GTK_FOUND) |
| 130 | ) |
| 131 | poppler_add_test(pdf-inspector BUILD_GTK_TESTS ${pdf_inspector_SRCS}) |
| 132 | target_link_libraries(pdf-inspector ${CAIRO_LIBRARIES} Freetype::Freetype ${common_libs} PkgConfig::GTK3 poppler) |
| 133 | - target_include_directories(pdf-inspector SYSTEM PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 134 | + target_include_directories(pdf-inspector PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 135 | target_compile_definitions(pdf-inspector PRIVATE -DSRC_DIR="${CMAKE_CURRENT_SOURCE_DIR}") |
| 136 | endif () |
| 137 | |
| 138 | @@ -59,7 +59,7 @@ if (HAVE_CAIRO) |
| 139 | ) |
| 140 | add_executable(cairo-thread-test ${cairo_thread_test_SRCS}) |
| 141 | target_link_libraries(cairo-thread-test ${CAIRO_LIBRARIES} Freetype::Freetype Threads::Threads poppler) |
| 142 | - target_include_directories(cairo-thread-test SYSTEM PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 143 | + target_include_directories(cairo-thread-test PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 144 | endif () |
| 145 | endif () |
| 146 | |
| 147 | diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt |
| 148 | index 1c3ebcb..bc1840a 100644 |
| 149 | --- a/utils/CMakeLists.txt |
| 150 | +++ b/utils/CMakeLists.txt |
| 151 | @@ -16,7 +16,7 @@ add_executable(pdftoppm ${pdftoppm_SOURCES}) |
| 152 | target_link_libraries(pdftoppm ${common_libs}) |
| 153 | if(LCMS2_FOUND) |
| 154 | target_link_libraries(pdftoppm ${LCMS2_LIBRARIES}) |
| 155 | - target_include_directories(pdftoppm SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 156 | + target_include_directories(pdftoppm PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 157 | endif() |
| 158 | install(TARGETS pdftoppm DESTINATION bin) |
| 159 | install(FILES pdftoppm.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) |
| 160 | @@ -37,10 +37,10 @@ if (HAVE_CAIRO) |
| 161 | add_definitions(${CAIRO_CFLAGS}) |
| 162 | add_executable(pdftocairo ${pdftocairo_SOURCES}) |
| 163 | target_link_libraries(pdftocairo ${CAIRO_LIBRARIES} Freetype::Freetype ${common_libs}) |
| 164 | - target_include_directories(pdftocairo SYSTEM PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 165 | + target_include_directories(pdftocairo PRIVATE ${CAIRO_INCLUDE_DIRS}) |
| 166 | if(LCMS2_FOUND) |
| 167 | target_link_libraries(pdftocairo ${LCMS2_LIBRARIES}) |
| 168 | - target_include_directories(pdftocairo SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 169 | + target_include_directories(pdftocairo PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 170 | endif() |
| 171 | install(TARGETS pdftocairo DESTINATION bin) |
| 172 | install(FILES pdftocairo.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) |
| 173 | @@ -99,7 +99,7 @@ if (ENABLE_NSS3) |
| 174 | pdfsig.cc |
| 175 | ) |
| 176 | add_executable(pdfsig ${pdfsig_SOURCES}) |
| 177 | - target_include_directories(pdfsig SYSTEM PRIVATE ${NSS3_INCLUDE_DIRS}) |
| 178 | + target_include_directories(pdfsig PRIVATE ${NSS3_INCLUDE_DIRS}) |
| 179 | target_link_libraries(pdfsig ${common_libs}) |
| 180 | install(TARGETS pdfsig DESTINATION bin) |
| 181 | install(FILES pdfsig.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) |
| 182 | @@ -114,7 +114,7 @@ add_executable(pdftops ${pdftops_SOURCES}) |
| 183 | target_link_libraries(pdftops ${common_libs}) |
| 184 | if(LCMS2_FOUND) |
| 185 | target_link_libraries(pdftops ${LCMS2_LIBRARIES}) |
| 186 | - target_include_directories(pdftops SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 187 | + target_include_directories(pdftops PRIVATE ${LCMS2_INCLUDE_DIR}) |
| 188 | endif() |
| 189 | install(TARGETS pdftops DESTINATION bin) |
| 190 | install(FILES pdftops.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) |