Skip to content

Commit 1b79d86

Browse files
authored
Enable WMO (#832) (#841)
1 parent 92b84e4 commit 1b79d86

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ if(NOT SWIFT_SYSTEM_NAME)
3535
endif()
3636
endif()
3737

38+
# Don't enable WMO on Windows due to linker failures
39+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
40+
# Enable whole module optimization for release builds & incremental for debug builds
41+
if(POLICY CMP0157)
42+
set(CMAKE_Swift_COMPILATION_MODE "$<IF:$<CONFIG:Release>,wholemodule,incremental>")
43+
else()
44+
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Swift>,$<CONFIG:Release>>:-wmo>)
45+
endif()
46+
endif()
47+
3848
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
3949
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
4050
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

0 commit comments

Comments
 (0)