Skip to content

Commit 810f5b5

Browse files
committed
[cmake] Make SwiftCompilerSources support debug info in RelWithDebInfoMode and use -Os instead of -O with MinSizeRel.
1 parent 80f052e commit 810f5b5

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9+
include(SwiftUtils)
10+
911
# Following function are needed as a workaround until it's possible to compile
1012
# swift code with cmake's builtin swift support.
1113

@@ -121,10 +123,19 @@ function(add_swift_compiler_modules_library name)
121123
list(APPEND swift_compile_options "-Xfrontend" "-cxx-interop-use-opaque-pointer-for-moveonly")
122124
endif()
123125

124-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
126+
is_build_type_with_debuginfo("${CMAKE_BUILD_TYPE}" debug)
127+
if (debug)
125128
list(APPEND swift_compile_options "-g")
126-
else()
127-
list(APPEND swift_compile_options "-O" "-cross-module-optimization")
129+
endif()
130+
131+
is_build_type_optimized("${CMAKE_BUILD_TYPE}" optimized)
132+
if (optimized)
133+
if("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
134+
list(APPEND swift_compile_options "-Osize")
135+
else()
136+
list(APPEND swift_compile_options "-O")
137+
endif()
138+
list(APPEND swift_compile_options "-cross-module-optimization")
128139
endif()
129140

130141
if(LLVM_ENABLE_ASSERTIONS)

0 commit comments

Comments
 (0)