Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 893404
Collapse All | Expand All

(-)a/cmake/modules/FindClang.cmake (-152 lines)
Lines 1-152 Link Here
1
# Detect Clang libraries
2
#
3
# Defines the following variables:
4
#  CLANG_FOUND                 - True if Clang was found
5
#  CLANG_INCLUDE_DIRS          - Where to find Clang includes
6
#  CLANG_LIBRARY_DIRS          - Where to find Clang libraries
7
#  CLANG_BUILTIN_DIR           - Where to find Clang builtin includes
8
#
9
#  CLANG_CLANG_LIB             - Libclang C library
10
#
11
#  CLANG_CLANGFRONTEND_LIB     - Clang Frontend (C++) Library
12
#  CLANG_CLANGDRIVER_LIB       - Clang Driver (C++) Library
13
#  ...
14
#
15
#  CLANG_LIBS                  - All the Clang C++ libraries
16
#
17
# Uses the same include and library paths detected by FindLLVM.cmake
18
#
19
# See https://clang.llvm.org/docs/InternalsManual.html for full list of libraries
20
21
#=============================================================================
22
# SPDX-FileCopyrightText: 2014-2015 Kevin Funk <kfunk@kde.org>
23
#
24
# SPDX-License-Identifier: BSD-3-Clause
25
#=============================================================================
26
27
set(KNOWN_VERSIONS 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8)
28
29
foreach(version ${KNOWN_VERSIONS})
30
    if(LLVM_FOUND OR (DEFINED Clang_FIND_VERSION AND Clang_FIND_VERSION VERSION_GREATER version))
31
        # already found or version doesn't match
32
        break()
33
    endif()
34
35
    find_package(LLVM ${version} QUIET)
36
endforeach()
37
38
if (${Clang_FIND_REQUIRED})
39
    if(NOT DEFINED Clang_FIND_VERSION)
40
        message(SEND_ERROR "Could not find Clang.")
41
    else()
42
        message("Found version ${Clang_FIND_VERSION}")
43
    endif()
44
endif()
45
46
set(CLANG_FOUND FALSE)
47
48
if (LLVM_FOUND AND LLVM_LIBRARY_DIRS)
49
  macro(FIND_AND_ADD_CLANG_LIB _libname_)
50
    string(TOUPPER ${_libname_} _prettylibname_)
51
    find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_} HINTS ${LLVM_LIBRARY_DIRS} ${ARGN})
52
    if (CLANG_${_prettylibname_}_LIB)
53
      set(CLANG_LIBS ${CLANG_LIBS} ${CLANG_${_prettylibname_}_LIB})
54
    endif()
55
  endmacro(FIND_AND_ADD_CLANG_LIB)
56
57
  FIND_AND_ADD_CLANG_LIB(clangFrontend)
58
59
  # note: On Windows there's 'libclang.dll' instead of 'clang.dll' -> search for 'libclang', too
60
  FIND_AND_ADD_CLANG_LIB(clang NAMES clang libclang) # LibClang: high-level C interface
61
62
  FIND_AND_ADD_CLANG_LIB(clangDriver)
63
  FIND_AND_ADD_CLANG_LIB(clangCodeGen)
64
  FIND_AND_ADD_CLANG_LIB(clangSema)
65
  FIND_AND_ADD_CLANG_LIB(clangChecker)
66
  FIND_AND_ADD_CLANG_LIB(clangAnalysis)
67
  FIND_AND_ADD_CLANG_LIB(clangRewriteFrontend)
68
  FIND_AND_ADD_CLANG_LIB(clangRewrite)
69
  FIND_AND_ADD_CLANG_LIB(clangAST)
70
  FIND_AND_ADD_CLANG_LIB(clangParse)
71
  FIND_AND_ADD_CLANG_LIB(clangLex)
72
  FIND_AND_ADD_CLANG_LIB(clangBasic)
73
  FIND_AND_ADD_CLANG_LIB(clangARCMigrate)
74
  FIND_AND_ADD_CLANG_LIB(clangEdit)
