@@ -12,16 +12,7 @@ else()
12
12
set (cmake_3_2_USES_TERMINAL USES_TERMINAL )
13
13
endif ()
14
14
15
- # Common cmake project config for standalone builds.
16
- #
17
- # Parameters:
18
- # product
19
- # The product name, e.g. Swift or SourceKit. Used as prefix for some
20
- # cmake variables.
21
- #
22
- # is_cross_compiling
23
- # Whether this is cross-compiling host tools.
24
- macro (swift_common_standalone_build_config product is_cross_compiling )
15
+ macro (swift_common_standalone_build_config_llvm product is_cross_compiling )
25
16
option (LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON )
26
17
27
18
precondition_translate_flag (${product} _PATH_TO_LLVM_SOURCE PATH_TO_LLVM_SOURCE )
@@ -68,44 +59,6 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
68
59
precondition_translate_flag (LLVM_BUILD_BINARY_DIR LLVM_BINARY_DIR )
69
60
precondition_translate_flag (LLVM_BUILD_MAIN_SRC_DIR LLVM_MAIN_SRC_DIR )
70
61
71
- # Clang
72
- set (${product} _PATH_TO_CLANG_SOURCE "${PATH_TO_LLVM_SOURCE} /tools/clang"
73
- CACHE PATH "Path to Clang source code." )
74
- set (${product} _PATH_TO_CLANG_BUILD "${PATH_TO_LLVM_BUILD} " CACHE PATH
75
- "Path to the directory where Clang was built or installed." )
76
-
77
- set (${product} _PATH_TO_CMARK_SOURCE "${${product} _PATH_TO_CMARK_SOURCE}"
78
- CACHE PATH "Path to CMark source code." )
79
- set (${product} _PATH_TO_CMARK_BUILD "${${product} _PATH_TO_CMARK_BUILD}"
80
- CACHE PATH "Path to the directory where CMark was built." )
81
- set (${product} _CMARK_LIBRARY_DIR "${${product} _CMARK_LIBRARY_DIR}" CACHE PATH
82
- "Path to the directory where CMark was installed." )
83
- get_filename_component (PATH_TO_CMARK_BUILD "${${product} _PATH_TO_CMARK_BUILD}"
84
- ABSOLUTE )
85
- get_filename_component (CMARK_MAIN_SRC_DIR "${${product} _PATH_TO_CMARK_SOURCE}"
86
- ABSOLUTE )
87
- get_filename_component (CMARK_LIBRARY_DIR "${${product} _CMARK_LIBRARY_DIR}"
88
- ABSOLUTE )
89
-
90
- if (NOT EXISTS "${${product} _PATH_TO_CLANG_SOURCE}/include/clang/AST/Decl.h" )
91
- message (FATAL_ERROR "Please set ${product} _PATH_TO_CLANG_SOURCE to the root directory of Clang's source code." )
92
- else ()
93
- get_filename_component (CLANG_MAIN_SRC_DIR ${${product}_PATH_TO_CLANG_SOURCE}
94
- ABSOLUTE )
95
- endif ()
96
-
97
- if (EXISTS "${${product} _PATH_TO_CLANG_BUILD}/include/clang/Basic/Version.inc" )
98
- set (CLANG_BUILD_INCLUDE_DIR "${${product} _PATH_TO_CLANG_BUILD}/include" )
99
- elseif (EXISTS "${${product} _PATH_TO_CLANG_BUILD}/tools/clang/include/clang/Basic/Version.inc" )
100
- set (CLANG_BUILD_INCLUDE_DIR "${${product} _PATH_TO_CLANG_BUILD}/tools/clang/include" )
101
- else ()
102
- message (FATAL_ERROR "Please set ${product} _PATH_TO_CLANG_BUILD to a directory containing a Clang build." )
103
- endif ()
104
- if (CLANG_MAIN_INCLUDE_DIR )
105
- get_filename_component (CLANG_MAIN_SRC_DIR ${${product}_PATH_TO_CLANG_SOURCE}
106
- ABSOLUTE )
107
- endif ()
108
-
109
62
if (${is_cross_compiling} )
110
63
find_program (SWIFT_TABLEGEN_EXE "llvm-tblgen" "${${product} _NATIVE_LLVM_TOOLS_PATH}"
111
64
NO_DEFAULT_PATH )
@@ -115,7 +68,6 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
115
68
else ()
116
69
set (SWIFT_TABLEGEN_EXE llvm-tblgen )
117
70
set (${product} _NATIVE_LLVM_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR} " )
118
- set (${product} _NATIVE_CLANG_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR} " )
119
71
endif ()
120
72
121
73
include (AddLLVM )
@@ -132,17 +84,9 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
132
84
"${PACKAGE_VERSION_MAJOR} .${PACKAGE_VERSION_MINOR} " CACHE STRING
133
85
"Version number that will be placed into the libclang library , in the form XX.YY" )
134
86
135
- set (CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR} /include" )
136
- set (CMARK_MAIN_INCLUDE_DIR "${CMARK_MAIN_SRC_DIR} /src" )
137
- set (CMARK_BUILD_INCLUDE_DIR "${PATH_TO_CMARK_BUILD} /src" )
138
-
139
87
set (CMAKE_INCLUDE_CURRENT_DIR ON )
140
88
include_directories ("${PATH_TO_LLVM_BUILD} /include"
141
- "${LLVM_MAIN_INCLUDE_DIR} "
142
- "${CLANG_BUILD_INCLUDE_DIR} "
143
- "${CLANG_MAIN_INCLUDE_DIR} "
144
- "${CMARK_MAIN_INCLUDE_DIR} "
145
- "${CMARK_BUILD_INCLUDE_DIR} " )
89
+ "${LLVM_MAIN_INCLUDE_DIR} " )
146
90
foreach (INCLUDE_DIR ${LLVM_INCLUDE_DIRS} )
147
91
include_directories (${INCLUDE_DIR} )
148
92
endforeach ()
@@ -170,6 +114,76 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
170
114
endif ()
171
115
endmacro ()
172
116
117
+ macro (swift_common_standalone_build_config_clang product is_cross_compiling )
118
+ # Clang
119
+ set (${product} _PATH_TO_CLANG_SOURCE "${PATH_TO_LLVM_SOURCE} /tools/clang"
120
+ CACHE PATH "Path to Clang source code." )
121
+ set (${product} _PATH_TO_CLANG_BUILD "${PATH_TO_LLVM_BUILD} " CACHE PATH
122
+ "Path to the directory where Clang was built or installed." )
123
+
124
+ if (NOT EXISTS "${${product} _PATH_TO_CLANG_SOURCE}/include/clang/AST/Decl.h" )
125
+ message (FATAL_ERROR "Please set ${product} _PATH_TO_CLANG_SOURCE to the root directory of Clang's source code." )
126
+ else ()
127
+ get_filename_component (CLANG_MAIN_SRC_DIR ${${product}_PATH_TO_CLANG_SOURCE}
128
+ ABSOLUTE )
129
+ endif ()
130
+
131
+ if (EXISTS "${${product} _PATH_TO_CLANG_BUILD}/include/clang/Basic/Version.inc" )
132
+ set (CLANG_BUILD_INCLUDE_DIR "${${product} _PATH_TO_CLANG_BUILD}/include" )
133
+ elseif (EXISTS "${${product} _PATH_TO_CLANG_BUILD}/tools/clang/include/clang/Basic/Version.inc" )
134
+ set (CLANG_BUILD_INCLUDE_DIR "${${product} _PATH_TO_CLANG_BUILD}/tools/clang/include" )
135
+ else ()
136
+ message (FATAL_ERROR "Please set ${product} _PATH_TO_CLANG_BUILD to a directory containing a Clang build." )
137
+ endif ()
138
+ if (CLANG_MAIN_INCLUDE_DIR )
139
+ get_filename_component (CLANG_MAIN_SRC_DIR ${${product}_PATH_TO_CLANG_SOURCE}
140
+ ABSOLUTE )
141
+ endif ()
142
+
143
+ if (NOT ${is_cross_compiling} )
144
+ set (${product} _NATIVE_CLANG_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR} " )
145
+ endif ()
146
+
147
+ set (CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR} /include" )
148
+
149
+ include_directories ("${CLANG_BUILD_INCLUDE_DIR} "
150
+ "${CLANG_MAIN_INCLUDE_DIR} " )
151
+ endmacro ()
152
+
153
+ macro (swift_common_standalone_build_config_cmark product )
154
+ set (${product} _PATH_TO_CMARK_SOURCE "${${product} _PATH_TO_CMARK_SOURCE}"
155
+ CACHE PATH "Path to CMark source code." )
156
+ set (${product} _PATH_TO_CMARK_BUILD "${${product} _PATH_TO_CMARK_BUILD}"
157
+ CACHE PATH "Path to the directory where CMark was built." )
158
+ set (${product} _CMARK_LIBRARY_DIR "${${product} _CMARK_LIBRARY_DIR}" CACHE PATH
159
+ "Path to the directory where CMark was installed." )
160
+ get_filename_component (PATH_TO_CMARK_BUILD "${${product} _PATH_TO_CMARK_BUILD}"
161
+ ABSOLUTE )
162
+ get_filename_component (CMARK_MAIN_SRC_DIR "${${product} _PATH_TO_CMARK_SOURCE}"
163
+ ABSOLUTE )
164
+ get_filename_component (CMARK_LIBRARY_DIR "${${product} _CMARK_LIBRARY_DIR}"
165
+ ABSOLUTE )
166
+ set (CMARK_MAIN_INCLUDE_DIR "${CMARK_MAIN_SRC_DIR} /src" )
167
+ set (CMARK_BUILD_INCLUDE_DIR "${PATH_TO_CMARK_BUILD} /src" )
168
+ include_directories ("${CMARK_MAIN_INCLUDE_DIR} "
169
+ "${CMARK_BUILD_INCLUDE_DIR} " )
170
+ endmacro ()
171
+
172
+ # Common cmake project config for standalone builds.
173
+ #
174
+ # Parameters:
175
+ # product
176
+ # The product name, e.g. Swift or SourceKit. Used as prefix for some
177
+ # cmake variables.
178
+ #
179
+ # is_cross_compiling
180
+ # Whether this is cross-compiling host tools.
181
+ macro (swift_common_standalone_build_config product is_cross_compiling )
182
+ swift_common_standalone_build_config_llvm (${product} ${is_cross_compiling} )
183
+ swift_common_standalone_build_config_clang (${product} ${is_cross_compiling} )
184
+ swift_common_standalone_build_config_cmark (${product} )
185
+ endmacro ()
186
+
173
187
# Common cmake project config for unified builds.
174
188
#
175
189
# Parameters:
0 commit comments