Browse Source

Meta: Make the "Release" build type use -O3 and -flto

This doesn't affect the default preset, but the Distribution preset will
now compile with these flags instead.
Jelle Raaijmakers 2 weeks ago
parent
commit
3bc6870bbf

+ 1 - 5
CMakePresets.json

@@ -153,10 +153,7 @@
         "vcpkg_ci",
         "Sanitizer"
       ],
-      "displayName": "Sanitizer CI Config",
-      "cacheVariables": {
-        "CMAKE_BUILD_TYPE": ""
-      }
+      "displayName": "Sanitizer CI Config"
     },
     {
       "name": "Fuzzers",
@@ -166,7 +163,6 @@
       "binaryDir": "${fileDir}/Build/fuzzers",
       "cacheVariables": {
         "BUILD_SHARED_LIBS": "OFF",
-        "CMAKE_BUILD_TYPE": "",
         "ENABLE_QT": "OFF",
         "VCPKG_OVERLAY_TRIPLETS": "${fileDir}/Meta/CMake/vcpkg/distribution-triplets",
         "ENABLE_FUZZERS_LIBFUZZER": "ON",

+ 1 - 1
Documentation/AdvancedBuildInstructions.md

@@ -123,7 +123,7 @@ If you do run into such an error, the rest of this section explains how to deal
            endif()
       -    add_cxx_compile_options(-Og)
       +    add_cxx_compile_options(-O0)
-       else()
+       elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
            add_cxx_compile_options(-O2)
            if (NOT MSVC)
       EOF

+ 7 - 1
Meta/CMake/lagom_compile_options.cmake

@@ -30,11 +30,17 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
         add_cxx_compile_options(-ggdb3)
     endif()
     add_cxx_compile_options(-Og)
-else()
+elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
     add_cxx_compile_options(-O2)
     if (NOT MSVC)
         add_cxx_compile_options(-g1)
     endif()
+else()
+    add_cxx_compile_options(-O3)
+
+    include(CheckIPOSupported)
+    check_ipo_supported()
+    set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
 endif()
 
 function(add_cxx_linker_flag_if_supported flag)