Skip to content

Commit d7953ff

Browse files
compnerdnatecook1000
authored andcommitted
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 41982a3 commit d7953ff

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
@@ -52,8 +52,11 @@ set_target_properties(ArgumentParser PROPERTIES
5252
target_compile_options(ArgumentParser PRIVATE
5353
$<$<BOOL:${BUILD_TESTING}>:-enable-testing>)
5454
target_link_libraries(ArgumentParser PRIVATE
55-
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
5655
ArgumentParserToolInfo)
56+
if(Foundation_FOUND)
57+
target_link_libraries(ArgumentParser PRIVATE
58+
Foundation)
59+
endif()
5760

5861

5962
_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)