Build using LTO if compiler supports it (requires Cmake 3.9)

This commit is contained in:
Evan Klitzke 2020-06-10 09:21:13 -07:00
parent c5acf62060
commit 39ec1549af
No known key found for this signature in database
GPG Key ID: 7547F1FDF6629AFB

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.9)
project(ccls LANGUAGES CXX)
option(USE_SYSTEM_RAPIDJSON "Use system RapidJSON instead of the git submodule if exists" ON)
@ -30,6 +30,13 @@ set_property(TARGET ccls PROPERTY CXX_STANDARD 17)
set_property(TARGET ccls PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ccls PROPERTY CXX_EXTENSIONS OFF)
# Build using LTO if the compiler supports it
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo OUTPUT error)
if (ipo)
set_property(TARGET ccls PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
# CMake sets MSVC for both MSVC and Clang(Windows)
if(MSVC)
# Common MSVC/Clang(Windows) options