summaryrefslogtreecommitdiff
path: root/community/freeorion/cmake_python.patch
blob: b875fa84416282d43a4b9d44a216308cde808f3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
--- a/client/AI/CMakeLists.txt	2012-09-10 00:11:18.659341865 +0200
+++ b/client/AI/CMakeLists.txt	2012-09-10 00:12:37.659345189 +0200
@@ -33,6 +33,20 @@
 find_package(PythonLibs)
 if (PYTHONLIBS_FOUND)
     include_directories(${PYTHON_INCLUDE_PATH})
+    SET(_VERSION_REGEX
+      "^#define[ \t]+PY([A-Z_]*_VERSION)[ \t]+[\"]*([0-9A-Za-z\\.]+)[\"]*[ \t]*$")
+    FILE(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" _VERSION_STRINGS
+       LIMIT_COUNT 10 REGEX ${_VERSION_REGEX})
+    FOREACH(_VERSION_STRING ${_VERSION_STRINGS})
+        STRING(REGEX REPLACE ${_VERSION_REGEX} "PYTHON\\1"
+           _VERSION_VARIABLE "${_VERSION_STRING}")
+        STRING(REGEX REPLACE ${_VERSION_REGEX} "\\2"
+           _VERSION_NUMBER "${_VERSION_STRING}")
+        SET(${_VERSION_VARIABLE} ${_VERSION_NUMBER})
+    ENDFOREACH(_VERSION_STRING ${_VERSION_STRINGS})
+    IF(PYTHON_MAJOR_VERSION EQUAL 3)
+        MESSAGE(FATAL_ERROR "Python 3 is not supported!")
+    ENDIF()
 else ()
     message(FATAL_ERROR " library not found.")
 endif ()