blob: 1133558dc76c346a199356b517c294c2c0d04324 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
find_package(Clang CONFIG)
# silence a lot of warnings from building against llvm
if(MSVC AND TARGET libclang)
target_compile_options(libclang INTERFACE /wd4267)
endif()
option(CLANGTOOLING_LINK_CLANG_DYLIB "Force linking of Clang tooling against clang-cpp" NO)
if (TARGET clangTooling AND NOT CLANGTOOLING_LINK_CLANG_DYLIB)
set(CLANG_TOOLING_LIBS libclang clangTooling clangQuery clangIndex)
set(CLANG_FORMAT_LIB clangFormat)
elseif (TARGET clang-cpp)
set(CLANG_TOOLING_LIBS libclang clang-cpp)
set(CLANG_FORMAT_LIB clang-cpp)
endif()
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)
{
class Parser : public CommonOptionsParser {
public:
Parser(int &argc, const char **argv, llvm::cl::OptionCategory &Category) :
CommonOptionsParser(argc, argv, Category) {}
};
Parser 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)
elseif(TARGET clangTooling)
set(QTC_CLANG_BUILDMODE_MATCH ON)
endif()
if (TARGET clangTooling AND NOT QTC_CLANG_BUILDMODE_MATCH)
message("Clang build mode mismatch (debug vs release): limiting clangTooling")
endif()
|