summaryrefslogtreecommitdiff
path: root/dev-util/cmake/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /dev-util/cmake/files
reinit the tree, so we can have metadata
Diffstat (limited to 'dev-util/cmake/files')
-rw-r--r--dev-util/cmake/files/50cmake-gentoo.el4
-rw-r--r--dev-util/cmake/files/cmake-2.8.10.2-FindPythonLibs.patch24
-rw-r--r--dev-util/cmake/files/cmake-2.8.12.1-FindImageMagick.patch23
-rw-r--r--dev-util/cmake/files/cmake-3.0.0-FindBLAS.patch43
-rw-r--r--dev-util/cmake/files/cmake-3.0.0-FindBoost-python.patch93
-rw-r--r--dev-util/cmake/files/cmake-3.0.0-prefix-dirs.patch142
-rw-r--r--dev-util/cmake/files/cmake-3.0.2-FindLAPACK.patch43
-rw-r--r--dev-util/cmake/files/cmake-3.1.0-FindPythonInterp.patch29
-rw-r--r--dev-util/cmake/files/cmake-3.1.0-darwin-isysroot.patch48
-rw-r--r--dev-util/cmake/files/cmake-3.4.0_rc1-darwin-bundle.patch25
-rw-r--r--dev-util/cmake/files/cmake-3.5.2-FindQt4.patch45
-rw-r--r--dev-util/cmake/files/cmake-3.8.0_rc2-FindBoost-python.patch95
-rw-r--r--dev-util/cmake/files/cmake-3.9.0_rc2-FindImageMagick.patch47
-rw-r--r--dev-util/cmake/files/cmake-3.9.0_rc2-FindPythonInterp.patch43
-rw-r--r--dev-util/cmake/files/cmake-3.9.0_rc2-prefix-dirs.patch126
-rw-r--r--dev-util/cmake/files/cmake.vim3
16 files changed, 833 insertions, 0 deletions
diff --git a/dev-util/cmake/files/50cmake-gentoo.el b/dev-util/cmake/files/50cmake-gentoo.el
new file mode 100644
index 000000000000..e4a1a6d47cbc
--- /dev/null
+++ b/dev-util/cmake/files/50cmake-gentoo.el
@@ -0,0 +1,4 @@
+(add-to-list 'load-path "@SITELISP@")
+(autoload 'cmake-mode "cmake-mode" "Major mode for editing CMake files." t)
+(add-to-list 'auto-mode-alist '("CMakeLists\\.txt\\'" . cmake-mode))
+(add-to-list 'auto-mode-alist '("\\.cmake\\'" . cmake-mode))
diff --git a/dev-util/cmake/files/cmake-2.8.10.2-FindPythonLibs.patch b/dev-util/cmake/files/cmake-2.8.10.2-FindPythonLibs.patch
new file mode 100644
index 000000000000..5f9c26658f31
--- /dev/null
+++ b/dev-util/cmake/files/cmake-2.8.10.2-FindPythonLibs.patch
@@ -0,0 +1,24 @@
+diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
+index bffa9fb..8fc90ee 100644
+--- a/Modules/FindPythonLibs.cmake
++++ b/Modules/FindPythonLibs.cmake
+@@ -74,6 +74,19 @@ set(_Python_VERSIONS
+ ${_PYTHON_FIND_OTHER_VERSIONS}
+ )
+
++# Gentoo portage requires that you use exactly the given python version
++if (CMAKE_GENTOO_BUILD OR CMAKE_BUILD_TYPE STREQUAL Gentoo)
++ execute_process(COMMAND python -c "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))"
++ OUTPUT_VARIABLE _Gentoo_Python_VERSION)
++ list(FIND _Python_VERSIONS "${_Gentoo_Python_VERSION}" _Gentoo_Python_INDEX)
++ if (_Gentoo_Python_INDEX EQUAL -1)
++ # the current Gentoo python version is not compatible with what is requested
++ set(_Python_VERSIONS)
++ else ()
++ set(_Python_VERSIONS "${_Gentoo_Python_VERSION}")
++ endif ()
++endif()
++
+ unset(_PYTHON_FIND_OTHER_VERSIONS)
+ unset(_PYTHON1_VERSIONS)
+ unset(_PYTHON2_VERSIONS)
diff --git a/dev-util/cmake/files/cmake-2.8.12.1-FindImageMagick.patch b/dev-util/cmake/files/cmake-2.8.12.1-FindImageMagick.patch
new file mode 100644
index 000000000000..0c42303955af
--- /dev/null
+++ b/dev-util/cmake/files/cmake-2.8.12.1-FindImageMagick.patch
@@ -0,0 +1,23 @@
+--- a/Modules/FindImageMagick.cmake
++++ b/Modules/FindImageMagick.cmake
+@@ -147,17 +147,17 @@
+ )
+ if(component STREQUAL "Magick++")
+ FIND_IMAGEMAGICK_API(Magick++ Magick++.h
+- Magick++ CORE_RL_Magick++_ Magick++-6.Q16 Magick++-Q16 Magick++-6.Q8 Magick++-Q8 Magick++-6.Q16HDRI Magick++-Q16HDRI Magick++-6.Q8HDRI Magick++-Q8HDRI
++ Magick++ CORE_RL_Magick++_ Magick++-6.Q64 Magick++-6.Q64HDRI Magick++-6.Q32 Magick++-6.Q32HDRI Magick++-6.Q16 Magick++-6.Q16HDRI Magick++-6.Q8 Magick++-6.Q8HDRI
+ )
+ list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_Magick++_LIBRARY)
+ elseif(component STREQUAL "MagickWand")
+ FIND_IMAGEMAGICK_API(MagickWand wand/MagickWand.h
+- Wand MagickWand CORE_RL_wand_ MagickWand-6.Q16 MagickWand-Q16 MagickWand-6.Q8 MagickWand-Q8 MagickWand-6.Q16HDRI MagickWand-Q16HDRI MagickWand-6.Q8HDRI MagickWand-Q8HDRI
++ Wand MagickWand CORE_RL_wand_ MagickWand-6.Q64 MagickWand-6.Q64HDRI MagickWand-6.Q32 MagickWand-6.Q32HDRI MagickWand-6.Q16 MagickWand-6.Q16HDRI MagickWand-6.Q8 MagickWand-6.Q8HDRI
+ )
+ list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickWand_LIBRARY)
+ elseif(component STREQUAL "MagickCore")
+ FIND_IMAGEMAGICK_API(MagickCore magick/MagickCore.h
+- Magick MagickCore CORE_RL_magick_ MagickCore-6.Q16 MagickCore-Q16 MagickCore-6.Q8 MagickCore-Q8 MagickCore-6.Q16HDRI MagickCore-Q16HDRI MagickCore-6.Q8HDRI MagickCore-Q8HDRI
++ Magick MagickCore CORE_RL_magick_ MagickCore-6.Q64 MagickCore-6.Q64HDRI MagickCore-6.Q32 MagickCore-6.Q32HDRI MagickCore-6.Q16 MagickCore-6.Q16HDRI MagickCore-6.Q8 MagickCore-6.Q8HDRI
+ )
+ list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickCore_LIBRARY)
+ else()
diff --git a/dev-util/cmake/files/cmake-3.0.0-FindBLAS.patch b/dev-util/cmake/files/cmake-3.0.0-FindBLAS.patch
new file mode 100644
index 000000000000..342a4319798d
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.0.0-FindBLAS.patch
@@ -0,0 +1,43 @@
+--- a/Modules/FindBLAS.cmake
++++ b/Modules/FindBLAS.cmake
+@@ -4,6 +4,10 @@
+ #
+ # Find BLAS library
+ #
++# Version modified for Gentoo Linux.
++# If a valid PkgConfig configuration is found, this overrides and cancels
++# all further checks.
++#
+ # This module finds an installed fortran library that implements the
+ # BLAS linear-algebra interface (see http://www.netlib.org/blas/). The
+ # list of libraries searched for is taken from the autoconf macro file,
+@@ -50,6 +54,23 @@
+ # (To distribute this file outside of CMake, substitute the full
+ # License text for the above reference.)
+
++# first, try PkgConfig
++#
++find_package(PkgConfig REQUIRED)
++pkg_check_modules(PC_BLAS blas)
++if(PC_BLAS_FOUND)
++ foreach(PC_LIB ${PC_BLAS_LIBRARIES})
++ find_library(${PC_LIB}_LIBRARY NAMES ${PC_LIB} HINTS ${PC_BLAS_LIBRARY_DIRS} )
++ if (NOT ${PC_LIB}_LIBRARY)
++ message(FATAL_ERROR "Something is wrong in your pkg-config file - lib ${PC_LIB} not found in ${PC_BLAS_LIBRARY_DIRS}")
++ endif (NOT ${PC_LIB}_LIBRARY)
++ list(APPEND BLAS_LIBRARIES ${${PC_LIB}_LIBRARY})
++ endforeach(PC_LIB)
++ find_package_handle_standard_args(BLAS DEFAULT_MSG BLAS_LIBRARIES)
++ mark_as_advanced(BLAS_LIBRARIES)
++else(PC_BLAS_FOUND)
++message(STATUS "No PkgConfig configuration for BLAS found; starting more extensive search.")
++
+ include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
+ include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
+
+@@ -688,3 +709,5 @@
+ endif()
+
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
++
++endif(PC_BLAS_FOUND)
diff --git a/dev-util/cmake/files/cmake-3.0.0-FindBoost-python.patch b/dev-util/cmake/files/cmake-3.0.0-FindBoost-python.patch
new file mode 100644
index 000000000000..a6291d2b8500
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.0.0-FindBoost-python.patch
@@ -0,0 +1,93 @@
+From 934ec9add33d413e4d5c9cec1cb3ebb5cbfd81f4 Mon Sep 17 00:00:00 2001
+From: Michael Palimaka <kensington@gentoo.org>
+Date: Thu, 19 Jun 2014 00:17:48 +1000
+Subject: [PATCH] Fix detection of PYTHON_ABI-versioned Boost Python libraries
+ wrt bug #400969.
+
+---
+ Modules/FindBoost.cmake | 41 +++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 41 insertions(+)
+
+diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
+index dfd4460..70bfb4f 100644
+--- a/Modules/FindBoost.cmake
++++ b/Modules/FindBoost.cmake
+@@ -952,6 +952,15 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ set( _boost_docstring_release "Boost ${COMPONENT} library (release)")
+ set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)")
+
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ # Get version of Python.
++ if (NOT PYTHON_EXECUTABLE)
++ #if a certain version of python was detected by cmake before use that one
++ set(PYTHON_EXECUTABLE "python")
++ endif (NOT PYTHON_EXECUTABLE)
++ execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write('.'.join(str(x) for x in sys.version_info[:2]))" OUTPUT_VARIABLE _python_version)
++ endif()
++
+ # Compute component-specific hints.
+ set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
+ if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR
+@@ -984,6 +993,15 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ list(APPEND _boost_RELEASE_NAMES
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version} )
++ endif()
++
+ if(_boost_STATIC_RUNTIME_WORKAROUND)
+ set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
+ list(APPEND _boost_RELEASE_NAMES
+@@ -991,6 +1009,13 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ list(APPEND _boost_RELEASE_NAMES
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
++ endif()
+ endif()
+ if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
+ _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES})
+@@ -1020,6 +1045,15 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ list(APPEND _boost_DEBUG_NAMES
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version} )
++ endif()
+ if(_boost_STATIC_RUNTIME_WORKAROUND)
+ set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
+ list(APPEND _boost_DEBUG_NAMES
+@@ -1027,6 +1061,13 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ list(APPEND _boost_DEBUG_NAMES
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
++ endif()
+ endif()
+ if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
+ _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES})
+--
+1.8.5.5
+
diff --git a/dev-util/cmake/files/cmake-3.0.0-prefix-dirs.patch b/dev-util/cmake/files/cmake-3.0.0-prefix-dirs.patch
new file mode 100644
index 000000000000..decfb91260aa
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.0.0-prefix-dirs.patch
@@ -0,0 +1,142 @@
+From e7ce3e523f8cfa1bc749118f381753230766827f Mon Sep 17 00:00:00 2001
+From: Michael Palimaka <kensington@gentoo.org>
+Date: Thu, 19 Jun 2014 00:08:13 +1000
+Subject: [PATCH] Set some proper paths to make cmake find our tools.
+
+The ebuild now adds an extra / at the end of $EPREFIX so that it is
+never the empty string (so that CMAKE_SYSTEM_PREFIX_PATH remains
+correct)
+
+Original patch by Heiko Przybyl.
+Updated by Chris Reffett (cmake-2.8.8)
+Updated by Johannes Huber (cmake-2.8.9)
+Updated by Michael Palimaka (cmake-2.8.10)
+Updated by Chris Reffett (cmake-2.8.11)
+Updated by Michael Palimaka (cmake-3.0.0)
+---
+ Modules/Platform/Darwin.cmake | 12 +++++++----
+ Modules/Platform/UnixPaths.cmake | 43 ++++++++++++++++++++--------------------
+ 2 files changed, 29 insertions(+), 26 deletions(-)
+
+diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
+index e25df1e..9b22a6a 100644
+--- a/Modules/Platform/Darwin.cmake
++++ b/Modules/Platform/Darwin.cmake
+@@ -132,9 +132,9 @@ set(CMAKE_C_FRAMEWORK_SEARCH_FLAG -F)
+ set(CMAKE_CXX_FRAMEWORK_SEARCH_FLAG -F)
+ set(CMAKE_Fortran_FRAMEWORK_SEARCH_FLAG -F)
+
+-# default to searching for frameworks first
++# default to searching for frameworks last
+ if(NOT DEFINED CMAKE_FIND_FRAMEWORK)
+- set(CMAKE_FIND_FRAMEWORK FIRST)
++ set(CMAKE_FIND_FRAMEWORK LAST)
+ endif()
+
+ # Older OS X linkers do not report their framework search path
+@@ -156,6 +156,8 @@ endif()
+
+ # set up the default search directories for frameworks
+ set(CMAKE_SYSTEM_FRAMEWORK_PATH
++ @GENTOO_PORTAGE_EPREFIX@Frameworks
++ @GENTOO_PORTAGE_EPREFIX@usr/lib
+ ~/Library/Frameworks
+ )
+ if(_CMAKE_OSX_SYSROOT_PATH)
+@@ -187,13 +189,15 @@ if(CMAKE_OSX_SYSROOT)
+ endif()
+ endif()
+
+-# default to searching for application bundles first
++# default to searching for application bundles last
+ if(NOT DEFINED CMAKE_FIND_APPBUNDLE)
+- set(CMAKE_FIND_APPBUNDLE FIRST)
++ set(CMAKE_FIND_APPBUNDLE LAST)
+ endif()
+ # set up the default search directories for application bundles
+ set(_apps_paths)
+ foreach(_path
++ @GENTOO_PORTAGE_EPREFIX@Applications
++ @GENTOO_PORTAGE_EPREFIX@usr/bin
+ "~/Applications"
+ "/Applications"
+ "${OSX_DEVELOPER_ROOT}/../Applications" # Xcode 4.3+
+diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
+index 20ee1d1..3481ca8 100644
+--- a/Modules/Platform/UnixPaths.cmake
++++ b/Modules/Platform/UnixPaths.cmake
+@@ -33,6 +33,7 @@ get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
+ # search types.
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
+ # Standard
++ @GENTOO_PORTAGE_EPREFIX@usr/local @GENTOO_PORTAGE_EPREFIX@usr @GENTOO_PORTAGE_EPREFIX@
+ /usr/local /usr /
+
+ # CMake install location
+@@ -53,43 +54,41 @@ endif()
+
+ # List common include file locations not under the common prefixes.
+ list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
+- # Windows API on Cygwin
+- /usr/include/w32api
+-
+- # X11
+- /usr/X11R6/include /usr/include/X11
+-
+- # Other
+- /usr/pkg/include
+- /opt/csw/include /opt/include
+- /usr/openwin/include
++ @GENTOO_PORTAGE_EPREFIX@usr/include
+ )
+
+ list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
+- # Windows API on Cygwin
+- /usr/lib/w32api
+-
+- # X11
+- /usr/X11R6/lib /usr/lib/X11
+-
+- # Other
+- /usr/pkg/lib
+- /opt/csw/lib /opt/lib
+- /usr/openwin/lib
++ @GENTOO_PORTAGE_GCCLIBDIR@/gcc
++ @GENTOO_PORTAGE_GCCLIBDIR@
++ @GENTOO_PORTAGE_EPREFIX@usr/lib64
++ @GENTOO_PORTAGE_EPREFIX@usr/libx32
++ @GENTOO_PORTAGE_EPREFIX@usr/lib32
++ @GENTOO_PORTAGE_EPREFIX@usr/lib
++ @GENTOO_PORTAGE_EPREFIX@lib
+ )
+
+ list(APPEND CMAKE_SYSTEM_PROGRAM_PATH
+- /usr/pkg/bin
++ @GENTOO_PORTAGE_EPREFIX@usr/bin
++ @GENTOO_PORTAGE_EPREFIX@bin
+ )
+
+ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
+- /lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
++ @GENTOO_PORTAGE_GCCLIBDIR@/gcc
++ @GENTOO_PORTAGE_GCCLIBDIR@
++ @GENTOO_PORTAGE_EPREFIX@usr/lib64
++ @GENTOO_PORTAGE_EPREFIX@usr/libx32
++ @GENTOO_PORTAGE_EPREFIX@usr/lib32
++ @GENTOO_PORTAGE_EPREFIX@usr/lib
++ @GENTOO_PORTAGE_EPREFIX@lib
++ /lib /usr/lib /usr/lib32 /usr/lib64 /usr/libx32
+ )
+
+ list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
++ GENTOO_PORTAGE_EPREFIX@usr/include
+ /usr/include
+ )
+ list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
++ @GENTOO_PORTAGE_EPREFIX@usr/include
+ /usr/include
+ )
+
+--
+1.8.5.5
+
diff --git a/dev-util/cmake/files/cmake-3.0.2-FindLAPACK.patch b/dev-util/cmake/files/cmake-3.0.2-FindLAPACK.patch
new file mode 100644
index 000000000000..321f05302aa1
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.0.2-FindLAPACK.patch
@@ -0,0 +1,43 @@
+--- a/Modules/FindLAPACK.cmake
++++ b/Modules/FindLAPACK.cmake
+@@ -4,6 +4,10 @@
+ #
+ # Find LAPACK library
+ #
++# Version modified for Gentoo Linux.
++# If a valid PkgConfig configuration is found, this overrides and cancels
++# all further checks.
++#
+ # This module finds an installed fortran library that implements the
+ # LAPACK linear-algebra interface (see http://www.netlib.org/lapack/).
+ #
+@@ -140,6 +144,23 @@
+
+ endmacro()
+
++#
++# first, try PkgConfig
++#
++find_package(PkgConfig REQUIRED)
++pkg_check_modules(PC_LAPACK lapack)
++if(PC_LAPACK_FOUND)
++ foreach(PC_LIB ${PC_LAPACK_LIBRARIES})
++ find_library(${PC_LIB}_LIBRARY NAMES ${PC_LIB} HINTS ${PC_LAPACK_LIBRARY_DIRS} )
++ if (NOT ${PC_LIB}_LIBRARY)
++ message(FATAL_ERROR "Something is wrong in your pkg-config file - lib ${PC_LIB} not found in ${PC_LAPACK_LIBRARY_DIRS}")
++ endif (NOT ${PC_LIB}_LIBRARY)
++ list(APPEND LAPACK_LIBRARIES ${${PC_LIB}_LIBRARY})
++ endforeach(PC_LIB)
++ find_package_handle_standard_args(LAPACK DEFAULT_MSG LAPACK_LIBRARIES)
++ mark_as_advanced(LAPACK_LIBRARIES)
++else(PC_LAPACK_FOUND)
++message(STATUS "No PkgConfig configuration for LAPACK found; starting more extensive search.")
+
+ set(LAPACK_LINKER_FLAGS)
+ set(LAPACK_LIBRARIES)
+@@ -348,3 +369,5 @@
+ endif()
+
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
++
++endif(PC_LAPACK_FOUND)
diff --git a/dev-util/cmake/files/cmake-3.1.0-FindPythonInterp.patch b/dev-util/cmake/files/cmake-3.1.0-FindPythonInterp.patch
new file mode 100644
index 000000000000..bb3ca9580ad9
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.1.0-FindPythonInterp.patch
@@ -0,0 +1,29 @@
+--- a/Modules/FindPythonInterp.cmake
++++ b/Modules/FindPythonInterp.cmake
+@@ -75,6 +75,11 @@
+ else()
+ set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
+ endif()
++
++if (CMAKE_GENTOO_BUILD OR CMAKE_BUILD_TYPE STREQUAL Gentoo)
++ set(_Python_NAMES python)
++endif()
++
+ find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES})
+
+ # Set up the versions we know about, in the order we will search. Always add
+@@ -99,12 +104,13 @@
+ unset(_PYTHON3_VERSIONS)
+
+ # Search for newest python version if python executable isn't found
+-if(NOT PYTHON_EXECUTABLE)
++if(NOT PYTHON_EXECUTABLE AND NOT (CMAKE_GENTOO_BUILD OR CMAKE_BUILD_TYPE STREQUAL Gentoo))
+ foreach(_CURRENT_VERSION IN LISTS _Python_VERSIONS)
+ set(_Python_NAMES python${_CURRENT_VERSION})
+ if(WIN32)
+ list(APPEND _Python_NAMES python)
+ endif()
++
+ find_program(PYTHON_EXECUTABLE
+ NAMES ${_Python_NAMES}
+ PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]
diff --git a/dev-util/cmake/files/cmake-3.1.0-darwin-isysroot.patch b/dev-util/cmake/files/cmake-3.1.0-darwin-isysroot.patch
new file mode 100644
index 000000000000..1f3599bcc828
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.1.0-darwin-isysroot.patch
@@ -0,0 +1,48 @@
+Do not detect Xcode and set -isysroot for its SDK, since that messes up
+our toolchain, and hence makes any compilation fail, bug #445308
+
+--- a/Modules/Platform/Darwin-Initialize.cmake
++++ b/Modules/Platform/Darwin-Initialize.cmake
+@@ -1,16 +1,16 @@
+ # Ask xcode-select where to find /Developer or fall back to ancient location.
+-execute_process(COMMAND xcode-select -print-path
+- OUTPUT_VARIABLE _stdout
+- OUTPUT_STRIP_TRAILING_WHITESPACE
+- ERROR_VARIABLE _stderr
+- RESULT_VARIABLE _failed)
+-if(NOT _failed AND IS_DIRECTORY ${_stdout})
+- set(OSX_DEVELOPER_ROOT ${_stdout})
+-elseif(IS_DIRECTORY "/Developer")
+- set(OSX_DEVELOPER_ROOT "/Developer")
+-else()
++#execute_process(COMMAND xcode-select -print-path
++# OUTPUT_VARIABLE _stdout
++# OUTPUT_STRIP_TRAILING_WHITESPACE
++# ERROR_VARIABLE _stderr
++# RESULT_VARIABLE _failed)
++#if(NOT _failed AND IS_DIRECTORY ${_stdout})
++# set(OSX_DEVELOPER_ROOT ${_stdout})
++#elseif(IS_DIRECTORY "/Developer")
++# set(OSX_DEVELOPER_ROOT "/Developer")
++#else()
+ set(OSX_DEVELOPER_ROOT "")
+-endif()
++#endif()
+
+ execute_process(COMMAND sw_vers -productVersion
+ OUTPUT_VARIABLE CURRENT_OSX_VERSION
+@@ -91,10 +91,10 @@
+ # CMAKE_OSX_DEPLOYMENT_TARGET
+
+ # Set cache variable - end user may change this during ccmake or cmake-gui configure.
+-if(_CURRENT_OSX_VERSION VERSION_GREATER 10.3)
+- set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING
+- "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.")
+-endif()
++#if(_CURRENT_OSX_VERSION VERSION_GREATER 10.3)
++# set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING
++# "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.")
++#endif()
+
+ #----------------------------------------------------------------------------
+ # CMAKE_OSX_SYSROOT
diff --git a/dev-util/cmake/files/cmake-3.4.0_rc1-darwin-bundle.patch b/dev-util/cmake/files/cmake-3.4.0_rc1-darwin-bundle.patch
new file mode 100644
index 000000000000..2808ed79f735
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.4.0_rc1-darwin-bundle.patch
@@ -0,0 +1,25 @@
+Don't use .so for modules on darwin/macos. Use .bundle instead.
+Patch by Heiko Przybyl
+
+Forward-ported from 2.8.10 to 3.4.0-rc1
+
+--- cmake-3.4.0-rc1/Modules/Platform/Darwin.cmake
++++ cmake-3.4.0-rc1/Modules/Platform/Darwin.cmake
+@@ -26,7 +26,7 @@
+ set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
+ set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
+ set(CMAKE_SHARED_MODULE_PREFIX "lib")
+-set(CMAKE_SHARED_MODULE_SUFFIX ".so")
++set(CMAKE_SHARED_MODULE_SUFFIX ".bundle")
+ set(CMAKE_MODULE_EXISTS 1)
+ set(CMAKE_DL_LIBS "")
+
+@@ -53,7 +53,7 @@
+ set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names")
+ set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
+ set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
+-set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a")
++set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".bundle" ".a")
+
+ # hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
+ # (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
diff --git a/dev-util/cmake/files/cmake-3.5.2-FindQt4.patch b/dev-util/cmake/files/cmake-3.5.2-FindQt4.patch
new file mode 100644
index 000000000000..2f2764d30cf6
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.5.2-FindQt4.patch
@@ -0,0 +1,45 @@
+Ensure that the correct version of Qt is always used.
+
+With the introduction qt-4.8.6, Qt binaries were moved from /usr/bin to
+/usr/$(get_libdir)/qt4/bin, leaving behind in their place symlinks to qtchooser.
+
+There is no guarantee to which version of Qt these symlinks might point, so it
+is necessary to find the correct version explicitly.
+
+Once qmake is found, it is queried for the correct location of all other items.
+
+Gentoo-bug: 547222
+
+--- a/Modules/FindQt4.cmake
++++ b/Modules/FindQt4.cmake
+@@ -482,13 +482,23 @@
+
+ get_filename_component(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
+
+- find_program(QT_QMAKE_EXECUTABLE NAMES ${QMAKE_NAME}
+- PATHS
+- ENV QTDIR
+- "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]"
+- PATH_SUFFIXES bin
+- DOC "The qmake executable for the Qt installation to use"
+- )
++ if(CMAKE_GENTOO_BUILD OR CMAKE_BUILD_TYPE STREQUAL Gentoo)
++ find_program(QT_QMAKE_EXECUTABLE NAMES ${QMAKE_NAME}
++ PATHS
++ $ENV{EPREFIX}/usr/${CMAKE_INSTALL_LIBDIR}/qt4/bin
++ $ENV{EPREFIX}/usr/bin
++ NO_DEFAULT_PATH
++ DOC "The qmake executable for the Qt installation to use"
++ )
++ else()
++ find_program(QT_QMAKE_EXECUTABLE NAMES ${QMAKE_NAME}
++ PATHS
++ ENV QTDIR
++ "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]"
++ PATH_SUFFIXES bin
++ DOC "The qmake executable for the Qt installation to use"
++ )
++ endif()
+
+ set(major 0)
+ if (QT_QMAKE_EXECUTABLE)
diff --git a/dev-util/cmake/files/cmake-3.8.0_rc2-FindBoost-python.patch b/dev-util/cmake/files/cmake-3.8.0_rc2-FindBoost-python.patch
new file mode 100644
index 000000000000..441650b72a2a
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.8.0_rc2-FindBoost-python.patch
@@ -0,0 +1,95 @@
+From 7d3a5c466bf14a0c12edc6ece359012b723e39bc Mon Sep 17 00:00:00 2001
+From: Michael Palimaka <kensington@gentoo.org>
+Date: Thu, 23 Mar 2017 11:36:39 +0100
+Subject: [PATCH] Fix detection of PYTHON_ABI-versioned Boost Python libraries
+
+Gentoo-bug: 400969
+Gentoo-bug: 613442
+---
+ Modules/FindBoost.cmake | 42 ++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 42 insertions(+)
+
+diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
+index e795aadcc..11269c30b 100644
+--- a/Modules/FindBoost.cmake
++++ b/Modules/FindBoost.cmake
+@@ -1481,6 +1481,16 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ set( _boost_docstring_release "Boost ${COMPONENT} library (release)")
+ set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)")
+
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ # If a certain version of python has already been selected ensure we select the corresponding boost python version.
++ if(PYTHON_EXECUTABLE)
++ set(GENTOO_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}")
++ else()
++ set(GENTOO_PYTHON_EXECUTABLE "python")
++ endif()
++ execute_process(COMMAND "${GENTOO_PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write('.'.join(str(x) for x in sys.version_info[:2]))" OUTPUT_VARIABLE _python_version)
++ endif()
++
+ # Compute component-specific hints.
+ set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
+ if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR
+@@ -1529,6 +1539,15 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ list(APPEND _boost_RELEASE_NAMES
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version} )
++ endif()
++
+ if(_boost_STATIC_RUNTIME_WORKAROUND)
+ set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
+ list(APPEND _boost_RELEASE_NAMES
+@@ -1536,6 +1555,13 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ list(APPEND _boost_RELEASE_NAMES
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
++ endif()
+ endif()
+ if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
+ _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES})
+@@ -1571,6 +1597,15 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ list(APPEND _boost_DEBUG_NAMES
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version} )
++ endif()
+ if(_boost_STATIC_RUNTIME_WORKAROUND)
+ set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
+ list(APPEND _boost_DEBUG_NAMES
+@@ -1578,6 +1613,13 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
++ if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python")
++ list(APPEND _boost_DEBUG_NAMES
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
++ ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_python_version}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
++ endif()
+ endif()
+ if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
+ _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES})
+--
+2.12.1
+
diff --git a/dev-util/cmake/files/cmake-3.9.0_rc2-FindImageMagick.patch b/dev-util/cmake/files/cmake-3.9.0_rc2-FindImageMagick.patch
new file mode 100644
index 000000000000..ce63988f2ec8
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.9.0_rc2-FindImageMagick.patch
@@ -0,0 +1,47 @@
+From f51ccd38ed85e5799b2f0a88829eb6a40574ab05 Mon Sep 17 00:00:00 2001
+From: Lars Wendler <polynomial-c@gentoo.org>
+Date: Fri, 9 Jun 2017 02:07:11 +0200
+Subject: [PATCH] Find more variants of ImageMagick
+
+---
+ Modules/FindImageMagick.cmake | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake
+index 7d5534bc2..488d7e0bf 100644
+--- a/Modules/FindImageMagick.cmake
++++ b/Modules/FindImageMagick.cmake
+@@ -196,24 +196,30 @@ foreach(component ${ImageMagick_FIND_COMPONENTS}
+ if(component STREQUAL "Magick++")
+ FIND_IMAGEMAGICK_API(Magick++ Magick++.h
+ Magick++ CORE_RL_Magick++_
++ Magick++-6.Q64 Magick++-6.Q64HDRI Magick++-6.Q32 Magick++-6.Q32HDRI
+ Magick++-Q8 Magick++-Q16 Magick++-Q16HDRI Magick++-Q8HDRI
+ Magick++-6.Q16 Magick++-6.Q8 Magick++-6.Q16HDRI Magick++-6.Q8HDRI
++ Magick++-7.Q64 Magick++-7.Q64HDRI Magick++-7.Q32 Magick++-7.Q32HDRI
+ Magick++-7.Q16 Magick++-7.Q8 Magick++-7.Q16HDRI Magick++-7.Q8HDRI
+ )
+ list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_Magick++_LIBRARY)
+ elseif(component STREQUAL "MagickWand")
+ FIND_IMAGEMAGICK_API(MagickWand "wand/MagickWand.h;MagickWand/MagickWand.h"
+ Wand MagickWand CORE_RL_wand_
++ MagickWand-6.Q64 MagickWand-6.Q64HDRI MagickWand-6.Q32 MagickWand-6.Q32HDRI
+ MagickWand-Q16 MagickWand-Q8 MagickWand-Q16HDRI MagickWand-Q8HDRI
+ MagickWand-6.Q16 MagickWand-6.Q8 MagickWand-6.Q16HDRI MagickWand-6.Q8HDRI
++ MagickWand-7.Q64 MagickWand-7.Q64HDRI MagickWand-7.Q32 MagickWand-7.Q32HDRI
+ MagickWand-7.Q16 MagickWand-7.Q8 MagickWand-7.Q16HDRI MagickWand-7.Q8HDRI
+ )
+ list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickWand_LIBRARY)
+ elseif(component STREQUAL "MagickCore")
+ FIND_IMAGEMAGICK_API(MagickCore "magick/MagickCore.h;MagickCore/MagickCore.h"
+ Magick MagickCore CORE_RL_magick_
++ MagickCore-6.Q64 MagickCore-6.Q64HDRI MagickCore-6.Q32 MagickCore-6.Q32HDRI
+ MagickCore-Q16 MagickCore-Q8 MagickCore-Q16HDRI MagickCore-Q8HDRI
+ MagickCore-6.Q16 MagickCore-6.Q8 MagickCore-6.Q16HDRI MagickCore-6.Q8HDRI
++ MagickCore-7.Q64 MagickCore-7.Q64HDRI MagickCore-7.Q32 MagickCore-7.Q32HDRI
+ MagickCore-7.Q16 MagickCore-7.Q8 MagickCore-7.Q16HDRI MagickCore-7.Q8HDRI
+ )
+ list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickCore_LIBRARY)
+--
+2.13.1
+
diff --git a/dev-util/cmake/files/cmake-3.9.0_rc2-FindPythonInterp.patch b/dev-util/cmake/files/cmake-3.9.0_rc2-FindPythonInterp.patch
new file mode 100644
index 000000000000..242392d8520e
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.9.0_rc2-FindPythonInterp.patch
@@ -0,0 +1,43 @@
+From 325652950ecc5d72f0a6ac843889a048fe9e32cf Mon Sep 17 00:00:00 2001
+From: Lars Wendler <polynomial-c@gentoo.org>
+Date: Fri, 9 Jun 2017 02:08:03 +0200
+Subject: [PATCH] Don't mess with python versions too much
+
+---
+ Modules/FindPythonInterp.cmake | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake
+index 64b98a879..73bd35b56 100644
+--- a/Modules/FindPythonInterp.cmake
++++ b/Modules/FindPythonInterp.cmake
+@@ -64,6 +64,11 @@ if(PythonInterp_FIND_VERSION)
+ else()
+ set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
+ endif()
++
++if (CMAKE_GENTOO_BUILD OR CMAKE_BUILD_TYPE STREQUAL Gentoo)
++ set(_Python_NAMES python)
++endif()
++
+ find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES})
+
+ # Set up the versions we know about, in the order we will search. Always add
+@@ -88,12 +93,13 @@ unset(_PYTHON2_VERSIONS)
+ unset(_PYTHON3_VERSIONS)
+
+ # Search for newest python version if python executable isn't found
+-if(NOT PYTHON_EXECUTABLE)
++if(NOT PYTHON_EXECUTABLE AND NOT (CMAKE_GENTOO_BUILD OR CMAKE_BUILD_TYPE STREQUAL Gentoo))
+ foreach(_CURRENT_VERSION IN LISTS _Python_VERSIONS)
+ set(_Python_NAMES python${_CURRENT_VERSION})
+ if(CMAKE_HOST_WIN32)
+ list(APPEND _Python_NAMES python)
+ endif()
++
+ find_program(PYTHON_EXECUTABLE
+ NAMES ${_Python_NAMES}
+ PATHS
+--
+2.13.1
+
diff --git a/dev-util/cmake/files/cmake-3.9.0_rc2-prefix-dirs.patch b/dev-util/cmake/files/cmake-3.9.0_rc2-prefix-dirs.patch
new file mode 100644
index 000000000000..f4e9a27597cf
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.9.0_rc2-prefix-dirs.patch
@@ -0,0 +1,126 @@
+From b1f045122fb210728081ae2165197aebff4ee498 Mon Sep 17 00:00:00 2001
+From: Lars Wendler <polynomial-c@gentoo.org>
+Date: Fri, 9 Jun 2017 01:47:55 +0200
+Subject: [PATCH] Set some proper paths to make cmake find our tools.
+
+The ebuild now adds an extra / at the end of $EPREFIX so that it is
+never the empty string (so that CMAKE_SYSTEM_PREFIX_PATH remains
+correct)
+
+Original patch by Heiko Przybyl.
+Updated by Chris Reffett (cmake-2.8.8)
+Updated by Johannes Huber (cmake-2.8.9)
+Updated by Michael Palimaka (cmake-2.8.10)
+Updated by Chris Reffett (cmake-2.8.11)
+Updated by Michael Palimaka (cmake-3.0.0)
+Updated by Lars Wendler (cmake-3.9.0_rc2)
+---
+ Modules/Platform/Darwin.cmake | 12 ++++++++----
+ Modules/Platform/UnixPaths.cmake | 29 ++++++++++++++++++++++++-----
+ 2 files changed, 32 insertions(+), 9 deletions(-)
+
+diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
+index 727baa6e1..543d9e034 100644
+--- a/Modules/Platform/Darwin.cmake
++++ b/Modules/Platform/Darwin.cmake
+@@ -108,9 +108,9 @@ set(CMAKE_C_FRAMEWORK_SEARCH_FLAG -F)
+ set(CMAKE_CXX_FRAMEWORK_SEARCH_FLAG -F)
+ set(CMAKE_Fortran_FRAMEWORK_SEARCH_FLAG -F)
+
+-# default to searching for frameworks first
++# default to searching for frameworks last
+ if(NOT DEFINED CMAKE_FIND_FRAMEWORK)
+- set(CMAKE_FIND_FRAMEWORK FIRST)
++ set(CMAKE_FIND_FRAMEWORK LAST)
+ endif()
+
+ # Older OS X linkers do not report their framework search path
+@@ -132,6 +132,8 @@ endif()
+
+ # set up the default search directories for frameworks
+ set(CMAKE_SYSTEM_FRAMEWORK_PATH
++ @GENTOO_PORTAGE_EPREFIX@Frameworks
++ @GENTOO_PORTAGE_EPREFIX@usr/lib
+ ~/Library/Frameworks
+ )
+ if(_CMAKE_OSX_SYSROOT_PATH)
+@@ -178,13 +180,15 @@ if(CMAKE_OSX_SYSROOT)
+ endif()
+ endif()
+
+-# default to searching for application bundles first
++# default to searching for application bundles last
+ if(NOT DEFINED CMAKE_FIND_APPBUNDLE)
+- set(CMAKE_FIND_APPBUNDLE FIRST)
++ set(CMAKE_FIND_APPBUNDLE LAST)
+ endif()
+ # set up the default search directories for application bundles
+ set(_apps_paths)
+ foreach(_path
++ @GENTOO_PORTAGE_EPREFIX@Applications
++ @GENTOO_PORTAGE_EPREFIX@usr/bin
+ "~/Applications"
+ "/Applications"
+ "${OSX_DEVELOPER_ROOT}/../Applications" # Xcode 4.3+
+diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
+index 5687653cf..be7695898 100644
+--- a/Modules/Platform/UnixPaths.cmake
++++ b/Modules/Platform/UnixPaths.cmake
+@@ -23,6 +23,7 @@ get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
+ # search types.
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
+ # Standard
++ @GENTOO_PORTAGE_EPREFIX@usr/local @GENTOO_PORTAGE_EPREFIX@usr @GENTOO_PORTAGE_EPREFIX@
+ /usr/local /usr /
+
+ # CMake install location
+@@ -50,23 +51,41 @@ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
+
+ # List common include file locations not under the common prefixes.
+ list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
+- # X11
+- /usr/include/X11
++ @GENTOO_PORTAGE_EPREFIX@usr/include
+ )
+
+ list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
+- # X11
+- /usr/lib/X11
++ @GENTOO_PORTAGE_GCCLIBDIR@/gcc
++ @GENTOO_PORTAGE_GCCLIBDIR@
++ @GENTOO_PORTAGE_EPREFIX@usr/lib64
++ @GENTOO_PORTAGE_EPREFIX@usr/libx32
++ @GENTOO_PORTAGE_EPREFIX@usr/lib32
++ @GENTOO_PORTAGE_EPREFIX@usr/lib
++ @GENTOO_PORTAGE_EPREFIX@lib
++ )
++
++list(APPEND CMAKE_SYSTEM_PROGRAM_PATH
++ @GENTOO_PORTAGE_EPREFIX@usr/bin
++ @GENTOO_PORTAGE_EPREFIX@bin
+ )
+
+ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
+- /lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
++ @GENTOO_PORTAGE_GCCLIBDIR@/gcc
++ @GENTOO_PORTAGE_GCCLIBDIR@
++ @GENTOO_PORTAGE_EPREFIX@usr/lib64
++ @GENTOO_PORTAGE_EPREFIX@usr/libx32
++ @GENTOO_PORTAGE_EPREFIX@usr/lib32
++ @GENTOO_PORTAGE_EPREFIX@usr/lib
++ @GENTOO_PORTAGE_EPREFIX@lib
++ /lib /usr/lib /usr/lib32 /usr/lib64 /usr/libx32
+ )
+
+ list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
++ @GENTOO_PORTAGE_EPREFIX@usr/include
+ /usr/include
+ )
+ list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
++ @GENTOO_PORTAGE_EPREFIX@usr/include
+ /usr/include
+ )
+
+--
+2.13.1
+
diff --git a/dev-util/cmake/files/cmake.vim b/dev-util/cmake/files/cmake.vim
new file mode 100644
index 000000000000..5cecd7d05b64
--- /dev/null
+++ b/dev-util/cmake/files/cmake.vim
@@ -0,0 +1,3 @@
+autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in runtime! indent/cmake.vim
+autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in setf cmake
+autocmd BufRead,BufNewFile *.ctest,*.ctest.in setf cmake