Skip to content

Commit 1703544

Browse files
committed
Enable whole-module-optimization in release builds
1 parent 8bf4cb0 commit 1703544

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
112112
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xcc -D_WASI_EMULATED_MMAN>")
113113
endif()
114114

115+
# Enable whole module optimization for release builds & incremental for debug builds
116+
if(POLICY CMP0157)
117+
set(CMAKE_Swift_COMPILATION_MODE "$<IF:$<CONFIG:Release>,wholemodule,incremental>")
118+
else()
119+
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Swift>,$<IF:$<CONFIG:Release>>>:-wmo>)
120+
endif()
121+
115122
include(GNUInstallDirs)
116123
include(SwiftFoundationSwiftSupport)
117124

0 commit comments

Comments
 (0)