Skip to content

Commit

Permalink
Enable LTO/IPO on release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
oynqr committed Mar 22, 2022
1 parent c7fdfb8 commit c7c83a3
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "depends/libnbtplusplus"]
path = libraries/libnbtplusplus
url = https://github.com/MultiMC/libnbtplusplus.git
pushurl = [email protected]:MultiMC/libnbtplusplus.git
url = https://github.com/PolyMC/libnbtplusplus.git
pushurl = [email protected]:PolyMC/libnbtplusplus.git

[submodule "libraries/quazip"]
path = libraries/quazip
Expand Down
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9.4)

if(WIN32)
# In Qt 5.1+ we have our own main() function, don't autolink to qtmain on Windows
Expand Down Expand Up @@ -43,6 +43,18 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror=return-type")
# Fix build with Qt 5.13
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_DEPRECATED_WARNINGS=Y")

include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error)

if(ipo_supported AND (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel"))
message(STATUS "IPO / LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
elseif(ipo_supported)
message(STATUS "Not enabling IPO / LTO on debug builds")
else()
message(STATUS "IPO / LTO not supported: <${ipo_error}>")
endif()

##################################### Set Application options #####################################

######## Set URLs ########
Expand Down
2 changes: 1 addition & 1 deletion libraries/LocalPeer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9.4)
project(LocalPeer)

find_package(Qt5 COMPONENTS Core Network REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion libraries/iconfix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9.4)
project(iconfix)

find_package(Qt5Core REQUIRED QUIET)
Expand Down
2 changes: 1 addition & 1 deletion libraries/javacheck/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9.4)
project(launcher Java)
find_package(Java 1.7 REQUIRED COMPONENTS Development)

Expand Down
2 changes: 1 addition & 1 deletion libraries/katabasis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.6)
cmake_minimum_required(VERSION 3.9.4)

string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BUILD_DIR}" IS_IN_SOURCE_BUILD)
if(IS_IN_SOURCE_BUILD)
Expand Down
2 changes: 1 addition & 1 deletion libraries/launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9.4)
project(launcher Java)
find_package(Java 1.7 REQUIRED COMPONENTS Development)

Expand Down
2 changes: 1 addition & 1 deletion libraries/libnbtplusplus
2 changes: 1 addition & 1 deletion libraries/optional-bare/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9.4)
project(optional-bare)

add_library(optional-bare INTERFACE)
Expand Down
2 changes: 1 addition & 1 deletion libraries/rainbow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9.4)
project(rainbow)

find_package(Qt5Core REQUIRED QUIET)
Expand Down
2 changes: 1 addition & 1 deletion libraries/xz-embedded/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9.4)
project(xz-embedded LANGUAGES C)

option(XZ_BUILD_BCJ "Build xz-embedded with BCJ support (native binary optimization)" OFF)
Expand Down

0 comments on commit c7c83a3

Please sign in to comment.