# ------
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)
# ------
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)