DO NOT MERGE try what lto does; this needs cmake 3.9 so it will break in places, but I want to see what happens
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 914aaf6..7e46b35 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -90,6 +90,16 @@
 include(CheckFunctionExists)
 include(CheckIncludeFiles)
 include(CMakeDependentOption)
+include(CheckIPOSupported)
+
+check_ipo_supported(RESULT cc_has_ipo OUTPUT check_ipo_supported_output)
+message(STATUS "Interprocedural optimization (IPO/LTO) supported: ${cc_has_ipo}")
+if(NOT cc_has_ipo)
+    message(WARNING "IPO is not supported: ${output}")
+endif()
+if(NOT DEFINED(CMAKE_INTERPROCEDURAL_OPTIMIZATION))
+    set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${cc_has_ipo})
+endif()
 
 ##
 ## Find dependencies