1 set(LLVM_LINK_COMPONENTS
9 add_subdirectory(Inclusions)
10 add_subdirectory(Refactoring)
11 add_subdirectory(ASTDiff)
12 add_subdirectory(DumpTool)
13 add_subdirectory(Syntax)
14 add_subdirectory(DependencyScanning)
15 add_subdirectory(Transformer)
17 # Replace the last lib component of the current binary directory with include
18 string(FIND ${CMAKE_CURRENT_BINARY_DIR} "/lib/" PATH_LIB_START REVERSE)
19 if(PATH_LIB_START EQUAL -1)
20 message(FATAL_ERROR "Couldn't find lib component in binary directory")
22 math(EXPR PATH_LIB_END "${PATH_LIB_START}+5")
23 string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD)
24 string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} ${PATH_LIB_END} -1 PATH_TAIL)
25 string(CONCAT BINARY_INCLUDE_DIR ${PATH_HEAD} "/include/clang/" ${PATH_TAIL})
27 if (NOT Python3_EXECUTABLE
29 OR CMAKE_CROSSCOMPILING
30 OR GENERATOR_IS_MULTI_CONFIG
31 OR NOT LLVM_NATIVE_ARCH IN_LIST LLVM_TARGETS_TO_BUILD
34 EmptyNodeIntrospection.inc.in
35 ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
38 set(CLANG_TOOLING_BUILD_AST_INTROSPECTION "OFF" CACHE BOOL "")
40 # The generation of ASTNodeAPI.json takes a long time in a
41 # Debug build due to parsing AST.h. Disable the processing
42 # but setting CLANG_TOOLING_BUILD_AST_INTROSPECTION as an
43 # internal hidden setting to override.
44 # When the processing is disabled, a trivial/empty JSON
45 # file is generated by clang-ast-dump and generate_cxx_src_locs.py
46 # generates the same API, but with a trivial implementation.
47 option(CLANG_TOOLING_BUILD_AST_INTROSPECTION "Enable AST introspection" TRUE)
49 set(skip_expensive_processing $<OR:$<CONFIG:Debug>,$<NOT:$<BOOL:${CLANG_TOOLING_BUILD_AST_INTROSPECTION}>>>)
52 foreach(implicitDir ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
53 list(APPEND implicitDirs -I ${implicitDir})
56 include(GetClangResourceDir)
57 get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR})
59 COMMENT Generate ASTNodeAPI.json
60 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
61 DEPENDS clang-ast-dump clang-resource-headers
63 $<TARGET_FILE:clang-ast-dump>
64 # Skip this in debug mode because parsing AST.h is too slow
65 --skip-processing=${skip_expensive_processing}
66 -I ${resource_dir}/include
67 -I ${CLANG_SOURCE_DIR}/include
68 -I ${LLVM_BINARY_DIR}/tools/clang/include
69 -I ${LLVM_BINARY_DIR}/include
70 -I ${LLVM_SOURCE_DIR}/include
72 --json-output-path ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
75 add_custom_target(run-ast-api-dump-tool
76 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
80 COMMENT Generate NodeIntrospection.inc
81 OUTPUT ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
82 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
83 ${CMAKE_CURRENT_SOURCE_DIR}/DumpTool/generate_cxx_src_locs.py
84 ${CMAKE_CURRENT_SOURCE_DIR}/EmptyNodeIntrospection.inc.in
86 ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/DumpTool/generate_cxx_src_locs.py
87 --json-input-path ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
88 --output-file NodeIntrospection.inc
89 --use-empty-implementation ${skip_expensive_processing}
90 --empty-implementation
91 "${CMAKE_CURRENT_SOURCE_DIR}/EmptyNodeIntrospection.inc.in"
93 ${CMAKE_COMMAND} -E copy_if_different
94 ${CMAKE_CURRENT_BINARY_DIR}/NodeIntrospection.inc
95 ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
98 add_custom_target(run-ast-api-generate-tool
100 ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
104 add_clang_library(clangTooling
106 ArgumentsAdjusters.cpp
107 CommonOptionsParser.cpp
108 CompilationDatabase.cpp
110 ExpandResponseFilesCompilationDatabase.cpp
113 GuessTargetAndModeCompilationDatabase.cpp
114 InterpolatingCompilationDatabase.cpp
115 JSONCompilationDatabase.cpp
117 RefactoringCallbacks.cpp
118 StandaloneExecution.cpp
119 NodeIntrospection.cpp
120 ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc