From b783b0f10c9b83a348d479015affb4106cb258f1 Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 28 Apr 2009 14:35:24 +0000 Subject: [PATCH] When WITH_PYTHON is used, PYTHON_EXECUTABLE must be set --- salome_adm/cmake_files/FindPYTHON.cmake | 62 ++++++++++++++++++------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/salome_adm/cmake_files/FindPYTHON.cmake b/salome_adm/cmake_files/FindPYTHON.cmake index f1215749d..9d9934c33 100644 --- a/salome_adm/cmake_files/FindPYTHON.cmake +++ b/salome_adm/cmake_files/FindPYTHON.cmake @@ -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) -- 2.39.2