mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-21 15:15:07 +00:00
Only add include directories for LLVM, clang & rapidjson if they are not in CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
/usr/include/c++/9 comes before /usr/include in `{clang,gcc} -v -fsyntax-only -xc++ /dev/null`. target_include_directories(ccls SYSTEM PRIVATE ${RapidJSON_INCLUDE_DIRS}) If ${RapidJSON_INCLUDE_DIRS} resolves to /usr/include, /usr/include will be shuffled before /usr/include/c++/9 and will cause `#include_next <stdlib.h>` issues (see https://github.com/MaskRay/ccls/pull/417). Check if the include directories are already in CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES.
This commit is contained in:
parent
c728fe9795
commit
795ad205d7
@ -143,17 +143,25 @@ set_property(SOURCE src/utils.cc APPEND PROPERTY COMPILE_DEFINITIONS
|
||||
|
||||
### Includes
|
||||
|
||||
target_include_directories(ccls PRIVATE src)
|
||||
target_include_directories(ccls SYSTEM PRIVATE
|
||||
third_party ${LLVM_INCLUDE_DIRS} ${CLANG_INCLUDE_DIRS})
|
||||
|
||||
if(USE_SYSTEM_RAPIDJSON)
|
||||
find_package(RapidJSON QUIET)
|
||||
endif()
|
||||
if(NOT RapidJSON_FOUND)
|
||||
set(RapidJSON_INCLUDE_DIRS third_party/rapidjson/include)
|
||||
endif()
|
||||
target_include_directories(ccls SYSTEM PRIVATE ${RapidJSON_INCLUDE_DIRS})
|
||||
|
||||
target_include_directories(ccls PRIVATE src)
|
||||
|
||||
foreach(include_dir third_party
|
||||
${LLVM_INCLUDE_DIRS} ${CLANG_INCLUDE_DIRS} ${RapidJSON_INCLUDE_DIRS})
|
||||
get_filename_component(include_dir_realpath ${include_dir} REALPATH)
|
||||
# Don't add as SYSTEM if they are in CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES.
|
||||
# It would reorder the system search paths and cause issues with libstdc++'s
|
||||
# use of #include_next. See https://github.com/MaskRay/ccls/pull/417
|
||||
if(NOT "${include_dir_realpath}" IN_LIST CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)
|
||||
target_include_directories(ccls SYSTEM PRIVATE ${include_dir})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
### Install
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user