@@ -1290,14 +1290,34 @@ endfunction()
1290
1290
1291
1291
function (add_llvm_tool_symlink link_name target )
1292
1292
cmake_parse_arguments (ARG "ALWAYS_GENERATE" "OUTPUT_DIR" "" ${ARGN} )
1293
+ # This got a bit gross... For multi-configuration generators the target
1294
+ # properties return the resolved value of the string, not the build system
1295
+ # expression. To reconstruct the platform-agnostic path we have to do some
1296
+ # magic. First we grab one of the types, and a type-specific path. Then from
1297
+ # the type-specific path we find the last occurrence of the type in the path,
1298
+ # and replace it with CMAKE_CFG_INTDIR. This allows the build step to be type
1299
+ # agnostic again.
1293
1300
if (NOT ARG_OUTPUT_DIR )
1301
+ if (CMAKE_CONFIGURATION_TYPES )
1302
+ list (GET CMAKE_CONFIGURATION_TYPES 0 first_type )
1303
+ string (TOUPPER ${first_type} first_type_upper )
1304
+ set (first_type_suffix _${first_type_upper} )
1305
+ endif ()
1294
1306
get_target_property (target_type ${target} TYPE )
1295
1307
if (${target_type} STREQUAL "STATIC_LIBRARY" )
1296
- get_target_property (ARG_OUTPUT_DIR ${target} ARCHIVE_OUTPUT_DIRECTORY )
1308
+ get_target_property (ARG_OUTPUT_DIR ${target} ARCHIVE_OUTPUT_DIRECTORY ${first_type_suffix} )
1297
1309
elseif (UNIX AND ${target_type} STREQUAL "SHARED_LIBRARY" )
1298
- get_target_property (ARG_OUTPUT_DIR ${target} LIBRARY_OUTPUT_DIRECTORY )
1310
+ get_target_property (ARG_OUTPUT_DIR ${target} LIBRARY_OUTPUT_DIRECTORY ${first_type_suffix} )
1299
1311
else ()
1300
- get_target_property (ARG_OUTPUT_DIR ${target} RUNTIME_OUTPUT_DIRECTORY )
1312
+ get_target_property (ARG_OUTPUT_DIR ${target} RUNTIME_OUTPUT_DIRECTORY ${first_type_suffix} )
1313
+ endif ()
1314
+ if (CMAKE_CONFIGURATION_TYPES )
1315
+ string (FIND "${ARG_OUTPUT_DIR} " "/${first_type} /" type_start REVERSE )
1316
+ string (SUBSTRING "${ARG_OUTPUT_DIR} " 0 ${type_start} path_prefix )
1317
+ string (SUBSTRING "${ARG_OUTPUT_DIR} " ${type_start} -1 path_suffix )
1318
+ string (REPLACE "/${first_type} /" "/${CMAKE_CFG_INTDIR} /"
1319
+ path_suffix ${path_suffix} )
1320
+ set (ARG_OUTPUT_DIR ${path_prefix}${path_suffix} )
1301
1321
endif ()
1302
1322
endif ()
1303
1323
0 commit comments