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)
|
||||
endif()
|
||||
|
||||
SET(QTC_CLANG_BUILDMODE_MATCH ON)
|
||||
if (WIN32 AND TARGET libclang)
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} _type)
|
||||
get_target_property(_llvmConfigs libclang IMPORTED_CONFIGURATIONS)
|
||||
string(TOLOWER ${_llvmConfigs} _llvm_configs)
|
||||
list(FIND _llvm_configs ${_type} _build_type_found)
|
||||
if (_build_type_found LESS 0)
|
||||
set(QTC_CLANG_BUILDMODE_MATCH OFF)
|
||||
message("Build mode mismatch (debug vs release): limiting clangTooling")
|
||||
|
||||
if (WIN32 AND TARGET clangTooling)
|
||||
# check that we can compile against clangTooling
|
||||
# which requires the build modes to be compatible
|
||||
# (debug vs release on Windows)
|
||||
include(CheckCxxSourceCompiles)
|
||||
|
||||
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
|
||||
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()
|
||||
|
||||
if (NOT QTC_CLANG_BUILDMODE_MATCH)
|
||||
message("Clang build mode mismatch (debug vs release): limiting clangTooling")
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user