Use LTO by default
This commit is contained in:
parent
f32a6dfc74
commit
43b9aed1ef
@ -36,6 +36,7 @@ option(ENABLE_FUZZING "Fuzz testing using LLVM's libFuzzer" OFF)
|
|||||||
option(ENABLE_NODE_BINDINGS "Build NodeJs bindings" OFF)
|
option(ENABLE_NODE_BINDINGS "Build NodeJs bindings" OFF)
|
||||||
option(ENABLE_CLANG_TIDY "Enables clang-tidy checks" OFF)
|
option(ENABLE_CLANG_TIDY "Enables clang-tidy checks" OFF)
|
||||||
|
|
||||||
|
|
||||||
if (ENABLE_CLANG_TIDY)
|
if (ENABLE_CLANG_TIDY)
|
||||||
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
|
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
|
||||||
if(NOT CLANG_TIDY_COMMAND)
|
if(NOT CLANG_TIDY_COMMAND)
|
||||||
@ -57,6 +58,18 @@ if (POLICY CMP0074)
|
|||||||
endif()
|
endif()
|
||||||
project(OSRM C CXX)
|
project(OSRM C CXX)
|
||||||
|
|
||||||
|
|
||||||
|
if(ENABLE_LTO AND (CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES MinRelSize OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo))
|
||||||
|
include(CheckIPOSupported)
|
||||||
|
check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT error)
|
||||||
|
if(LTO_SUPPORTED)
|
||||||
|
message(STATUS "IPO / LTO enabled")
|
||||||
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "IPO / LTO not supported: <${error}>")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# add @loader_path/$ORIGIN to rpath to make binaries relocatable
|
# add @loader_path/$ORIGIN to rpath to make binaries relocatable
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
set(CMAKE_BUILD_RPATH "@loader_path")
|
set(CMAKE_BUILD_RPATH "@loader_path")
|
||||||
@ -208,17 +221,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -ggdb")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -ggdb")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LTO AND (CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES MinRelSize OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo))
|
|
||||||
include(CheckIPOSupported)
|
|
||||||
check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT error)
|
|
||||||
if(LTO_SUPPORTED)
|
|
||||||
message(STATUS "IPO / LTO enabled")
|
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "IPO / LTO not supported: <${error}>")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(MAYBE_COVERAGE_LIBRARIES "")
|
set(MAYBE_COVERAGE_LIBRARIES "")
|
||||||
if (ENABLE_COVERAGE)
|
if (ENABLE_COVERAGE)
|
||||||
if (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
if (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
|
Loading…
Reference in New Issue
Block a user