75
  FIND_AND_ADD_CLANG_LIB(clangFrontendTool)
76
  FIND_AND_ADD_CLANG_LIB(clangSerialization)
77
  FIND_AND_ADD_CLANG_LIB(clangTooling)
78
  FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCheckers)
79
  FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCore)
80
  FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerFrontend)
81
  FIND_AND_ADD_CLANG_LIB(clangRewriteCore)
82
endif()
83
84
if(CLANG_LIBS OR CLANG_CLANG_LIB)
85
  set(CLANG_FOUND TRUE)
86
else()
87
  message(STATUS "Could not find any Clang libraries in ${LLVM_LIBRARY_DIRS}")
88
endif()
89
90
if(CLANG_FOUND)
91
  set(CLANG_LIBRARY_DIRS ${LLVM_LIBRARY_DIRS})
92
  set(CLANG_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
93
  set(CLANG_VERSION ${LLVM_VERSION})
94
95
  # svn version of clang has a svn suffix "8.0.0svn" but installs the header in "8.0.0", without the suffix
96
  string(REPLACE "svn" "" CLANG_VERSION_CLEAN "${CLANG_VERSION}")
97
  # dito for git
98
  string(REPLACE "git" "" CLANG_VERSION_CLEAN "${CLANG_VERSION}")
99
100
  find_path(CLANG_BUILTIN_DIR
101
            # cpuid.h because it is defined in ClangSupport constructor as valid clang builtin dir indicator
102
            NAMES "cpuid.h"
103
            PATHS "${CLANG_LIBRARY_DIRS}"
104
                  "${CLANG_INCLUDE_DIRS}"
105
            PATH_SUFFIXES "clang/${CLANG_VERSION}/include"
106
                          "../../../clang/${CLANG_VERSION}/include"
107
                          "clang/${CLANG_VERSION_CLEAN}/include"
108
                          "../../../clang/${CLANG_VERSION_CLEAN}/include"
109
            NO_DEFAULT_PATH
110
  )
111
112
  if (NOT CLANG_BUILTIN_DIR)
113
      message(FATAL_ERROR "Could not find Clang builtin directory")
114
  endif()
115
  get_filename_component(CLANG_BUILTIN_DIR ${CLANG_BUILTIN_DIR} ABSOLUTE)
116
117
  # check whether llvm-config comes from an install prefix
118
  execute_process(
119
    COMMAND ${LLVM_CONFIG_EXECUTABLE} --src-root
120
    OUTPUT_VARIABLE _llvmSourceRoot
121
    OUTPUT_STRIP_TRAILING_WHITESPACE
122
  )
123
  string(FIND "${LLVM_INCLUDE_DIRS}" "${_llvmSourceRoot}" _llvmIsInstalled)
124
  if (NOT _llvmIsInstalled)
125
    message(STATUS "Detected that llvm-config comes from a build-tree, adding more include directories for Clang")
126
    list(APPEND CLANG_INCLUDE_DIRS
127
         "${LLVM_INSTALL_PREFIX}/tools/clang/include" # build dir
128
    )
129
130
    # check whether the source is from llvm-project.git (currently recommended way to clone the LLVM projects)
131
    # contains all LLVM projects in the top-level directory
132
    get_filename_component(_llvmProjectClangIncludeDir ${_llvmSourceRoot}/../clang/include REALPATH)
133
    if (EXISTS ${_llvmProjectClangIncludeDir})
134
        message(STATUS "  Note: llvm-project.git structure detected, using different include path pointing into source dir")
135
        list(APPEND CLANG_INCLUDE_DIRS "${_llvmProjectClangIncludeDir}") # source dir
136
    else()
137
        list(APPEND CLANG_INCLUDE_DIRS "${_llvmSourceRoot}/tools/clang/include") # source dir
138
    endif()
139
  endif()
140
141
  if(NOT Clang_FIND_QUIETLY)
142
    message(STATUS "Found Clang (LLVM version: ${CLANG_VERSION})")
143
    message(STATUS "  Include dirs:        ${CLANG_INCLUDE_DIRS}")
144
    message(STATUS "  Clang libraries:     ${CLANG_LIBS}")
145
    message(STATUS "  Libclang C library:  ${CLANG_CLANG_LIB}")
146
    message(STATUS "  Builtin include dir: ${CLANG_BUILTIN_DIR}")
147
   endif()
148
else()
149
  if(Clang_FIND_REQUIRED)
150
    message(FATAL_ERROR "Could NOT find Clang")
151
  endif()
152
endif()
(-)a/cmake/modules/FindLLVM.cmake (-152 lines)
Lines 1-152 Link Here
1
# Find the native LLVM includes and libraries
2
#
3
# Defines the following variables
4
#  LLVM_INCLUDE_DIRS   - where to find llvm include files
5
#  LLVM_LIBRARY_DIRS   - where to find llvm libs
6
#  LLVM_CFLAGS         - llvm compiler flags
7
#  LLVM_LFLAGS         - llvm linker flags
8
#  LLVM_MODULE_LIBS    - list of llvm libs for working with modules.
9
#  LLVM_INSTALL_PREFIX - LLVM installation prefix
10
#  LLVM_FOUND          - True if llvm found.
11
#  LLVM_VERSION        - Version string ("llvm-config --version")
12
#
13
# This module reads hints about search locations from variables
14
#  LLVM_ROOT           - Preferred LLVM installation prefix (containing bin/, lib/, ...)
15
#
16
#  Note: One may specify these as environment variables if they are not specified as
17
#   CMake variables or cache entries.
18
19
#=============================================================================
20
# SPDX-FileCopyrightText: 2014 Kevin Funk <kfunk@kde.org>
21
#
22
# SPDX-License-Identifier: BSD-3-Clause
23
#=============================================================================
24
25
if (NOT LLVM_ROOT AND DEFINED ENV{LLVM_ROOT})
26
    file(TO_CMAKE_PATH "$ENV{LLVM_ROOT}" LLVM_ROOT)
27
endif()
28
29
# if the user specified LLVM_ROOT, use that and fail otherwise
30
if (LLVM_ROOT)
31
  find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config HINTS ${LLVM_ROOT}/bin DOC "llvm-config executable" NO_DEFAULT_PATH)
32
elseif (NOT LLVM_CONFIG_EXECUTABLE)
33
  # find llvm-config, prefer the one with a version suffix, e.g. llvm-config-3.5
34
  # note: FreeBSD installs llvm-config as llvm-config35 and so on
35
  # note: on some distributions, only 'llvm-config' is shipped, so let's always try to fallback on that
36
  string(REPLACE "." "" LLVM_FIND_VERSION_CONCAT ${LLVM_FIND_VERSION})
37
  find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config-${LLVM_FIND_VERSION} llvm-config${LLVM_FIND_VERSION_CONCAT} llvm-config DOC "llvm-config executable")
38
39
  # other distributions don't ship llvm-config, but only some llvm-config-VERSION binary
40
  # try to deduce installed LLVM version by looking up llvm-nm in PATH and *then* find llvm-config-VERSION via that
41
  if (NOT LLVM_CONFIG_EXECUTABLE)
42
    find_program(_llvmNmExecutable llvm-nm)
43
    if (_llvmNmExecutable)
44
      execute_process(COMMAND ${_llvmNmExecutable} --version OUTPUT_VARIABLE _out)
45
      string(REGEX REPLACE ".*LLVM version ([^ \n]+).*" "\\1" _versionString "${_out}")
46
      find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config-${_versionString} DOC "llvm-config executable")
47
    endif()
48
  endif()
49
endif()
50
51
set(LLVM_FOUND FALSE)
52
53
if (LLVM_CONFIG_EXECUTABLE)
54
  # verify that we've found the correct version of llvm-config
55
  execute_process(COMMAND ${LLVM_CONFIG_EXECUTABLE} --version
56
    OUTPUT_VARIABLE LLVM_VERSION
57
    OUTPUT_STRIP_TRAILING_WHITESPACE)
58
59
  if (NOT LLVM_VERSION)
