@@ -12,120 +12,7 @@ else()
12
12
set (cmake_3_2_USES_TERMINAL USES_TERMINAL )
13
13
endif ()
14
14
15
- function (get_effective_platform_for_triple triple output )
16
- string (FIND "${triple} " "macos" IS_MACOS )
17
- if (IS_MACOS )
18
- set (${output} "" PARENT_SCOPE )
19
- return ()
20
- endif ()
21
- message (FATAL_ERROR "Not supported" )
22
- endfunction ()
23
-
24
- # Eliminate $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) from a path.
25
- #
26
- # We do not support compiling llvm with an Xcode setting beyond the one that was
27
- # used with build-script. This allows us to remove those paths. Right now,
28
- # nothing here is tested for cross compiling with Xcode, but it is in principal
29
- # possible.
30
- function (escape_llvm_path_for_xcode path outvar )
31
- # First check if we are using Xcode. If not, return early.
32
- if (NOT XCODE )
33
- set (${outvar} "${path} " PARENT_SCOPE )
34
- return ()
35
- endif ()
36
-
37
- get_effective_platform_for_triple ("${SWIFT_HOST_TRIPLE} " SWIFT_EFFECTIVE_PLATFORM_NAME )
38
- string (REPLACE "$(CONFIGURATION)" "${LLVM_BUILD_TYPE} " path "${path} " )
39
- string (REPLACE "$(EFFECTIVE_PLATFORM_NAME)" "${SWIFT_EFFECTIVE_PLATFORM_NAME} " path "${path} " )
40
- set (${outvar} "${path} " PARENT_SCOPE )
41
- endfunction ()
42
-
43
- function (get_imported_library_prefix outvar target prefix )
44
- string (FIND "${target} " "${prefix} " ALREADY_HAS_PREFIX )
45
- if (ALREADY_HAS_PREFIX )
46
- set (${outvar} "" PARENT_SCOPE )
47
- else ()
48
- set (${outvar} "${prefix} " PARENT_SCOPE )
49
- endif ()
50
- endfunction ()
51
-
52
- function (check_imported_target_has_imported_configuration target config )
53
- get_target_property (IMPORTED_CONFIGS_LIST ${target} IMPORTED_CONFIGURATIONS )
54
- if ("${IMPORTED_CONFIGS_LIST} " STREQUAL "NOTFOUND" )
55
- message (FATAL_ERROR "No import configuration of ${target} specified?!" )
56
- endif ()
57
-
58
- list (FIND "${IMPORTED_CONFIGS_LIST} " "${config} " FOUND_CONFIG )
59
- if (NOT FOUND_CONFIG )
60
- message (FATAL_ERROR "${target} does not have imported config '${config} '?! \
61
- Instead: ${IMPORTED_CONFIGS_LIST} " )
62
- endif ()
63
- endfunction ()
64
-
65
- function (fixup_imported_target_property_for_xcode target property real_build_type )
66
- set (FULL_PROP_NAME "${property} _${real_build_type} " )
67
-
68
- # First try to lookup the value associated with the "real build type".
69
- get_target_property (PROP_VALUE ${target} ${FULL_PROP_NAME} )
70
-
71
- # If the property is unspecified, return.
72
- if ("${PROP_VALUE} " STREQUAL "NOTFOUND" )
73
- return ()
74
- endif ()
75
-
76
- # Otherwise for each cmake configuration that is not real_build_type, hardcode
77
- # its value to be PROP_VALUE.
78
- foreach (c ${CMAKE_CONFIGURATION_TYPES} )
79
- if ("${c} " STREQUAL "${real_build_type} " )
80
- continue ()
81
- endif ()
82
- set_target_properties (${target} PROPERTIES ${FULL_PROP_NAME} "${PROP_VALUE} " )
83
- endforeach ()
84
- endfunction ()
85
-
86
- # When building with Xcode, we only support compiling against the LLVM
87
- # configuration that was specified by build-script. This becomes a problem since
88
- # if we compile LLVM-Release and Swift-Debug, Swift is going to look in the
89
- # Debug, not the Release folder for LLVM's code and thus will be compiling
90
- # against an unintended set of libraries, if those libraries exist at all.
91
- #
92
- # Luckily, via LLVMConfig.cmake, we know the configuration that LLVM was
93
- # compiled in, so we can grab the imported location for that configuration and
94
- # splat it across the other configurations as well.
95
- function (fix_imported_targets_for_xcode imported_targets )
96
- # This is the set of configuration specific cmake properties that are
97
- # supported for imported targets in cmake 3.4.3. Sadly, beyond hacks, it seems
98
- # that there is no way to dynamically query the list of set properties of a
99
- # target.
100
- #
101
- # *NOTE* In fixup_imported_target_property_for_xcode, we add the _${CONFIG}
102
- # *suffix.
103
- set (imported_target_properties
104
- IMPORTED_IMPLIB
105
- IMPORTED_LINK_DEPENDENT_LIBRARIES
106
- IMPORTED_LINK_INTERFACE_LANGUAGES
107
- IMPORTED_LINK_INTERFACE_LIBRARIES
108
- IMPORTED_LINK_INTERFACE_MULTIPLICITY
109
- IMPORTED_LOCATION
110
- IMPORTED_NO_SONAME
111
- IMPORTED_SONAME )
112
-
113
- foreach (target ${imported_targets} )
114
- if (NOT TARGET ${target} )
115
- message (FATAL_ERROR "${target} is not a target?!" )
116
- endif ()
117
-
118
- # First check that we actually imported the configuration that LLVM said
119
- # that we did. This is just a sanity check.
120
- check_imported_target_has_imported_configuration (${target} ${LLVM_BUILD_TYPE} )
121
-
122
- # Then loop through all of the imported properties and translate.
123
- foreach (property ${imported_properties} )
124
- fixup_imported_target_property_for_xcode (
125
- ${target} ${property} ${LLVM_BUILD_TYPE} )
126
- endforeach ()
127
- endforeach ()
128
- endfunction ()
15
+ include (SwiftXcodeSupport )
129
16
130
17
macro (swift_common_standalone_build_config_llvm product is_cross_compiling )
131
18
option (LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON )
@@ -170,14 +57,14 @@ macro(swift_common_standalone_build_config_llvm product is_cross_compiling)
170
57
mark_as_advanced (LLVM_ENABLE_ASSERTIONS )
171
58
172
59
precondition (LLVM_TOOLS_BINARY_DIR )
173
- escape_llvm_path_for_xcode ( "${LLVM_TOOLS_BINARY_DIR} " LLVM_TOOLS_BINARY_DIR )
60
+ escape_path_for_xcode ( " ${LLVM_BUILD_TYPE} " "${LLVM_TOOLS_BINARY_DIR} " LLVM_TOOLS_BINARY_DIR )
174
61
precondition_translate_flag (LLVM_BUILD_LIBRARY_DIR LLVM_LIBRARY_DIR )
175
- escape_llvm_path_for_xcode ( "${LLVM_LIBRARY_DIR} " LLVM_LIBRARY_DIR )
62
+ escape_path_for_xcode ( " ${LLVM_BUILD_TYPE} " "${LLVM_LIBRARY_DIR} " LLVM_LIBRARY_DIR )
176
63
precondition_translate_flag (LLVM_BUILD_MAIN_INCLUDE_DIR LLVM_MAIN_INCLUDE_DIR )
177
64
precondition_translate_flag (LLVM_BUILD_BINARY_DIR LLVM_BINARY_DIR )
178
65
precondition_translate_flag (LLVM_BUILD_MAIN_SRC_DIR LLVM_MAIN_SRC_DIR )
179
66
precondition (LLVM_LIBRARY_DIRS )
180
- escape_llvm_path_for_xcode ( "${LLVM_LIBRARY_DIRS} " LLVM_LIBRARY_DIRS )
67
+ escape_path_for_xcode ( " ${LLVM_BUILD_TYPE} " "${LLVM_LIBRARY_DIRS} " LLVM_LIBRARY_DIRS )
181
68
182
69
# This could be computed using ${CMAKE_CFG_INTDIR} if we want to link Swift
183
70
# against a matching LLVM build configuration. However, we usually want to be
@@ -215,7 +102,7 @@ macro(swift_common_standalone_build_config_llvm product is_cross_compiling)
215
102
"Version number that will be placed into the libclang library , in the form XX.YY" )
216
103
217
104
foreach (INCLUDE_DIR ${LLVM_INCLUDE_DIRS} )
218
- escape_llvm_path_for_xcode ( "${INCLUDE_DIR} " INCLUDE_DIR )
105
+ escape_path_for_xcode ( " ${LLVM_BUILD_TYPE} " "${INCLUDE_DIR} " INCLUDE_DIR )
219
106
include_directories (${INCLUDE_DIR} )
220
107
endforeach ()
221
108
@@ -371,45 +258,6 @@ macro(swift_common_unified_build_config product)
371
258
endif ()
372
259
endmacro ()
373
260
374
- # Common additional cmake project config for Xcode.
375
- #
376
- macro (swift_common_xcode_cxx_config )
377
- # Force usage of Clang.
378
- set (CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0"
379
- CACHE STRING "Xcode Compiler" )
380
- # Use C++'11.
381
- set (CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11"
382
- CACHE STRING "Xcode C++ Language Standard" )
383
- # Use libc++.
384
- set (CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++"
385
- CACHE STRING "Xcode C++ Standard Library" )
386
- # Enable some warnings not enabled by default. These
387
- # mostly reset clang back to its default settings, since
388
- # Xcode passes -Wno... for many warnings that are not enabled
389
- # by default.
390
- set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE "YES" )
391
- set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE "YES" )
392
- set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE "YES" )
393
- set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE "YES" )
394
- set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE "YES" )
395
- set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION "YES" )
396
- set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS "YES" )
397
- set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS "YES" )
398
- set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_DOCUMENTATION_COMMENTS "YES" )
399
- set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION "YES" )
400
- set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY "YES" )
401
- set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION "YES" )
402
- set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION "YES" )
403
- set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION "YES" )
404
- set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_NON_VIRTUAL_DESTRUCTOR "YES" )
405
-
406
- # Disable RTTI
407
- set (CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_RTTI "NO" )
408
-
409
- # Disable exceptions
410
- set (CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_EXCEPTIONS "NO" )
411
- endmacro ()
412
-
413
261
# Common cmake project config for additional warnings.
414
262
#
415
263
macro (swift_common_cxx_warnings )
0 commit comments