@@ -12,6 +12,42 @@ else()
12
12
set (cmake_3_2_USES_TERMINAL USES_TERMINAL )
13
13
endif ()
14
14
15
+ macro (swift_common_standalone_build_config_clang product is_cross_compiling )
16
+ # Clang
17
+ set (${product} _PATH_TO_CLANG_SOURCE "${PATH_TO_LLVM_SOURCE} /tools/clang"
18
+ CACHE PATH "Path to Clang source code." )
19
+ set (${product} _PATH_TO_CLANG_BUILD "${PATH_TO_LLVM_BUILD} " CACHE PATH
20
+ "Path to the directory where Clang was built or installed." )
21
+
22
+ if (NOT EXISTS "${${product} _PATH_TO_CLANG_SOURCE}/include/clang/AST/Decl.h" )
23
+ message (FATAL_ERROR "Please set ${product} _PATH_TO_CLANG_SOURCE to the root directory of Clang's source code." )
24
+ else ()
25
+ get_filename_component (CLANG_MAIN_SRC_DIR ${${product}_PATH_TO_CLANG_SOURCE}
26
+ ABSOLUTE )
27
+ endif ()
28
+
29
+ if (EXISTS "${${product} _PATH_TO_CLANG_BUILD}/include/clang/Basic/Version.inc" )
30
+ set (CLANG_BUILD_INCLUDE_DIR "${${product} _PATH_TO_CLANG_BUILD}/include" )
31
+ elseif (EXISTS "${${product} _PATH_TO_CLANG_BUILD}/tools/clang/include/clang/Basic/Version.inc" )
32
+ set (CLANG_BUILD_INCLUDE_DIR "${${product} _PATH_TO_CLANG_BUILD}/tools/clang/include" )
33
+ else ()
34
+ message (FATAL_ERROR "Please set ${product} _PATH_TO_CLANG_BUILD to a directory containing a Clang build." )
35
+ endif ()
36
+ if (CLANG_MAIN_INCLUDE_DIR )
37
+ get_filename_component (CLANG_MAIN_SRC_DIR ${${product}_PATH_TO_CLANG_SOURCE}
38
+ ABSOLUTE )
39
+ endif ()
40
+
41
+ if (NOT ${is_cross_compiling} )
42
+ set (${product} _NATIVE_CLANG_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR} " )
43
+ endif ()
44
+
45
+ set (CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR} /include" )
46
+
47
+ include_directories ("${CLANG_BUILD_INCLUDE_DIR} "
48
+ "${CLANG_MAIN_INCLUDE_DIR} " )
49
+ endmacro ()
50
+
15
51
macro (swift_common_standalone_build_config_cmark product )
16
52
set (${product} _PATH_TO_CMARK_SOURCE "${${product} _PATH_TO_CMARK_SOURCE}"
17
53
CACHE PATH "Path to CMark source code." )
@@ -87,31 +123,6 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
87
123
precondition_translate_flag (LLVM_BUILD_BINARY_DIR LLVM_BINARY_DIR )
88
124
precondition_translate_flag (LLVM_BUILD_MAIN_SRC_DIR LLVM_MAIN_SRC_DIR )
89
125
90
- # Clang
91
- set (${product} _PATH_TO_CLANG_SOURCE "${PATH_TO_LLVM_SOURCE} /tools/clang"
92
- CACHE PATH "Path to Clang source code." )
93
- set (${product} _PATH_TO_CLANG_BUILD "${PATH_TO_LLVM_BUILD} " CACHE PATH
94
- "Path to the directory where Clang was built or installed." )
95
-
96
- if (NOT EXISTS "${${product} _PATH_TO_CLANG_SOURCE}/include/clang/AST/Decl.h" )
97
- message (FATAL_ERROR "Please set ${product} _PATH_TO_CLANG_SOURCE to the root directory of Clang's source code." )
98
- else ()
99
- get_filename_component (CLANG_MAIN_SRC_DIR ${${product}_PATH_TO_CLANG_SOURCE}
100
- ABSOLUTE )
101
- endif ()
102
-
103
- if (EXISTS "${${product} _PATH_TO_CLANG_BUILD}/include/clang/Basic/Version.inc" )
104
- set (CLANG_BUILD_INCLUDE_DIR "${${product} _PATH_TO_CLANG_BUILD}/include" )
105
- elseif (EXISTS "${${product} _PATH_TO_CLANG_BUILD}/tools/clang/include/clang/Basic/Version.inc" )
106
- set (CLANG_BUILD_INCLUDE_DIR "${${product} _PATH_TO_CLANG_BUILD}/tools/clang/include" )
107
- else ()
108
- message (FATAL_ERROR "Please set ${product} _PATH_TO_CLANG_BUILD to a directory containing a Clang build." )
109
- endif ()
110
- if (CLANG_MAIN_INCLUDE_DIR )
111
- get_filename_component (CLANG_MAIN_SRC_DIR ${${product}_PATH_TO_CLANG_SOURCE}
112
- ABSOLUTE )
113
- endif ()
114
-
115
126
if (${is_cross_compiling} )
116
127
find_program (SWIFT_TABLEGEN_EXE "llvm-tblgen" "${${product} _NATIVE_LLVM_TOOLS_PATH}"
117
128
NO_DEFAULT_PATH )
@@ -121,7 +132,6 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
121
132
else ()
122
133
set (SWIFT_TABLEGEN_EXE llvm-tblgen )
123
134
set (${product} _NATIVE_LLVM_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR} " )
124
- set (${product} _NATIVE_CLANG_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR} " )
125
135
endif ()
126
136
127
137
include (AddLLVM )
@@ -138,13 +148,9 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
138
148
"${PACKAGE_VERSION_MAJOR} .${PACKAGE_VERSION_MINOR} " CACHE STRING
139
149
"Version number that will be placed into the libclang library , in the form XX.YY" )
140
150
141
- set (CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR} /include" )
142
-
143
151
set (CMAKE_INCLUDE_CURRENT_DIR ON )
144
152
include_directories ("${PATH_TO_LLVM_BUILD} /include"
145
- "${LLVM_MAIN_INCLUDE_DIR} "
146
- "${CLANG_BUILD_INCLUDE_DIR} "
147
- "${CLANG_MAIN_INCLUDE_DIR} " )
153
+ "${LLVM_MAIN_INCLUDE_DIR} " )
148
154
foreach (INCLUDE_DIR ${LLVM_INCLUDE_DIRS} )
149
155
include_directories (${INCLUDE_DIR} )
150
156
endforeach ()
@@ -171,6 +177,7 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
171
177
find_package (Doxygen REQUIRED )
172
178
endif ()
173
179
180
+ swift_common_standalone_build_config_clang (${product} ${is_cross_compiling} )
174
181
swift_common_standalone_build_config_cmark (${product} )
175
182
endmacro ()
176
183
0 commit comments