Skip to content

Commit 9cf6c41

Browse files
compnerdmeg-gupta
authored andcommitted
build: only apply linker flags for C/C++
When building C/C++ code we need to add `/debug` to the flags. However, if we are building Swift code, this becomes a problem as the flag is passed to the Swift compiler directly. Only pass the flag when C/C++ code is being built.
1 parent c2f9c41 commit 9cf6c41

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

utils/build.ps1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,16 +580,19 @@ function Build-CMakeProject {
580580

581581
# Add additional defines (unless already present)
582582
$Defines = $Defines.Clone()
583-
583+
584584
TryAdd-KeyValue $Defines CMAKE_BUILD_TYPE Release
585585
TryAdd-KeyValue $Defines CMAKE_MT "mt"
586586

587587
$CFlags = @("/GS-", "/Gw", "/Gy", "/Oi", "/Oy", "/Zc:inline")
588-
if ($DebugInfo) {
589-
$CFlags += if ($EnableCaching) { "/Z7" } else { "/Zi" }
590-
# Add additional linker flags for generating the debug info.
591-
Append-FlagsDefine $Defines CMAKE_SHARED_LINKER_FLAGS "/debug"
592-
Append-FlagsDefine $Defines CMAKE_EXE_LINKER_FLAGS "/debug"
588+
if ($UseMSVCCompilers.Contains("C") -Or $UseMSVCCompilers.Contains("CXX") -Or
589+
$UsePinnedCompilers.Contains("C") -Or $UsePinnedCompilers.Contains("CXX")) {
590+
if ($DebugInfo) {
591+
$CFlags += if ($EnableCaching) { "/Z7" } else { "/Zi" }
592+
# Add additional linker flags for generating the debug info.
593+
Append-FlagsDefine $Defines CMAKE_SHARED_LINKER_FLAGS "/debug"
594+
Append-FlagsDefine $Defines CMAKE_EXE_LINKER_FLAGS "/debug"
595+
}
593596
}
594597
$CXXFlags = $CFlags.Clone() + "/Zc:__cplusplus"
595598

0 commit comments

Comments
 (0)