Skip to content

Commit 7fa9985

Browse files
committed
Build using LTO if compiler supports it (requires Cmake 3.9)
1 parent c5acf62 commit 7fa9985

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.9)
22
project(ccls LANGUAGES CXX)
33

44
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)
3030
set_property(TARGET ccls PROPERTY CXX_STANDARD_REQUIRED ON)
3131
set_property(TARGET ccls PROPERTY CXX_EXTENSIONS OFF)
3232

33+
# Build using LTO if the copmiler supports it
34+
include(CheckIPOSupported)
35+
check_ipo_supported(RESULT ipo OUTPUT error)
36+
if (ipo)
37+
set_property(TARGET ccls PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
38+
endif()
39+
3340
# CMake sets MSVC for both MSVC and Clang(Windows)
3441
if(MSVC)
3542
# Common MSVC/Clang(Windows) options

0 commit comments

Comments
 (0)