[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / lib / Tooling / CMakeLists.txt
blobaff39e4de13c0b2c85e33ca047e075d53722038b
1 set(LLVM_LINK_COMPONENTS
2   Option
3   FrontendOpenMP
4   Support
5   TargetParser
6   )
8 add_subdirectory(Core)
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")
21 endif()
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
28     OR APPLE
29     OR CMAKE_CROSSCOMPILING
30     OR GENERATOR_IS_MULTI_CONFIG
31     OR NOT LLVM_NATIVE_ARCH IN_LIST LLVM_TARGETS_TO_BUILD
32     )
33     configure_file(
34       EmptyNodeIntrospection.inc.in
35       ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
36       COPYONLY
37     )
38     set(CLANG_TOOLING_BUILD_AST_INTROSPECTION "OFF" CACHE BOOL "")
39 else()
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}>>>)
51   set(implicitDirs)
52   foreach(implicitDir ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
53     list(APPEND implicitDirs -I ${implicitDir})
54   endforeach()
56   include(GetClangResourceDir)
57   get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR})
58   add_custom_command(
59       COMMENT Generate ASTNodeAPI.json
60       OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
61       DEPENDS clang-ast-dump clang-resource-headers
62       COMMAND
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
71         ${implicitDirs}
72         --json-output-path ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
73   )
75   add_custom_target(run-ast-api-dump-tool
76       DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
77   )
79   add_custom_command(
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
85       COMMAND
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"
92       COMMAND
93       ${CMAKE_COMMAND} -E copy_if_different
94         ${CMAKE_CURRENT_BINARY_DIR}/NodeIntrospection.inc
95         ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
96   )
98   add_custom_target(run-ast-api-generate-tool
99       DEPENDS
100       ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
101   )
102 endif()
104 add_clang_library(clangTooling
105   AllTUsExecution.cpp
106   ArgumentsAdjusters.cpp
107   CommonOptionsParser.cpp
108   CompilationDatabase.cpp
109   Execution.cpp
110   ExpandResponseFilesCompilationDatabase.cpp
111   FileMatchTrie.cpp
112   FixIt.cpp
113   GuessTargetAndModeCompilationDatabase.cpp
114   InterpolatingCompilationDatabase.cpp
115   JSONCompilationDatabase.cpp
116   Refactoring.cpp
117   RefactoringCallbacks.cpp
118   StandaloneExecution.cpp
119   NodeIntrospection.cpp
120   ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
121   Tooling.cpp
123   DEPENDS
124   ClangDriverOptions
125   omp_gen
127   LINK_LIBS
128   clangAST
129   clangASTMatchers
130   clangBasic
131   clangDriver
132   clangFormat
133   clangFrontend
134   clangLex
135   clangRewrite
136   clangSerialization
137   clangToolingCore
138   )