diff --git a/cmake/modules/FindClang.cmake b/cmake/modules/FindClang.cmake index c7498feece..92086b96de 100644 --- a/cmake/modules/FindClang.cmake +++ b/cmake/modules/FindClang.cmake @@ -1,135 +1,140 @@ # Detect Clang libraries # # Defines the following variables: # CLANG_FOUND - True if Clang was found # CLANG_INCLUDE_DIRS - Where to find Clang includes # CLANG_LIBRARY_DIRS - Where to find Clang libraries # CLANG_BUILTIN_DIR - Where to find Clang builtin includes # # CLANG_CLANG_LIB - Libclang C library # # CLANG_CLANGFRONTEND_LIB - Clang Frontend (C++) Library # CLANG_CLANGDRIVER_LIB - Clang Driver (C++) Library # ... # # CLANG_LIBS - All the Clang C++ libraries # # Uses the same include and library paths detected by FindLLVM.cmake # # See http://clang.llvm.org/docs/InternalsManual.html for full list of libraries #============================================================================= # Copyright 2014-2015 Kevin Funk # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= set(KNOWN_VERSIONS 8 7 6.0 5.0 4.0 3.9 3.8) foreach(version ${KNOWN_VERSIONS}) if (LLVM_DIR OR (DEFINED Clang_FIND_VERSION AND Clang_FIND_VERSION VERSION_GREATER version)) break() endif () if (${Clang_FIND_REQUIRED}) find_package(LLVM ${version} REQUIRED) else () find_package(LLVM ${version}) endif () endforeach() set(CLANG_FOUND FALSE) if (LLVM_FOUND AND LLVM_LIBRARY_DIRS) macro(FIND_AND_ADD_CLANG_LIB _libname_) string(TOUPPER ${_libname_} _prettylibname_) find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_} HINTS ${LLVM_LIBRARY_DIRS} ${ARGN}) if (CLANG_${_prettylibname_}_LIB) set(CLANG_LIBS ${CLANG_LIBS} ${CLANG_${_prettylibname_}_LIB}) endif() endmacro(FIND_AND_ADD_CLANG_LIB) FIND_AND_ADD_CLANG_LIB(clangFrontend) # note: On Windows there's 'libclang.dll' instead of 'clang.dll' -> search for 'libclang', too FIND_AND_ADD_CLANG_LIB(clang NAMES clang libclang) # LibClang: high-level C interface FIND_AND_ADD_CLANG_LIB(clangDriver) FIND_AND_ADD_CLANG_LIB(clangCodeGen) FIND_AND_ADD_CLANG_LIB(clangSema) FIND_AND_ADD_CLANG_LIB(clangChecker) FIND_AND_ADD_CLANG_LIB(clangAnalysis) FIND_AND_ADD_CLANG_LIB(clangRewriteFrontend) FIND_AND_ADD_CLANG_LIB(clangRewrite) FIND_AND_ADD_CLANG_LIB(clangAST) FIND_AND_ADD_CLANG_LIB(clangParse) FIND_AND_ADD_CLANG_LIB(clangLex) FIND_AND_ADD_CLANG_LIB(clangBasic) FIND_AND_ADD_CLANG_LIB(clangARCMigrate) FIND_AND_ADD_CLANG_LIB(clangEdit) FIND_AND_ADD_CLANG_LIB(clangFrontendTool) FIND_AND_ADD_CLANG_LIB(clangSerialization) FIND_AND_ADD_CLANG_LIB(clangTooling) FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCheckers) FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCore) FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerFrontend) FIND_AND_ADD_CLANG_LIB(clangRewriteCore) endif() if(CLANG_LIBS OR CLANG_CLANG_LIB) set(CLANG_FOUND TRUE) else() message(STATUS "Could not find any Clang libraries in ${LLVM_LIBRARY_DIRS}") endif() if(CLANG_FOUND) set(CLANG_LIBRARY_DIRS ${LLVM_LIBRARY_DIRS}) set(CLANG_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) set(CLANG_VERSION ${LLVM_VERSION}) + # svn version of clang has a svn suffix "8.0.0svn" but installs the header in "8.0.0", without the suffix + string(REPLACE "svn" "" CLANG_VERSION_CLEAN "${CLANG_VERSION}") + find_path(CLANG_BUILTIN_DIR # cpuid.h because it is defined in ClangSupport constructor as valid clang builtin dir indicator NAMES "cpuid.h" PATHS "${CLANG_LIBRARY_DIRS}" "${CLANG_INCLUDE_DIRS}" PATH_SUFFIXES "clang/${CLANG_VERSION}/include" "../../../clang/${CLANG_VERSION}/include" + "clang/${CLANG_VERSION_CLEAN}/include" + "../../../clang/${CLANG_VERSION_CLEAN}/include" NO_DEFAULT_PATH ) if (NOT CLANG_BUILTIN_DIR) message(FATAL_ERROR "Could not find Clang builtin directory") endif() get_filename_component(CLANG_BUILTIN_DIR ${CLANG_BUILTIN_DIR} ABSOLUTE) # check whether llvm-config comes from an install prefix execute_process( COMMAND ${LLVM_CONFIG_EXECUTABLE} --src-root OUTPUT_VARIABLE _llvmSourceRoot OUTPUT_STRIP_TRAILING_WHITESPACE ) string(FIND "${LLVM_INCLUDE_DIRS}" "${_llvmSourceRoot}" _llvmIsInstalled) if (NOT _llvmIsInstalled) message(STATUS "Detected that llvm-config comes from a build-tree, adding more include directories for Clang") list(APPEND CLANG_INCLUDE_DIRS "${LLVM_INSTALL_PREFIX}/tools/clang/include" # build dir "${_llvmSourceRoot}/tools/clang/include" # source dir ) endif() message(STATUS "Found Clang (LLVM version: ${CLANG_VERSION})") message(STATUS " Include dirs: ${CLANG_INCLUDE_DIRS}") message(STATUS " Clang libraries: ${CLANG_LIBS}") message(STATUS " Libclang C library: ${CLANG_CLANG_LIB}") message(STATUS " Builtin include dir: ${CLANG_BUILTIN_DIR}") else() if(Clang_FIND_REQUIRED) message(FATAL_ERROR "Could NOT find Clang") endif() endif() diff --git a/plugins/execute/projecttargetscombobox.cpp b/plugins/execute/projecttargetscombobox.cpp index eb84c0cd90..d2eb68c3a9 100644 --- a/plugins/execute/projecttargetscombobox.cpp +++ b/plugins/execute/projecttargetscombobox.cpp @@ -1,90 +1,93 @@ /* This file is part of KDevelop Copyright 2010 Aleix Pol Gonzalez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "projecttargetscombobox.h" #include #include #include #include #include #include using namespace KDevelop; ProjectTargetsComboBox::ProjectTargetsComboBox(QWidget* parent) : QComboBox(parent) { } class ExecutablePathsVisitor : public ProjectVisitor { public: explicit ExecutablePathsVisitor(bool exec) : m_onlyExecutables(exec) {} using ProjectVisitor::visit; void visit(ProjectExecutableTargetItem* eit) override { if(!m_onlyExecutables || eit->type()==ProjectTargetItem::ExecutableTarget) m_paths += KDevelop::joinWithEscaping(eit->model()->pathFromIndex(eit->index()), QLatin1Char('/'), QLatin1Char('\\')); } QStringList paths() const { return m_paths; } + void sort() { m_paths.sort(); } + private: bool m_onlyExecutables; QStringList m_paths; }; void ProjectTargetsComboBox::setBaseItem(ProjectFolderItem* item, bool exec) { clear(); QList items; if(item) { items += item; } else { const auto projects = ICore::self()->projectController()->projects(); items.reserve(projects.size()); for (auto* p : projects) { items += p->projectItem(); } } - + ExecutablePathsVisitor walker(exec); foreach(ProjectFolderItem* item, items) { walker.visit(item); } - + walker.sort(); + foreach(const QString& item, walker.paths()) addItem(QIcon::fromTheme(QStringLiteral("system-run")), item); - + } QStringList ProjectTargetsComboBox::currentItemPath() const { return KDevelop::splitWithEscaping(currentText(), QLatin1Char('/'), QLatin1Char('\\')); } void ProjectTargetsComboBox::setCurrentItemPath(const QStringList& str) { setCurrentIndex(str.isEmpty() && count() ? 0 : findText(KDevelop::joinWithEscaping(str, QLatin1Char('/'), QLatin1Char('\\')))); }