summaryrefslogtreecommitdiff
blob: 2a83ff7abb69de8dcf1472c1e8c4bbac03354c1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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_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)