Skip to content

Commit

Permalink
fix ClangConfig.cmake target without header search path, bump CMake >= 3
Browse files Browse the repository at this point in the history
CMake bump is necessary to support irony_libclang INTERFACE library.

Fixes #530
  • Loading branch information
Sarcasm committed May 16, 2019
1 parent 80c3ce0 commit c3ae899
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12) # IMPORTED targets
cmake_minimum_required(VERSION 3.0.2)

project(IronyMode)

Expand Down
8 changes: 4 additions & 4 deletions server/cmake/modules/FindLibClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# LIBCLANG_LIBRARY_DIR - the path to the directory containing libclang
#
# This module defines the following IMPORTED target:
# - libclang
# - irony_libclang

# most recent versions come first
# http://llvm.org/apt/
Expand Down Expand Up @@ -96,9 +96,9 @@ find_package_handle_standard_args(LibClang DEFAULT_MSG

mark_as_advanced(LIBCLANG_INCLUDE_DIR LIBCLANG_LIBRARY)

if (LIBCLANG_FOUND AND NOT TARGET libclang)
add_library(libclang UNKNOWN IMPORTED)
set_target_properties(libclang PROPERTIES
if (LIBCLANG_FOUND AND NOT TARGET irony_libclang)
add_library(irony_libclang UNKNOWN IMPORTED)
set_target_properties(irony_libclang PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${LIBCLANG_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBCLANG_INCLUDE_DIR}"
Expand Down
20 changes: 12 additions & 8 deletions server/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# XXX: if there are issues
# due to https://reviews.llvm.org/D30911 / SVN Revision 298424
# then use the fallback when LLVM_VERSION VERSION_LESS 5.0.1
#
# XXX: at least since Clang 8.0.0
# it's looks like the 'libclang' IMPORTED target
# does not specify the following target property:
# INTERFACE_INCLUDE_DIRECTORIES ${CLANG_INCLUDE_DIRS}
# if it is an issue when Clang is installed in a non-standard location,
# this may need a workaround and an upstream patch
find_package(Clang)

if (Clang_FOUND)
# XXX: at least since Clang 8.0.0
# it's looks like the 'libclang' IMPORTED target
# does not specify the following target property:
# INTERFACE_INCLUDE_DIRECTORIES ${CLANG_INCLUDE_DIRS}
# which is confirmed by https://github.com/Sarcasm/irony-mode/issues/530
# so we work around this,
# but ideally Clang upstream should export fully usable IMPORTED targets
add_library(irony_libclang INTERFACE)
target_link_libraries(irony_libclang INTERFACE libclang)
target_include_directories(irony_libclang INTERFACE ${CLANG_INCLUDE_DIRS})

get_property(IRONY_CLANG_EXECUTABLE TARGET clang PROPERTY LOCATION)
execute_process(
COMMAND "${IRONY_CLANG_EXECUTABLE}" -print-resource-dir
Expand Down Expand Up @@ -99,7 +103,7 @@ if (CLANG_RESOURCE_DIR)
COMPILE_DEFINITIONS CLANG_RESOURCE_DIR=\"${CLANG_RESOURCE_DIR}\")
endif()

target_link_libraries(irony-server libclang)
target_link_libraries(irony-server irony_libclang)

set_target_properties(irony-server
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
Expand Down

0 comments on commit c3ae899

Please sign in to comment.