Permalink
Browse files

fix python libpath/includepath when multiple versions are installed

related to #4617
  • Loading branch information...
tbonfort committed Apr 9, 2013
1 parent 5faee46 commit 68182822de3491d76fcd29de11643a2f4b4ef7cc
Showing with 24 additions and 1 deletion.
  1. +24 −1 mapscript/python/CMakeLists.txt
@@ -1,7 +1,30 @@
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
FIND_PACKAGE(PythonLibs)
FIND_PACKAGE(PythonInterp)
# Python library/header finding doesn't seem to honor the python
# interpreter that was found beforehand, and defaults to the system
# python. We first try to find python.h and libpython.so ourselves
# from the hints given by distutils and sys
execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_inc; print get_python_inc(True)" OUTPUT_VARIABLE PYTHON_INC OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print sys.prefix" OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
find_path(PYTHON_INCLUDE_PATH Python.h
HINTS ${PYTHON_INC}
)
find_library(PYTHON_LIBRARIES
NAMES python${PYTHON_VERSION_STRING} python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} python
HINTS ${PYTHON_PREFIX}/lib
)
#if that failed, fall back to the default cmake method of finding python dev files
if(NOT PYTHON_INCLUDE_PATH OR NOT PYTHON_LIBRARIES)
FIND_PACKAGE(PythonLibs)
endif(NOT PYTHON_INCLUDE_PATH OR NOT PYTHON_LIBRARIES)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
include_directories(${PROJECT_SOURCE_DIR}/mapscript/swiginc)
include_directories(${PROJECT_SOURCE_DIR}/mapscript/)

0 comments on commit 6818282

Please sign in to comment.