forked from qt-creator/qt-creator
Clang: Fix enabling of ClangFormat plugin with RelWithDebInfo
RelWithDebInfo also builds in release mode, so just checking for the
build type to match is not enough.
Amends 6b62a99a8a
Fixes: QTCREATORBUG-25056
Change-Id: I5ea448e1cdd0cb3b76d052d6019337cdf13bdbc4
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -13,14 +13,39 @@ elseif (TARGET clang-cpp)
|
|||||||
set(CLANG_TOOLING_LIBS libclang clang-cpp)
|
set(CLANG_TOOLING_LIBS libclang clang-cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
SET(QTC_CLANG_BUILDMODE_MATCH ON)
|
|
||||||
if (WIN32 AND TARGET libclang)
|
if (WIN32 AND TARGET clangTooling)
|
||||||
string(TOLOWER ${CMAKE_BUILD_TYPE} _type)
|
# check that we can compile against clangTooling
|
||||||
get_target_property(_llvmConfigs libclang IMPORTED_CONFIGURATIONS)
|
# which requires the build modes to be compatible
|
||||||
string(TOLOWER ${_llvmConfigs} _llvm_configs)
|
# (debug vs release on Windows)
|
||||||
list(FIND _llvm_configs ${_type} _build_type_found)
|
include(CheckCxxSourceCompiles)
|
||||||
if (_build_type_found LESS 0)
|
|
||||||
set(QTC_CLANG_BUILDMODE_MATCH OFF)
|
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
|
||||||
message("Build mode mismatch (debug vs release): limiting clangTooling")
|
set(CMAKE_REQUIRED_INCLUDES ${CLANG_INCLUDE_DIRS})
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES clangTooling)
|
||||||
|
|
||||||
|
check_cxx_source_compiles([=[
|
||||||
|
#include <clang/Tooling/CommonOptionsParser.h>
|
||||||
|
#include <clang/Tooling/Tooling.h>
|
||||||
|
using namespace clang;
|
||||||
|
using namespace clang::tooling;
|
||||||
|
llvm::cl::OptionCategory CheckToolCategory("check tool options");
|
||||||
|
int main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
CommonOptionsParser OptionsParser(argc, argv, CheckToolCategory);
|
||||||
|
ClangTool Tool(OptionsParser.getCompilations(),
|
||||||
|
OptionsParser.getSourcePathList());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
]=] QTC_CLANG_BUILDMODE_MATCH
|
||||||
|
)
|
||||||
|
unset(CMAKE_TRY_COMPILE_CONFIGURATION)
|
||||||
|
unset(CMAKE_REQUIRED_INCLUDES)
|
||||||
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
else()
|
||||||
|
set(QTC_CLANG_BUILDMODE_MATCH ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT QTC_CLANG_BUILDMODE_MATCH)
|
||||||
|
message("Clang build mode mismatch (debug vs release): limiting clangTooling")
|
||||||
endif()
|
endif()
|
||||||
|
Reference in New Issue
Block a user