From bf1a38247f292301f3b75b3dacbef41cd0a1bb46 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sun, 20 Mar 2016 10:47:56 +0200 Subject: Add LTO option --- CMakeLists.txt | 9 ++++++++- README.md | 11 ++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45916d0..739b80d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ ENDIF(NOT CMAKE_BUILD_TYPE) set(LIBKMS_ENABLE_PYTHON ON CACHE BOOL "Enable Python wrappers") set(LIBKMS_ENABLE_KMSCUBE OFF CACHE BOOL "Enable kmscube") +set(LIBKMS_ENABLE_LTO OFF CACHE BOOL "Enable LTO") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") @@ -17,6 +18,12 @@ set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) # static link libc # set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") +if(LIBKMS_ENABLE_LTO) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -fwhole-program") + set(CMAKE_AR gcc-ar) + set(CMAKE_RANLIB gcc-ranlib) +endif() + find_package(PkgConfig REQUIRED) pkg_check_modules(LIBDRM libdrm REQUIRED) @@ -27,7 +34,7 @@ add_subdirectory(libkmstest) add_subdirectory(tests) if(LIBKMS_ENABLE_KMSCUBE) -add_subdirectory(kmscube) + add_subdirectory(kmscube) endif() if(LIBKMS_ENABLE_PYTHON) diff --git a/README.md b/README.md index 363be9a..030312f 100644 --- a/README.md +++ b/README.md @@ -54,11 +54,12 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) You can use the following cmake flags to control the build. Use `-DFLAG=VALUE` to set them. -Option name | Values | Default --------------------- | ------------- | -------- -CMAKE_BUILD_TYPE | Release/Debug | Release -LIBKMS_ENABLE_PYTHON | ON/OFF | ON -LIBKMS_ENABLE_KMSCUBE | ON/OFF | OFF +Option name | Values | Default | Notes +--------------------- | ------------- | -------- | -------- +CMAKE_BUILD_TYPE | Release/Debug | Release | +LIBKMS_ENABLE_PYTHON | ON/OFF | ON | +LIBKMS_ENABLE_KMSCUBE | ON/OFF | OFF | +LIBKMS_ENABLE_LTO  | ON/OFF | OFF | Link Time Optimization ## Env variables -- cgit v1.2.3