diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2016-02-28 22:35:47 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2016-02-28 22:35:47 +0100 |
commit | adc657ebcd01ecc2cc5f110453ef00dffde2d5c0 (patch) | |
tree | e25ed33b2608ccebc7b88c5738d4aa68a7d522b5 /CMakeLists.txt | |
parent | 631f0929c155087648acdd00ef0e2039737f8803 (diff) | |
download | pcitool-adc657ebcd01ecc2cc5f110453ef00dffde2d5c0.tar.gz pcitool-adc657ebcd01ecc2cc5f110453ef00dffde2d5c0.tar.bz2 pcitool-adc657ebcd01ecc2cc5f110453ef00dffde2d5c0.tar.xz pcitool-adc657ebcd01ecc2cc5f110453ef00dffde2d5c0.zip |
Altenrative way to detect location where python modules should be installed
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ee73a1a..cd889f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,22 @@ find_package(Threads REQUIRED) if (NOT DISABLE_PYTHON) find_package(PythonLibs 2.7 REQUIRED) + find_package(PythonInterp 2.7 REQUIRED) find_package(SWIG REQUIRED) + if (NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING) + message (FATAL_ERROR "Version mismatch between python interpreter and libraries") + endif (NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING) + +# execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "from sysconfig import get_path; print get_path('platlib')" OUTPUT_VARIABLE PYTHON_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "import site; print site.PREFIXES[-1]" OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) + file (TO_CMAKE_PATH "${PYTHON_PREFIX}" PYTHON_PREFIX) + execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "import site; print site.getsitepackages()[-1]" OUTPUT_VARIABLE PYTHON_SITE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + file (TO_CMAKE_PATH "${PYTHON_SITE_DIR}" PYTHON_SITE_DIR) + + string (REGEX REPLACE "^${PYTHON_PREFIX}/" "${CMAKE_INSTALL_PREFIX}/" PYTHON_SITE_DIR "${PYTHON_SITE_DIR}") + set(PYTHON_INSTALL_DIR ${PYTHON_SITE_DIR} CACHE PATH "path to install python module") + set(HAVE_PYTHON TRUE) endif (NOT DISABLE_PYTHON) |