60
    set(_LLVM_ERROR_MESSAGE "Failed to parse version from ${LLVM_CONFIG_EXECUTABLE}")
61
    unset(LLVM_CONFIG_EXECUTABLE CACHE)
62
  elseif (LLVM_FIND_VERSION VERSION_GREATER LLVM_VERSION)
63
    set(_LLVM_ERROR_MESSAGE "${LLVM_CONFIG_EXECUTABLE} (version ${LLVM_VERSION}) unsuitable: too old for requested version ${LLVM_FIND_VERSION}")
64
    unset(LLVM_CONFIG_EXECUTABLE CACHE)
65
  else()
66
    set(LLVM_FOUND TRUE)
67
  endif()
68
else()
69
  set(_LLVM_ERROR_MESSAGE "Could NOT find 'llvm-config' executable")
70
endif()
71
72
if (LLVM_FOUND)
73
  execute_process(
74
    COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir
75
    OUTPUT_VARIABLE LLVM_INCLUDE_DIRS
76
    OUTPUT_STRIP_TRAILING_WHITESPACE
77
  )
78
79
  execute_process(
80
    COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir
81
    OUTPUT_VARIABLE LLVM_LIBRARY_DIRS
82
    OUTPUT_STRIP_TRAILING_WHITESPACE
83
  )
84
85
  execute_process(
86
    COMMAND ${LLVM_CONFIG_EXECUTABLE} --cppflags
87
    OUTPUT_VARIABLE LLVM_CFLAGS
88
    OUTPUT_STRIP_TRAILING_WHITESPACE
89
  )
90
91
  execute_process(
92
    COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags
93
    OUTPUT_VARIABLE LLVM_LFLAGS
94
    OUTPUT_STRIP_TRAILING_WHITESPACE
95
  )
96
97
  execute_process(
98
    COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs core bitreader asmparser analysis
99
    OUTPUT_VARIABLE LLVM_MODULE_LIBS
100
    OUTPUT_STRIP_TRAILING_WHITESPACE
101
  )
102
103
  execute_process(
104
    COMMAND ${LLVM_CONFIG_EXECUTABLE} --libfiles
105
    OUTPUT_VARIABLE LLVM_LIBS
106
    OUTPUT_STRIP_TRAILING_WHITESPACE
107
  )
108
109
  execute_process(
110
    COMMAND ${LLVM_CONFIG_EXECUTABLE} --prefix
111
    OUTPUT_VARIABLE LLVM_INSTALL_PREFIX
112
    OUTPUT_STRIP_TRAILING_WHITESPACE
113
  )
114
  
115
  if (NOT ${LLVM_VERSION} VERSION_LESS "3.8.0") 
116
    execute_process(
117
        COMMAND ${LLVM_CONFIG_EXECUTABLE} --shared-mode
118
        OUTPUT_VARIABLE _LLVM_SHARED_MODE
119
        OUTPUT_STRIP_TRAILING_WHITESPACE
120
    )
121
    if (_LLVM_SHARED_MODE STREQUAL "shared")
122
        set(LLVM_SHARED_MODE ON)
123
    else()
124
        set(LLVM_SHARED_MODE OFF)
125
    endif()
126
  else()
127
    set(LLVM_SHARED_MODE OFF)
128
  endif()
129
130
  # potentially add include dir from binary dir for non-installed LLVM
131
  execute_process(
132
    COMMAND ${LLVM_CONFIG_EXECUTABLE} --src-root
133
    OUTPUT_VARIABLE _llvmSourceRoot
134
    OUTPUT_STRIP_TRAILING_WHITESPACE
135
  )
136
  string(FIND "${LLVM_INCLUDE_DIRS}" "${_llvmSourceRoot}" _llvmIsInstalled)
137
  if (NOT _llvmIsInstalled)
138
    list(APPEND LLVM_INCLUDE_DIRS "${LLVM_INSTALL_PREFIX}/include")
139
  endif()
140
endif()
141
142
if (LLVM_FIND_REQUIRED AND NOT LLVM_FOUND)
143
  message(FATAL_ERROR "Could not find LLVM: ${_LLVM_ERROR_MESSAGE}")
