From 435f6c5c89be038349b54cc175eda97b64e25aec Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Tue, 12 May 2020 15:06:22 -0500 Subject: [PATCH] build: Allow enabling inter-procedural optimization in CMake builds, if supported. --- CMakeLists.txt | 9 +++++++++ doc/changes/misc_features/mr.330.md | 1 + src/xrt/state_trackers/gui/CMakeLists.txt | 3 +++ 3 files changed, 13 insertions(+) create mode 100644 doc/changes/misc_features/mr.330.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 6483ba4e8..9459fb8b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(CMakeDependentOption) include(SPIR-V) include(GNUInstallDirs) +if(NOT ${CMAKE_VERSION} VERSION_LESS 3.9) + include(CheckIPOSupported) + check_ipo_supported(RESULT HAS_IPO) +endif() find_package(Eigen3 REQUIRED) find_package(Vulkan REQUIRED) @@ -64,6 +68,7 @@ else() find_package(OpenGL) endif() +cmake_dependent_option(CMAKE_INTERPROCEDURAL_OPTIMIZATION "Enable inter-procedural (link-time) optimization" OFF "HAS_IPO" OFF) cmake_dependent_option(XRT_HAVE_WAYLAND "Enable Wayland support" ON "WAYLAND_FOUND AND WAYLAND_SCANNER_FOUND AND WAYLAND_PROTOCOLS_FOUND" OFF) cmake_dependent_option(XRT_HAVE_XLIB "Enable xlib support" ON "X11_FOUND" OFF) cmake_dependent_option(XRT_HAVE_XCB "Enable xcb support" ON "XCB_FOUND" OFF) @@ -152,6 +157,10 @@ endif() # Default to PIC code set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# Describe IPO setting +if(CMAKE_INTERPROCEDURAL_OPTIMIZATION) + message(STATUS "Inter-procedural optimization enabled") +endif() ### # Decend into madness. diff --git a/doc/changes/misc_features/mr.330.md b/doc/changes/misc_features/mr.330.md new file mode 100644 index 000000000..120b0cf0f --- /dev/null +++ b/doc/changes/misc_features/mr.330.md @@ -0,0 +1 @@ +build: Allow enabling inter-procedural optimization in CMake GUIs, if supported by platform and compiler. diff --git a/src/xrt/state_trackers/gui/CMakeLists.txt b/src/xrt/state_trackers/gui/CMakeLists.txt index 863a76f8d..ca119247c 100644 --- a/src/xrt/state_trackers/gui/CMakeLists.txt +++ b/src/xrt/state_trackers/gui/CMakeLists.txt @@ -1,6 +1,9 @@ # Copyright 2019-2020, Collabora, Ltd. # SPDX-License-Identifier: BSL-1.0 +# c-imgui doesn't do well with IPO - lots of warnings. +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) + set(GUI_SOURCE_FILES gui_common.h gui_imgui.h