aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2023-01-12 16:49:17 +0100
committerGitHub <noreply@github.com>2023-01-12 16:49:17 +0100
commita0b2c124a3cba591575ecf6d2dfe91f515c2ebe2 (patch)
treec327264f423f4d9b9443e363f4e47deaa2f67cba
parent921e634119c14b03f9611f1602df171c9ffc9559 (diff)
downloadrneovim-a0b2c124a3cba591575ecf6d2dfe91f515c2ebe2.tar.gz
rneovim-a0b2c124a3cba591575ecf6d2dfe91f515c2ebe2.tar.bz2
rneovim-a0b2c124a3cba591575ecf6d2dfe91f515c2ebe2.zip
build: include our libraries before system libraries (#21746)
Including our libraries as system libraries is helpful to suppress any warnings, but the default behavior is to include it after existing libraries. This can become a problem with some package managers such as macports, as CMake automatically adds /opt/local to the include path, which is where they store all includes. This means that the wrong header might be chosen if it has the same name as the one from our dependencies. Adding the BEFORE keyword when including will ensure that our dependency headers are chosen first. Also remove old Darwin workarounds that shouldn't be necessary anymore. Closes: https://github.com/neovim/neovim/issues/21742
-rw-r--r--CMakeLists.txt15
-rwxr-xr-xsrc/nvim/CMakeLists.txt22
2 files changed, 11 insertions, 26 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 878d5134ab..949de8487d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,14 +82,6 @@ list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX})
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${DEPS_PREFIX}/lib/pkgconfig")
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- # CMake tries to treat /sw and /opt/local as extension of the system path, but
- # that doesn't really work out very well. Once you have a dependency that
- # resides there and have to add it as an include directory, then any other
- # dependency that could be satisfied from there must be--otherwise you can end
- # up with conflicting versions. So, let's make them more of a priority having
- # them be included as one of the first places to look for dependencies.
- list(APPEND CMAKE_PREFIX_PATH /sw /opt/local)
-
# If the macOS deployment target is not set manually (via $MACOSX_DEPLOYMENT_TARGET),
# fall back to local system version. Needs to be done both here and in cmake.deps.
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
@@ -99,13 +91,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET "${MACOS_VERSION}")
endif()
message(STATUS "Using deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET}")
-
- # Work around some old, broken detection by CMake for knowing when to use the
- # isystem flag. Apple's compilers have supported this for quite some time
- # now.
- if(CMAKE_C_COMPILER_ID MATCHES "GNU")
- set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
- endif()
endif()
if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 46191faf62..1d7724f8be 100755
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -3,15 +3,15 @@ add_executable(nvim main.c)
add_library(libuv_lib INTERFACE)
find_package(LibUV 1.28.0 REQUIRED)
-target_include_directories(libuv_lib SYSTEM INTERFACE ${LIBUV_INCLUDE_DIRS})
+target_include_directories(libuv_lib SYSTEM BEFORE INTERFACE ${LIBUV_INCLUDE_DIRS})
target_link_libraries(libuv_lib INTERFACE ${LIBUV_LIBRARIES})
find_package(Msgpack 1.0.0 REQUIRED)
-target_include_directories(main_lib SYSTEM INTERFACE ${MSGPACK_INCLUDE_DIRS})
+target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${MSGPACK_INCLUDE_DIRS})
target_link_libraries(main_lib INTERFACE ${MSGPACK_LIBRARIES})
find_package(LibLUV 1.43.0 REQUIRED)
-target_include_directories(main_lib SYSTEM INTERFACE ${LIBLUV_INCLUDE_DIRS})
+target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${LIBLUV_INCLUDE_DIRS})
# Use "luv" as imported library, to work around CMake using "-lluv" for
# "luv.so". #10407
add_library(luv UNKNOWN IMPORTED)
@@ -19,23 +19,23 @@ set_target_properties(luv PROPERTIES IMPORTED_LOCATION ${LIBLUV_LIBRARIES})
target_link_libraries(main_lib INTERFACE luv)
find_package(TreeSitter REQUIRED)
-target_include_directories(main_lib SYSTEM INTERFACE ${TreeSitter_INCLUDE_DIRS})
+target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${TreeSitter_INCLUDE_DIRS})
target_link_libraries(main_lib INTERFACE ${TreeSitter_LIBRARIES})
find_package(UNIBILIUM 2.0 REQUIRED)
-target_include_directories(main_lib SYSTEM INTERFACE ${UNIBILIUM_INCLUDE_DIRS})
+target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${UNIBILIUM_INCLUDE_DIRS})
target_link_libraries(main_lib INTERFACE ${UNIBILIUM_LIBRARIES})
find_package(LibTermkey 0.22 REQUIRED)
-target_include_directories(main_lib SYSTEM INTERFACE ${LIBTERMKEY_INCLUDE_DIRS})
+target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${LIBTERMKEY_INCLUDE_DIRS})
target_link_libraries(main_lib INTERFACE ${LIBTERMKEY_LIBRARIES})
find_package(LIBVTERM 0.3 REQUIRED)
-target_include_directories(main_lib SYSTEM INTERFACE ${LIBVTERM_INCLUDE_DIRS})
+target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${LIBVTERM_INCLUDE_DIRS})
target_link_libraries(main_lib INTERFACE ${LIBVTERM_LIBRARIES})
if(Iconv_FOUND)
- target_include_directories(main_lib SYSTEM INTERFACE ${Iconv_INCLUDE_DIRS})
+ target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${Iconv_INCLUDE_DIRS})
if(Iconv_LIBRARIES)
target_link_libraries(main_lib INTERFACE ${Iconv_LIBRARIES})
endif()
@@ -45,7 +45,7 @@ option(ENABLE_LIBINTL "enable libintl" ON)
if(ENABLE_LIBINTL)
# LibIntl (not Intl) selects our FindLibIntl.cmake script. #8464
find_package(LibIntl REQUIRED)
- target_include_directories(main_lib SYSTEM INTERFACE ${LibIntl_INCLUDE_DIRS})
+ target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${LibIntl_INCLUDE_DIRS})
if (LibIntl_FOUND)
target_link_libraries(main_lib INTERFACE ${LibIntl_LIBRARY})
endif()
@@ -55,13 +55,13 @@ endif()
option(PREFER_LUA "Prefer Lua over LuaJIT in the nvim executable." OFF)
if(PREFER_LUA)
find_package(Lua 5.1 EXACT REQUIRED)
- target_include_directories(main_lib SYSTEM INTERFACE ${LUA_INCLUDE_DIR})
+ target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${LUA_INCLUDE_DIR})
target_link_libraries(main_lib INTERFACE ${LUA_LIBRARIES})
# Passive (not REQUIRED): if LUAJIT_FOUND is not set, nvim-test is skipped.
find_package(LuaJit)
else()
find_package(LuaJit REQUIRED)
- target_include_directories(main_lib SYSTEM INTERFACE ${LUAJIT_INCLUDE_DIRS})
+ target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${LUAJIT_INCLUDE_DIRS})
target_link_libraries(main_lib INTERFACE ${LUAJIT_LIBRARIES})
endif()