@@ -40,6 +40,15 @@ function(escape_llvm_path_for_xcode path outvar)
40
40
set (${outvar} "${path} " PARENT_SCOPE )
41
41
endfunction ()
42
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
+
43
52
# What this function does is go through each of the passed in imported targets
44
53
# from LLVM/Clang and changes them to use the appropriate fully expanded paths.
45
54
#
@@ -52,14 +61,29 @@ function(fix_imported_target_locations_for_xcode targets)
52
61
53
62
get_target_property (TARGET_TYPE ${t} TYPE )
54
63
55
- # We only want to do this for static libraries for now.
56
- if (NOT ${TARGET_TYPE} STREQUAL "STATIC_LIBRARY" )
64
+ if (NOT "${TARGET_TYPE} " STREQUAL "STATIC_LIBRARY" AND
65
+ NOT "${TARGET_TYPE} " STREQUAL "SHARED_LIBRARY" AND
66
+ NOT "${TARGET_TYPE} " STREQUAL "EXECUTABLE" )
67
+ message (FATAL_ERROR "Unsupported imported target type ${TARGET_TYPE} " )
68
+ endif ()
69
+
70
+ # Ok, so at this point, we know that we have an executable, static library,
71
+ # or shared library.
72
+ #
73
+ # First we handle the executables.
74
+ if ("${TARGET_TYPE} " STREQUAL "EXECUTABLE" )
75
+ set_target_properties (${t} PROPERTIES
76
+ IMPORTED_LOCATION_DEBUG "${LLVM_BINARY_OUTPUT_INTDIR} /${t} "
77
+ IMPORTED_LOCATION_RELEASE "${LLVM_BINARY_OUTPUT_INTDIR} /${t} " )
57
78
continue ()
58
79
endif ()
59
80
81
+ # Otherwise, we have libraries. Since libclang has an extra lib prefix in
82
+ # its target name, we have to handle it specially.
83
+ get_imported_library_prefix (PREFIX "${t} " "${CMAKE_${TARGET_TYPE} _PREFIX}" )
60
84
set_target_properties (${t} PROPERTIES
61
- IMPORTED_LOCATION_DEBUG "${LLVM_LIBRARY_OUTPUT_INTDIR} /lib ${ t} .a "
62
- IMPORTED_LOCATION_RELEASE "${LLVM_LIBRARY_OUTPUT_INTDIR} /lib ${ t} .a " )
85
+ IMPORTED_LOCATION_DEBUG "${LLVM_LIBRARY_OUTPUT_INTDIR} /${PREFIX}${ t} .${CMAKE_ ${TARGET_TYPE} _SUFFIX} "
86
+ IMPORTED_LOCATION_RELEASE "${LLVM_LIBRARY_OUTPUT_INTDIR} /${PREFIX}${ t} .${CMAKE_ ${TARGET_TYPE} _SUFFIX} " )
63
87
endforeach ()
64
88
endfunction ()
65
89
@@ -119,6 +143,7 @@ macro(swift_common_standalone_build_config_llvm product is_cross_compiling)
119
143
# against a matching LLVM build configuration. However, we usually want to be
120
144
# flexible and allow linking a debug Swift against optimized LLVM.
121
145
set (LLVM_RUNTIME_OUTPUT_INTDIR "${LLVM_BINARY_DIR} " )
146
+ set (LLVM_BINARY_OUTPUT_INTDIR "${LLVM_TOOLS_BINARY_DIR} " )
122
147
set (LLVM_LIBRARY_OUTPUT_INTDIR "${LLVM_LIBRARY_DIR} " )
123
148
124
149
if (XCODE )
0 commit comments