Last active
August 29, 2015 14:08
-
-
Save mic-e/01151d6fc08467d58577 to your computer and use it in GitHub Desktop.
minimal cmake python test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# testing instructions: | |
# - save this file as /tmp/x/CMakeLists.txt | |
# - cd /tmp/x | |
# - cmake . | |
# - paste output and your distro version in comments | |
cmake_minimum_required(VERSION 2.8) | |
# cmake 2.8 doesn't know about python3.4 | |
set(Python_ADDITIONAL_VERSIONS 3.4) | |
# find py libs | |
find_package(PythonLibs 3.3 REQUIRED) | |
message("PYTHON_LIBRARY: ${PYTHON_LIBRARY}") | |
message("PYTHON_INCLUDE_DIR: ${PYTHON_INCLUDE_DIR}") | |
message("PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING}") | |
# on some distros (ubuntu 13.10) there seems to be additional clutter at the end, | |
# which needs to be stripped to prevent find_package(PythonInterp) from erroring. | |
if(PYTHONLIBS_VERSION_STRING MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)([^0-9].*)?$") | |
set(PYTHON_SANITIZED_VERSION "${CMAKE_MATCH_1}") | |
else() | |
message(WARNING "PYTHONLIBS_VERSION_STRING is ${PYTHONLIBS_VERSION_STRING}, expected major.minor.patch*") | |
set(PYTHON_SANITIZED_VERSION "${PYTHONLIBS_VERSION_STRING}") | |
endif() | |
message("PYTHON_SANITIZED_VERSION: ${PYTHON_SANITIZED_VERSION}") | |
# find python interpreter with the exact version of the chosen pythonlibs | |
find_package(PythonInterp "${PYTHON_SANITIZED_VERSION}" EXACT REQUIRED) | |
message("PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}") | |
message("PYTHON_VERSION_STRING: ${PYTHON_VERSION_STRING}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
distro details below -
script output below