From 13f0874757bb9a7e1b6e79174ebd3fc2559485a2 Mon Sep 17 00:00:00 2001 From: Diomendius <42310725+Diomendius@users.noreply.github.com> Date: Sat, 6 Jul 2024 14:31:27 +1200 Subject: [PATCH] Enable CMake Release build type and LTO by default --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 991c3de..4ff390b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,22 @@ SET(EXECNAME "AerofoilX" CACHE STRING "Defines the exec name") message(${CMAKE_BINARY_DIR}) +# Use Release build type by default +if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + message("Build type unspecified, using Release") +endif() + +# Enable LTO by default if supported +if("${CMAKE_INTERPROCEDURAL_OPTIMIZATION}" STREQUAL "") + include(CheckIPOSupported) + check_ipo_supported(RESULT IPO_SUPPORTED) + if(IPO_SUPPORTED) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION On) + message("Compiler supports LTO, enabling automatically") + endif() +endif() + # FIXME: Clang treats this as an error by default; fixing the source rather # than downgrading the error to a warning would be a better solution. add_compile_options(