]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
When WITH_PYTHON is used, PYTHON_EXECUTABLE must be set
authoradam <adam>
Tue, 28 Apr 2009 14:35:24 +0000 (14:35 +0000)
committeradam <adam>
Tue, 28 Apr 2009 14:35:24 +0000 (14:35 +0000)
salome_adm/cmake_files/FindPYTHON.cmake

index f1215749de83e8414027d5ba63c5fd8338e45d91..9d9934c335b8f8b51ed2aa1f0ba59c27e6100b91 100644 (file)
@@ -63,29 +63,55 @@ ENDIF(PYTHON_STATUS)
 # ------
 
 IF(PYTHON_STATUS)
+  IF(PYTHON_ROOT_USER)
+    SET(PYTHON_FIND_PATHS_OPTION NO_DEFAULT_PATH)
+  ELSE(PYTHON_ROOT_USER)
+    SET(PYTHON_FIND_PATHS_OPTION)
+  ENDIF(PYTHON_ROOT_USER)
+ENDIF(PYTHON_STATUS)
+
+# ------
+
+IF(PYTHON_STATUS)
+  IF(WINDOWS)
+    IF(CMAKE_BUILD_TYPE STREQUAL Release)
+      SET(PYTHON_EXECUTABLE_TO_FIND python)
+    ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
+      SET(PYTHON_EXECUTABLE_TO_FIND python_d)
+    ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
+  ELSE(WINDOWS)
+    SET(PYTHON_EXECUTABLE_TO_FIND python)
+  ENDIF(WINDOWS)
   IF(NOT PYTHON_ROOT_USER)
+    SET(PYTHON_EXECUTABLE_PATHS)
+  ELSE(NOT PYTHON_ROOT_USER)
     IF(WINDOWS)
-      IF(CMAKE_BUILD_TYPE STREQUAL Release)
-       FIND_PROGRAM(PYTHON_EXECUTABLE python)
-      ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
-       FIND_PROGRAM(PYTHON_EXECUTABLE python_d)
-      ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
+      SET(PYTHON_EXECUTABLE_PATHS ${PYTHON_ROOT_USER} ${PYTHON_ROOT_USER}/bin ${PYTHON_ROOT_USER}/PCbuild)
     ELSE(WINDOWS)
-      FIND_PROGRAM(PYTHON_EXECUTABLE python)
+      SET(PYTHON_EXECUTABLE_PATHS ${PYTHON_ROOT_USER}/bin)
     ENDIF(WINDOWS)
-    IF(PYTHON_EXECUTABLE)
-      MESSAGE(STATUS "python found: ${PYTHON_EXECUTABLE}")
-      IF(PYTHON_EXECUTABLE STREQUAL /usr/bin/python)
-      ELSE(PYTHON_EXECUTABLE STREQUAL /usr/bin/python)
-       SET(PYTHON_ROOT_USER ${PYTHON_EXECUTABLE})
+  ENDIF(NOT PYTHON_ROOT_USER)
+  FIND_PROGRAM(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE_TO_FIND} PATHS ${PYTHON_EXECUTABLE_PATHS} ${PYTHON_FIND_PATHS_OPTION})
+  IF(PYTHON_EXECUTABLE)
+    MESSAGE(STATUS "python found: ${PYTHON_EXECUTABLE}")
+    IF(PYTHON_EXECUTABLE STREQUAL /usr/bin/python)
+    ELSE(PYTHON_EXECUTABLE STREQUAL /usr/bin/python)
+      SET(PYTHON_ROOT_USER ${PYTHON_EXECUTABLE})
+      IF(PYTHON_EXECUTABLE STREQUAL ${PYTHON_ROOT_USER}/${PYTHON_EXECUTABLE_TO_FIND})
        GET_FILENAME_COMPONENT(PYTHON_ROOT_USER ${PYTHON_ROOT_USER} PATH)
+      ELSE(PYTHON_EXECUTABLE STREQUAL ${PYTHON_ROOT_USER}/${PYTHON_EXECUTABLE_TO_FIND})
        GET_FILENAME_COMPONENT(PYTHON_ROOT_USER ${PYTHON_ROOT_USER} PATH)
-      ENDIF(PYTHON_EXECUTABLE STREQUAL /usr/bin/python)
-    ELSE(PYTHON_EXECUTABLE)
-      MESSAGE(STATUS "python not found, try to use WITH_PYTHON option or PYTHONHOME environment variable")
-      SET(PYTHON_STATUS 0)
-    ENDIF(PYTHON_EXECUTABLE)
-  ENDIF(NOT PYTHON_ROOT_USER)
+       GET_FILENAME_COMPONENT(PYTHON_ROOT_USER ${PYTHON_ROOT_USER} PATH)
+      ENDIF(PYTHON_EXECUTABLE STREQUAL ${PYTHON_ROOT_USER}/${PYTHON_EXECUTABLE_TO_FIND})
+    ENDIF(PYTHON_EXECUTABLE STREQUAL /usr/bin/python)
+  ELSE(PYTHON_EXECUTABLE)
+    IF(PYTHON_ROOT_USER)
+      MESSAGE(STATUS "${PYTHON_EXECUTABLE_TO_FIND} not found in ${PYTHON_EXECUTABLE_PATHS}, check your PYTHON installation.")
+    ELSE(PYTHON_ROOT_USER)
+      MESSAGE(STATUS "${PYTHON_EXECUTABLE_TO_FIND} not found on system, try to use WITH_PYTHON option or PYTHON_ROOT environment variable.")
+    ENDIF(PYTHON_ROOT_USER)
+    SET(PYTHON_STATUS 0)
+  ENDIF(PYTHON_EXECUTABLE)
 ENDIF(PYTHON_STATUS)
 
 # ------
@@ -143,7 +169,7 @@ IF(PYTHON_STATUS)
     IF(WINDOWS)
       SET(PYTHON_LIB_PATHS ${PYTHON_ROOT_USER}/libs)
     ELSE(WINDOWS)
-      SET(PYTHON_LIB_PATHS ${PYTHON_ROOT_USER}/lib)
+      SET(PYTHON_LIB_PATHS ${PYTHON_ROOT_USER}/lib ${PYTHON_ROOT_USER}/lib/python${PYTHON_VERSION}/config)
     ENDIF(WINDOWS)
   ELSE(PYTHON_ROOT_USER)
     SET(PYTHON_LIB_PATHS)