@@ -698,7 +698,7 @@ function(_add_swift_lipo_target)
698
698
DEPENDS ${source_targets} )
699
699
endif ()
700
700
endfunction ()
701
-
701
+
702
702
# Add a single variant of a new Swift library.
703
703
#
704
704
# Usage:
@@ -1317,38 +1317,45 @@ function(add_swift_target_library_single target name)
1317
1317
# Set compile and link flags for the non-static target.
1318
1318
# Do these LAST.
1319
1319
set (target_static )
1320
- if (SWIFTLIB_SINGLE_IS_STDLIB AND SWIFTLIB_SINGLE_STATIC AND NOT SWIFTLIB_SINGLE_INSTALL_WITH_SHARED )
1320
+ if (SWIFTLIB_SINGLE_IS_STDLIB AND SWIFTLIB_SINGLE_STATIC )
1321
1321
set (target_static "${target} -static" )
1322
1322
1323
- # We have already compiled Swift sources. Link everything into a static
1324
- # library.
1325
- add_library (${target_static} STATIC
1323
+ if (SWIFTLIB_SINGLE_INSTALL_WITH_SHARED )
1324
+ # Create an interface library for the static version, and explicitly
1325
+ # add the output path for the non-static version to its libraries.
1326
+ add_library (${target_static} INTERFACE )
1327
+ target_link_libraries (${target_static} INTERFACE $< TARGET_FILE:${target} > )
1328
+ else ()
1329
+ # We have already compiled Swift sources. Link everything into a static
1330
+ # library.
1331
+ add_library (${target_static} STATIC
1326
1332
${SWIFTLIB_SINGLE_SOURCES}
1327
1333
${SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS}
1328
1334
${SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES} )
1329
1335
1330
- set_output_directory (${target_static}
1336
+ set_output_directory (${target_static}
1331
1337
BINARY_DIR ${out_bin_dir}
1332
1338
LIBRARY_DIR ${out_lib_dir} )
1333
1339
1334
- if (SWIFTLIB_INSTALL_WITH_SHARED )
1335
- set (swift_lib_dir ${lib_dir} )
1336
- else ()
1337
- set (swift_lib_dir ${static_lib_dir} )
1338
- endif ()
1340
+ if (SWIFTLIB_INSTALL_WITH_SHARED )
1341
+ set (swift_lib_dir ${lib_dir} )
1342
+ else ()
1343
+ set (swift_lib_dir ${static_lib_dir} )
1344
+ endif ()
1339
1345
1340
- foreach (config ${CMAKE_CONFIGURATION_TYPES} )
1341
- string (TOUPPER ${config} config_upper )
1342
- escape_path_for_xcode (
1346
+ foreach (config ${CMAKE_CONFIGURATION_TYPES} )
1347
+ string (TOUPPER ${config} config_upper )
1348
+ escape_path_for_xcode (
1343
1349
"${config} " "${swift_lib_dir} " config_lib_dir )
1344
- set_target_properties (${target_static} PROPERTIES
1345
- LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir} /${output_sub_dir}
1346
- ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir} /${output_sub_dir} )
1347
- endforeach ()
1350
+ set_target_properties (${target_static} PROPERTIES
1351
+ LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir} /${output_sub_dir}
1352
+ ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir} /${output_sub_dir} )
1353
+ endforeach ()
1348
1354
1349
- set_target_properties (${target_static} PROPERTIES
1350
- LIBRARY_OUTPUT_DIRECTORY ${swift_lib_dir} /${output_sub_dir}
1351
- ARCHIVE_OUTPUT_DIRECTORY ${swift_lib_dir} /${output_sub_dir} )
1355
+ set_target_properties (${target_static} PROPERTIES
1356
+ LIBRARY_OUTPUT_DIRECTORY ${swift_lib_dir} /${output_sub_dir}
1357
+ ARCHIVE_OUTPUT_DIRECTORY ${swift_lib_dir} /${output_sub_dir} )
1358
+ endif ()
1352
1359
endif ()
1353
1360
1354
1361
set_target_properties (${target}
@@ -1644,9 +1651,10 @@ function(add_swift_target_library_single target name)
1644
1651
LINKER_LANGUAGE "CXX" )
1645
1652
endif ()
1646
1653
1647
- if (target_static )
1654
+ if (target_static AND NOT SWIFTLIB_SINGLE_INSTALL_WITH_SHARED )
1648
1655
target_compile_options (${target_static} PRIVATE
1649
1656
${c_compile_flags} )
1657
+
1650
1658
# FIXME: The fallback paths here are going to be dynamic libraries.
1651
1659
1652
1660
if (SWIFTLIB_INSTALL_WITH_SHARED )
0 commit comments