diff options
author | philkr <philkr@users.noreply.github.com> | 2015-02-17 10:50:12 -0800 |
---|---|---|
committer | philkr <philkr@users.noreply.github.com> | 2015-02-24 14:06:36 -0800 |
commit | 54037d3942647ff3659028e1d7437f2e8f7cf911 (patch) | |
tree | 0fc3d12c933c3970f9e47f1c1f29d01492fc1f9d /cmake | |
parent | 682d9da0dba98788dd01723a16a257df4382376c (diff) | |
download | caffeonacl-54037d3942647ff3659028e1d7437f2e8f7cf911.tar.gz caffeonacl-54037d3942647ff3659028e1d7437f2e8f7cf911.tar.bz2 caffeonacl-54037d3942647ff3659028e1d7437f2e8f7cf911.zip |
Making python3 work with cmake and the new python wrapper
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Dependencies.cmake | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index aa2dcbe1..b1ac96c6 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -92,12 +92,39 @@ endif() # ---[ Python if(BUILD_python) - # disable Python 3 search - find_package(PythonInterp 2.7) - find_package(PythonLibs 2.7) - find_package(NumPy 1.7.1) - find_package(Boost 1.46 COMPONENTS python) - + if(NOT "${python_version}" VERSION_LESS "3.0.0") + # use python3 + find_package(PythonInterp 3.0) + find_package(PythonLibs 3.0) + find_package(NumPy 1.7.1) + # Find the matching boost python implementation + set(version ${PYTHONLIBS_VERSION_STRING}) + + STRING( REPLACE "." "" boost_py_version ${version} ) + find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}") + set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND}) + + while(NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND) + STRING( REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version} ) + STRING( REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version} ) + if("${has_more_version}" STREQUAL "") + break() + endif() + + STRING( REPLACE "." "" boost_py_version ${version} ) + find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}") + set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND}) + endwhile() + if(NOT Boost_PYTHON_FOUND) + find_package(Boost 1.46 COMPONENTS python) + endif() + else() + # disable Python 3 search + find_package(PythonInterp 2.7) + find_package(PythonLibs 2.7) + find_package(NumPy 1.7.1) + find_package(Boost 1.46 COMPONENTS python) + endif() if(PYTHONLIBS_FOUND AND NUMPY_FOUND AND Boost_PYTHON_FOUND) set(HAVE_PYTHON TRUE) endif() |