@@ -1320,6 +1320,10 @@ function Build-CMakeProject {
13201320 Add-KeyValueIfNew $Defines CMAKE_SYSTEM_PROCESSOR $Platform.Architecture.CMakeName
13211321 }
13221322
1323+ # Always prefer the CONFIG format for the packages so that we can build
1324+ # against the build tree.
1325+ Add-KeyValueIfNew $Defines CMAKE_FIND_PACKAGE_PREFER_CONFIG YES
1326+
13231327 switch ($Platform.OS ) {
13241328 Windows {
13251329 if ($UseASM ) {
@@ -1913,7 +1917,6 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
19131917 return $TestDefines + $DebugDefines + @ {
19141918 CLANG_TABLEGEN = (Join-Path - Path $BuildTools - ChildPath " clang-tblgen.exe" );
19151919 CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path - Path $BuildTools - ChildPath " clang-tidy-confusable-chars-gen.exe" );
1916- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
19171920 CMAKE_Swift_FLAGS = $SwiftFlags ;
19181921 LibXml2_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\cmake\libxml2-2.11.5" ;
19191922 LLDB_LIBXML2_VERSION = " 2.11.5" ;
@@ -2121,7 +2124,6 @@ function Build-LLVM([Hashtable] $Platform) {
21212124 - Platform $Platform `
21222125 - UseBuiltCompilers C, CXX `
21232126 - Defines @ {
2124- CMAKE_SYSTEM_NAME = $Platform.OS.ToString ();
21252127 LLVM_HOST_TRIPLE = $Platform.Triple ;
21262128 }
21272129}
@@ -2144,7 +2146,6 @@ function Build-Sanitizers([Hashtable] $Platform) {
21442146 - UseBuiltCompilers ASM, C, CXX `
21452147 - BuildTargets " install-compiler-rt" `
21462148 - Defines (@ {
2147- CMAKE_SYSTEM_NAME = $Platform.OS.ToString ();
21482149 LLVM_DIR = " $LLVMTargetCache \lib\cmake\llvm" ;
21492150 LLVM_ENABLE_PER_TARGET_RUNTIME_DIR = " YES" ;
21502151 COMPILER_RT_DEFAULT_TARGET_ONLY = " YES" ;
@@ -2157,8 +2158,7 @@ function Build-Sanitizers([Hashtable] $Platform) {
21572158 - Platform $Platform `
21582159 - UseBuiltCompilers ASM, C, CXX `
21592160 - BuildTargets " install-compiler-rt" `
2160- - Defines (@ {
2161- CMAKE_SYSTEM_NAME = $Platform.OS.ToString ();
2161+ - Defines @ {
21622162 LLVM_DIR = " $LLVMTargetCache \lib\cmake\llvm" ;
21632163 LLVM_ENABLE_PER_TARGET_RUNTIME_DIR = " YES" ;
21642164 COMPILER_RT_DEFAULT_TARGET_ONLY = " YES" ;
@@ -2169,7 +2169,7 @@ function Build-Sanitizers([Hashtable] $Platform) {
21692169 COMPILER_RT_BUILD_XRAY = " NO" ;
21702170 COMPILER_RT_BUILD_PROFILE = " YES" ;
21712171 COMPILER_RT_BUILD_SANITIZERS = " YES" ;
2172- })
2172+ }
21732173}
21742174
21752175function Build-ZLib ([Hashtable ] $Platform ) {
@@ -2182,7 +2182,6 @@ function Build-ZLib([Hashtable] $Platform) {
21822182 - Defines @ {
21832183 BUILD_SHARED_LIBS = " NO" ;
21842184 CMAKE_POSITION_INDEPENDENT_CODE = " YES" ;
2185- CMAKE_SYSTEM_NAME = $Platform.OS.ToString ();
21862185 }
21872186}
21882187
@@ -2196,7 +2195,6 @@ function Build-XML2([Hashtable] $Platform) {
21962195 - Defines @ {
21972196 BUILD_SHARED_LIBS = " NO" ;
21982197 CMAKE_POSITION_INDEPENDENT_CODE = " YES" ;
2199- CMAKE_SYSTEM_NAME = $Platform.OS.ToString ();
22002198 LIBXML2_WITH_ICONV = " NO" ;
22012199 LIBXML2_WITH_ICU = " NO" ;
22022200 LIBXML2_WITH_LZMA = " NO" ;
@@ -2227,7 +2225,6 @@ function Build-DS2([Hashtable] $Platform) {
22272225 - InstallTo " $ ( Get-PlatformRoot $Platform.OS ) \Developer\Library\ds2\usr" `
22282226 - Platform $Platform `
22292227 - Defines @ {
2230- CMAKE_SYSTEM_NAME = $Platform.OS.ToString ();
22312228 DS2_REGSGEN2 = " $ ( Get-ProjectBinaryCache $BuildPlatform RegsGen2) /regsgen2.exe" ;
22322229 DS2_PROGRAM_PREFIX = " $ ( Get-ModuleTriple $Platform ) -" ;
22332230 BISON_EXECUTABLE = " $ ( Get-BisonExecutable ) " ;
@@ -2253,7 +2250,6 @@ function Build-CURL([Hashtable] $Platform) {
22532250 BUILD_SHARED_LIBS = " NO" ;
22542251 BUILD_TESTING = " NO" ;
22552252 CMAKE_POSITION_INDEPENDENT_CODE = " YES" ;
2256- CMAKE_SYSTEM_NAME = $Platform.OS.ToString ();
22572253 BUILD_CURL_EXE = " NO" ;
22582254 BUILD_LIBCURL_DOCS = " NO" ;
22592255 BUILD_MISC_DOCS = " NO" ;
@@ -2365,8 +2361,6 @@ function Build-Runtime([Hashtable] $Platform) {
23652361 - SwiftSDK $null `
23662362 - CacheScript $SourceCache \swift\cmake\caches\Runtime- $ ($Platform.OS.ToString ())- $ ($Platform.Architecture.LLVMName ).cmake `
23672363 - Defines ($PlatformDefines + @ {
2368- CMAKE_Swift_COMPILER_WORKS = " YES" ;
2369- CMAKE_SYSTEM_NAME = $Platform.OS.ToString ();
23702364 LLVM_DIR = " $ ( Get-ProjectBinaryCache $Platform LLVM) \lib\cmake\llvm" ;
23712365 SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = " YES" ;
23722366 SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = " YES" ;
@@ -2484,7 +2478,6 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
24842478 - UseGNUDriver `
24852479 - Defines @ {
24862480 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
2487- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
24882481 # TODO(compnerd) enforce dynamic linking of BlocksRuntime and dispatch.
24892482 CMAKE_CXX_FLAGS = $ (if ($Static ) { @ (" -Ddispatch_STATIC" ) } else { @ () });
24902483 CMAKE_Swift_FLAGS = $ (if ($Static ) { @ (" -Xcc" , " -static-libclosure" ) } else { @ () });
@@ -2509,7 +2502,6 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25092502 - UseGNUDriver `
25102503 - Defines @ {
25112504 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
2512- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
25132505 CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
25142506
25152507 SwiftCore_DIR = " ${RuntimeBinaryCache} \cmake\SwiftCore" ;
@@ -2525,7 +2517,6 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25252517 - UseGNUDriver `
25262518 - Defines @ {
25272519 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
2528- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
25292520 CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
25302521
25312522 SwiftCore_DIR = " ${RuntimeBinaryCache} \cmake\SwiftCore" ;
@@ -2541,7 +2532,6 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25412532 - UseGNUDriver `
25422533 - Defines @ {
25432534 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
2544- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
25452535 CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
25462536
25472537 SwiftCore_DIR = " ${RuntimeBinaryCache} \cmake\SwiftCore" ;
@@ -2558,7 +2548,6 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25582548 - UseGNUDriver `
25592549 - Defines @ {
25602550 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
2561- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
25622551 # FIXME(#83449): avoid using `SwiftCMakeConfig.h`
25632552 CMAKE_CXX_FLAGS = @ (" -I${RuntimeBinaryCache} \include" );
25642553 CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
@@ -2577,7 +2566,6 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25772566 - UseGNUDriver `
25782567 - Defines @ {
25792568 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
2580- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
25812569 # FIXME(#83449): avoid using `SwiftCMakeConfig.h`
25822570 CMAKE_CXX_FLAGS = @ (" -I${RuntimeBinaryCache} \include" );
25832571 CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
@@ -2596,7 +2584,6 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25962584 - UseGNUDriver `
25972585 - Defines @ {
25982586 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
2599- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
26002587 CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
26012588
26022589 SwiftCore_DIR = " ${RuntimeBinaryCache} \cmake\SwiftCore" ;
@@ -2723,7 +2710,6 @@ function Build-Foundation {
27232710 - SwiftSDK $SwiftSDK `
27242711 - Defines @ {
27252712 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
2726- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
27272713 CMAKE_NINJA_FORCE_RESPONSE_FILE = " YES" ;
27282714 CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
27292715 CMAKE_Swift_FLAGS = $SwiftFlags ;
@@ -2942,7 +2928,6 @@ function Build-ExperimentalSDK([Hashtable] $Platform) {
29422928 - SwiftSDK (Get-SwiftSDK $Platform.OS - Identifier " $ ( $Platform.OS ) Experimental" ) `
29432929 - Defines @ {
29442930 BUILD_SHARED_LIBS = " NO" ;
2945- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
29462931 CMAKE_Swift_FLAGS = @ (" -static-stdlib" , " -Xfrontend" , " -use-static-resource-dir" );
29472932 CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
29482933
@@ -3014,7 +2999,6 @@ function Build-ToolsSupportCore([Hashtable] $Platform) {
30142999 - SwiftSDK (Get-SwiftSDK $Platform.OS ) `
30153000 - Defines @ {
30163001 BUILD_SHARED_LIBS = " YES" ;
3017- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
30183002 CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
30193003
30203004 Foundation_DIR = $ (Get-ProjectCMakeModules $Platform DynamicFoundation);
0 commit comments