From c91551b33ba76377bd541170e861604d40fcefe8 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 7 Feb 2016 15:45:56 +0100 Subject: [PATCH] improved python detection in CMakeLists.txt (fixes #98) --- CMakeLists.txt | 2 ++ docs/cmake.rst | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30f278223..c6c05523e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,8 @@ if (NOT ${PYBIND11_PYTHON_VERSION} STREQUAL "") else() find_package(PythonLibs REQUIRED) endif() +# The above sometimes returns version numbers like "3.4.3+"; the "+" must be removed for the next line to work +string(REPLACE "+" "" PYTHONLIBS_VERSION_STRING "+${PYTHONLIBS_VERSION_STRING}") find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} EXACT REQUIRED) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") diff --git a/docs/cmake.rst b/docs/cmake.rst index eb1f88544..238132f95 100644 --- a/docs/cmake.rst +++ b/docs/cmake.rst @@ -38,6 +38,9 @@ and that the pybind11 repository is located in a subdirectory named :file:`pybin find_package(PythonLibs REQUIRED) endif() + # The above sometimes returns version numbers like "3.4.3+"; the "+" must be removed for the next lines to work + string(REPLACE "+" "" PYTHONLIBS_VERSION_STRING "+${PYTHONLIBS_VERSION_STRING}") + # Uncomment the following line if you will also require a matching Python interpreter # find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} EXACT REQUIRED)