From fa5966bd044c4f3a06dae28fca841f9c849d729d Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 6 Nov 2014 15:12:53 -0700 Subject: [PATCH] Enable optimizations options for LTO and profile --- CMakeLists.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8ef4b9..3917f0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,27 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") add_definitions(-fsanitize=undefined -g) set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined") endif() + + option(ENABLE_LTO "Enable Link Time Optimization" FALSE) + + if (ENABLE_LTO) + add_definitions(-flto) + set(LINKER_FLAGS "${LINKER_FLAGS} -flto") + endif() + + option(PROFILE_GENERATE "Generate profile data" FALSE) + if (PROFILE_GENERATE) + add_definitions(-fprofile-generate) + set(LINKER_FLAGS "${LINKER_FLAGS} -fprofile-generate") + endif() + + option(PROFILE_USE "Use profile data" FALSE) + if (PROFILE_USE) + add_definitions(-fprofile-use) + set(LINKER_FLAGS "${LINKER_FLAGS} -fprofile-use") + endif() + + endif() list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR}")