summaryrefslogtreecommitdiffstats
path: root/Modules/Compiler
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/Compiler')
-rw-r--r--Modules/Compiler/Clang.cmake8
-rw-r--r--Modules/Compiler/GNU-CXX.cmake3
-rw-r--r--Modules/Compiler/GNU-FindBinUtils.cmake25
-rw-r--r--Modules/Compiler/GNU.cmake39
-rw-r--r--Modules/Compiler/Intel.cmake2
-rw-r--r--Modules/Compiler/QCC.cmake8
6 files changed, 83 insertions, 2 deletions
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index 96263fc..6b99a08 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -27,5 +27,13 @@ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=")
set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "--gcc-toolchain=")
endif()
+
+ set(_CMAKE_IPO_SUPPORTED_BY_CMAKE NO)
+ set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
+
+ unset(CMAKE_${lang}_COMPILE_OPTIONS_IPO)
+ unset(CMAKE_${lang}_ARCHIVE_CREATE_IPO)
+ unset(CMAKE_${lang}_ARCHIVE_APPEND_IPO)
+ unset(CMAKE_${lang}_ARCHIVE_FINISH_IPO)
endmacro()
endif()
diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index c007c98..2499d2f 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -11,8 +11,7 @@ else()
endif()
endif()
-if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
- # Supported since 4.3
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
endif()
diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake
new file mode 100644
index 0000000..1aa0219
--- /dev/null
+++ b/Modules/Compiler/GNU-FindBinUtils.cmake
@@ -0,0 +1,25 @@
+if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "")
+ message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set")
+endif()
+
+string(REGEX MATCH "^([0-9]+\\.[0-9]+)" __version_x_y
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}")
+
+# Try to find tools in the same directory as GCC itself
+get_filename_component(__gcc_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY)
+
+# http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ar.1.html
+find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar"
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}"
+ HINTS ${__gcc_hints}
+ DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler"
+)
+
+# http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ranlib.1.html
+find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib"
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}"
+ HINTS ${__gcc_hints}
+ DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler"
+)
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index b67002c..0a510f5 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -45,4 +45,43 @@ macro(__compiler_gnu lang)
if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4) # work around #4462
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
endif()
+
+ set(_CMAKE_IPO_SUPPORTED_BY_CMAKE YES)
+ set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
+
+ # '-flto' introduced since GCC 4.5:
+ # * https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Option-Summary.html (no)
+ # * https://gcc.gnu.org/onlinedocs/gcc-4.5.4/gcc/Option-Summary.html (yes)
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.5)
+ set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
+ set(__lto_flags -flto)
+
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.7)
+ # '-ffat-lto-objects' introduced since GCC 4.7:
+ # * https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Option-Summary.html (no)
+ # * https://gcc.gnu.org/onlinedocs/gcc-4.7.4/gcc/Option-Summary.html (yes)
+ list(APPEND __lto_flags -fno-fat-lto-objects)
+ endif()
+
+ set(CMAKE_${lang}_COMPILE_OPTIONS_IPO ${__lto_flags})
+
+ # Need to use version of 'ar'/'ranlib' with plugin support.
+ # Quote from [documentation][1]:
+ #
+ # To create static libraries suitable for LTO,
+ # use gcc-ar and gcc-ranlib instead of ar and ranlib
+ #
+ # [1]: https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/Optimize-Options.html
+ set(CMAKE_${lang}_ARCHIVE_CREATE_IPO
+ "${CMAKE_${lang}_COMPILER_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>"
+ )
+
+ set(CMAKE_${lang}_ARCHIVE_APPEND_IPO
+ "${CMAKE_${lang}_COMPILER_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>"
+ )
+
+ set(CMAKE_${lang}_ARCHIVE_FINISH_IPO
+ "${CMAKE_${lang}_COMPILER_RANLIB} <TARGET>"
+ )
+ endif()
endmacro()
diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake
index 02968b4..06d01f1 100644
--- a/Modules/Compiler/Intel.cmake
+++ b/Modules/Compiler/Intel.cmake
@@ -22,5 +22,7 @@ else()
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os")
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3")
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
+
+ set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
endmacro()
endif()
diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake
index 2d7e881..695a138 100644
--- a/Modules/Compiler/QCC.cmake
+++ b/Modules/Compiler/QCC.cmake
@@ -12,4 +12,12 @@ macro(__compiler_qcc lang)
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,")
set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>")
+
+ set(_CMAKE_IPO_SUPPORTED_BY_CMAKE NO)
+ set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
+
+ unset(CMAKE_${lang}_COMPILE_OPTIONS_IPO)
+ unset(CMAKE_${lang}_ARCHIVE_CREATE_IPO)
+ unset(CMAKE_${lang}_ARCHIVE_APPEND_IPO)
+ unset(CMAKE_${lang}_ARCHIVE_FINISH_IPO)
endmacro()