144
elseif(_LLVM_ERROR_MESSAGE AND NOT LLVM_FIND_QUIETLY)
145
  message(STATUS "Could not find LLVM: ${_LLVM_ERROR_MESSAGE}")
146
endif()
147
148
if(LLVM_FOUND AND NOT LLVM_FIND_QUIETLY)
149
  message(STATUS "Found LLVM (version: ${LLVM_VERSION}): (using ${LLVM_CONFIG_EXECUTABLE})")
150
  message(STATUS "  Include dirs:   ${LLVM_INCLUDE_DIRS}")
151
  message(STATUS "  LLVM libraries: ${LLVM_LIBS}")
152
endif()
(-)a/plugins/clang/CMakeLists.txt (-3 / +15 lines)
Lines 1-6 Link Here
1
add_definitions(-DTRANSLATION_DOMAIN=\"kdevclang\")
1
add_definitions(-DTRANSLATION_DOMAIN=\"kdevclang\")
2
add_definitions(${LLVM_CFLAGS})
2
3
include_directories(${CLANG_INCLUDE_DIRS})
3
if (CLANG_INCLUDE_DIRS)
4
    # Targets that link against libclang should inherit Clang include directories
5
    # automatically from it. However, when new API is added to a libclang version
6
    # not installed in the system and this new API is used in KDevelop, KDevelop
7
    # does not compile without the manual include_directories() command below.
8
    # This is probably an upstream Clang issue, which KDevelop has to work around.
9
    include_directories(${CLANG_INCLUDE_DIRS})
10
else()
11
    message(WARNING "CLANG_INCLUDE_DIRS CMake variable is not set. \
12
Has ClangConfig.cmake renamed this variable or removed it as no longer needed?")
13
endif()
14
15
include(Locate_CLANG_BUILTIN_DIR.cmake)
4
16
5
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
17
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
6
check_cxx_source_compiles(
18
check_cxx_source_compiles(
Lines 89-95 Link Here
89
    KDev::Language
101
    KDev::Language
90
    KDev::Project
102
    KDev::Project
91
    KDev::Util
103
    KDev::Util
92
    Clang::clang
104
    Clang::libclang
93
PRIVATE
105
PRIVATE
94
    Qt5::Core
106
    Qt5::Core
95
    KF5::TextEditor
107
    KF5::TextEditor
(-)a/plugins/clang/duchain/clanghelpers.cpp (-5 / +16 lines)
Lines 383-388 Link Here
383
    return clangVersion;
383
    return clangVersion;
384
}
384
}
385
385
386
static QString majorClangVersion()
387
{
388
    const QString version = ClangHelpers::clangVersion();
389
    return version.left(version.indexOf(QLatin1Char{'.'}));
390
}
391
386
bool ClangHelpers::isValidClangBuiltingIncludePath(const QString& path)
392
bool ClangHelpers::isValidClangBuiltingIncludePath(const QString& path)
387
{
393
{
388
    return QFile::exists(path + QLatin1String("/cpuid.h"));
394
    return QFile::exists(path + QLatin1String("/cpuid.h"));
Lines 399-408 Link Here
399
            return dir;
405
            return dir;
400
        }
406
        }
401
407
408
        // Since https://github.com/llvm/llvm-project/commit/e1b88c8a09be25b86b13f98755a9bd744b4dbf14
409
        // Clang's resource directory includes only the major version.
410
        const QString majorVersion = majorClangVersion();
411
        const QString versionSubdir = majorVersion.toInt() >= 16 ? majorVersion : clangVersion();
412
402
#ifdef Q_OS_WIN32
413
#ifdef Q_OS_WIN32
403
        // attempt to use the bundled copy on Windows
414
        // attempt to use the bundled copy on Windows
404
        dir = QDir::cleanPath(QStringLiteral("%1/../lib/clang/%2/include")
415
        dir = QDir::cleanPath(
405
            .arg(QCoreApplication::applicationDirPath(), clangVersion()));
416
            QStringLiteral("%1/../lib/clang/%2/include").arg(QCoreApplication::applicationDirPath(), versionSubdir));
406
        if (isValidClangBuiltingIncludePath(dir)) {
417
        if (isValidClangBuiltingIncludePath(dir)) {
407
            clangDebug() << "Using builtin dir:" << dir;
418
            clangDebug() << "Using builtin dir:" << dir;
408
            return dir;
419
            return dir;
Lines 413-419 Link Here
413
        // changed. Try to generate the correct builtin_dir for the current
424
        // changed. Try to generate the correct builtin_dir for the current
414
        // major.minor.patchlevel version: pop the last 2 components then
425
        // major.minor.patchlevel version: pop the last 2 components then
415
        // chdir through with the updated version directory.
426
        // chdir through with the updated version directory.
416
        dir = QDir::cleanPath(QStringLiteral(KDEV_CLANG_BUILTIN_DIR "/../../%1/include").arg(clangVersion()));
427
        dir = QDir::cleanPath(QStringLiteral(KDEV_CLANG_BUILTIN_DIR "/../../%1/include").arg(versionSubdir));
417
        if (isValidClangBuiltingIncludePath(dir)) {
428
        if (isValidClangBuiltingIncludePath(dir)) {
418
            clangDebug() << "Using builtin dir:" << dir;
429
            clangDebug() << "Using builtin dir:" << dir;
419
            return dir;
430
            return dir;
Lines 425-432 Link Here
425
        // we find it by pass any symbol in libclang to dladdr
436
        // we find it by pass any symbol in libclang to dladdr
426
        Dl_info info;
437
        Dl_info info;
427
        if (dladdr(reinterpret_cast<void*>(&clang_getClangVersion), &info)) {
438
        if (dladdr(reinterpret_cast<void*>(&clang_getClangVersion), &info)) {
428
            dir = QDir::cleanPath(QStringLiteral("%1/../clang/%2/include")
439
            dir = QDir::cleanPath(
429
                .arg(QString::fromUtf8(info.dli_fname), clangVersion()));
440
                QStringLiteral("%1/../clang/%2/include").arg(QString::fromUtf8(info.dli_fname), versionSubdir));
430
            if (isValidClangBuiltingIncludePath(dir)) {
441
            if (isValidClangBuiltingIncludePath(dir)) {
431
                clangDebug() << "Using builtin dir:" << dir;
442
                clangDebug() << "Using builtin dir:" << dir;
432
                return dir;
443
                return dir;
(-)a/plugins/clang/Locate_CLANG_BUILTIN_DIR.cmake (+32 lines)
Line 0 Link Here
1
set(CLANG_VERSION "${LLVM_PACKAGE_VERSION}")
2
set(CLANG_VERSION_MAJOR "${LLVM_VERSION_MAJOR}")
3
4
# Since https://github.com/llvm/llvm-project/commit/e1b88c8a09be25b86b13f98755a9bd744b4dbf14
5
# Clang's resource directory includes only the major version.
6
if (CLANG_VERSION_MAJOR GREATER_EQUAL 16)
7
    set(CLANG_VERSION_SUBDIR "${CLANG_VERSION_MAJOR}")
8
else()
9
    # Git version of Clang ends with the "git" suffix, e.g. "14.0.0git", but
10
    # installs builtin headers into a subdirectory without the suffix, e.g. "14.0.0".
11
    string(REPLACE "git" "" CLANG_VERSION_SUBDIR "${CLANG_VERSION}")
12
endif()
13
14
message(STATUS "  LLVM library directories:   ${LLVM_LIBRARY_DIRS}")
15
message(STATUS "  Clang include directories:  ${CLANG_INCLUDE_DIRS}")
16
17
find_path(CLANG_BUILTIN_DIR
18
    # cpuid.h because it is defined in ClangSupport constructor as valid clang builtin dir indicator
19
    NAMES "cpuid.h"
20
    PATHS   "${LLVM_LIBRARY_DIRS}"
21
            "${CLANG_INCLUDE_DIRS}"
22
    PATH_SUFFIXES   "clang/${CLANG_VERSION_SUBDIR}/include"
23
                    "../../../clang/${CLANG_VERSION_SUBDIR}/include"
24
    NO_DEFAULT_PATH
25
)
26
27
if (NOT CLANG_BUILTIN_DIR)
28
    message(FATAL_ERROR "Could not find Clang builtin include directory")
29
endif()
30
get_filename_component(CLANG_BUILTIN_DIR "${CLANG_BUILTIN_DIR}" ABSOLUTE)
31
32
message(STATUS "  Builtin include directory:  ${CLANG_BUILTIN_DIR}")
(-)a/plugins/clang/tests/CMakeLists.txt (-2 / +2 lines)
Lines 28-34 Link Here
28
)
28
)
29
ecm_mark_nongui_executable(clang-minimal-visitor)
29
ecm_mark_nongui_executable(clang-minimal-visitor)
30
target_link_libraries(clang-minimal-visitor
30
target_link_libraries(clang-minimal-visitor
31
    Clang::clang
31
    Clang::libclang
32
)
32
)
33
33
34
ecm_add_test(test_buddies.cpp
34
ecm_add_test(test_buddies.cpp
Lines 59-65 Link Here
59
    LINK_LIBRARIES
59
    LINK_LIBRARIES
60
        KDev::Tests
60
        KDev::Tests
61
        Qt5::Test
61
        Qt5::Test
62
        Clang::clang
62
        Clang::libclang
63
        KDevClangPrivate
63
        KDevClangPrivate
64
)
64
)
65
65
(-)a/plugins/CMakeLists.txt (-10 / +14 lines)
Lines 36-59 Link Here
36
36
37
ecm_optional_add_subdirectory(qmljs)
37
ecm_optional_add_subdirectory(qmljs)
38
38
39
find_package(Clang 6.0)
39
find_package(Clang CONFIG)
40
set(clangSearchHint "")
40
set(clangSearchHint "")
41
if (NOT CLANG_FOUND)
41
if (NOT Clang_FOUND)
42
    set(clangSearchHint "Please install a package providing libclang. Either pass -DLLVM_ROOT=/path/to/llvm-prefix or install the 'llvm-config' command-line utility for auto-detection.")
42
    set(clangSearchHint "
43
        Please install a package providing libclang.
44
        You can pass -DClang_DIR=/path/to/lib/cmake/clang to cmake.
45
        You may need to remove stale CLANG_BUILTIN_DIR and LLVM_DIR CMake cache variables.")
43
endif()
46
endif()
44
set_package_properties(Clang PROPERTIES
47
set_package_properties(Clang PROPERTIES
45
    DESCRIPTION "Clang libraries from the LLVM project. ${clangSearchHint}"
48
    DESCRIPTION "Clang libraries from the LLVM project, required version >= 6.0${clangSearchHint}"
46
    PURPOSE "Used for KDevelop's C++/C support plugin."
49
    PURPOSE "Used for KDevelop's C++/C support plugin."
47
    TYPE REQUIRED
50
    TYPE REQUIRED
48
)
51
)
49
52
50
if (CLANG_FOUND)
53
if (Clang_FOUND)
51
    if (NOT CLANG_CLANG_LIB)
54
    message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
52
        message(FATAL_ERROR "Could not find the Clang C library: libclang")
55
    message(STATUS "  Using LLVMConfig.cmake in:  ${LLVM_DIR}")
53
    endif()
56
    message(STATUS "  Using ClangConfig.cmake in: ${Clang_DIR}")
54
57
55
    add_library(Clang::clang UNKNOWN IMPORTED)
58
    if (NOT TARGET Clang::libclang)
56
    set_property(TARGET Clang::clang PROPERTY IMPORTED_LOCATION ${CLANG_CLANG_LIB})
59
        add_library(Clang::libclang ALIAS libclang)
60
    endif()
57
    ecm_optional_add_subdirectory(clang)
61
    ecm_optional_add_subdirectory(clang)
58
endif()
62
endif()
59
# END: Languages
63
# END: Languages

Return to bug 893404