Skip to content

Commit 02526df

Browse files
authored
build: conditionaly add Foundation dependency edge (#783)
When building without `-DFoundation_DIR=...`, we should not wire up a dependency on Foundation and instead rely on autolinking and the driver to collude to resolve the linkage. Failure to do so will instill a rogue `-lFoundation.lib` when linking on Windows.
1 parent d8a9695 commit 02526df

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Sources/ArgumentParser/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ set_target_properties(ArgumentParser PROPERTIES
5959
target_compile_options(ArgumentParser PRIVATE
6060
$<$<BOOL:${BUILD_TESTING}>:-enable-testing>)
6161
target_link_libraries(ArgumentParser PRIVATE
62-
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
6362
ArgumentParserToolInfo)
63+
if(Foundation_FOUND)
64+
target_link_libraries(ArgumentParser PRIVATE
65+
Foundation)
66+
endif()
6467

6568

6669
_install_target(ArgumentParser)

Sources/ArgumentParserTestHelpers/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ set_target_properties(ArgumentParserTestHelpers PROPERTIES
55
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
66
target_link_libraries(ArgumentParserTestHelpers PUBLIC
77
ArgumentParser
8-
ArgumentParserToolInfo
9-
XCTest
10-
Foundation)
8+
ArgumentParserToolInfo)
9+
if(Foundation_FOUND)
10+
target_link_libraries(ArgumentParserTestHelpers PUBLIC
11+
Foundation)
12+
endif()
13+
if(XCTest_Found)
14+
target_link_libraries(ArgumentParserTestHelpers PUBLIC
15+
XCTest)
16+
endif()

0 commit comments

Comments
 (0)