diff options
author | Jon Long <jonlong@cs.berkeley.edu> | 2015-02-24 15:00:58 -0800 |
---|---|---|
committer | Jon Long <jonlong@cs.berkeley.edu> | 2015-02-24 15:00:58 -0800 |
commit | b915f9d2bb3b198c0e219c88ee974757e58d258a (patch) | |
tree | cf6f5e0bf59eb7cf36171b6ab8939e559b17c856 /cmake | |
parent | 360dbfd492772852fd9d00184520c9543918ec60 (diff) | |
parent | 54037d3942647ff3659028e1d7437f2e8f7cf911 (diff) | |
download | caffeonacl-b915f9d2bb3b198c0e219c88ee974757e58d258a.tar.gz caffeonacl-b915f9d2bb3b198c0e219c88ee974757e58d258a.tar.bz2 caffeonacl-b915f9d2bb3b198c0e219c88ee974757e58d258a.zip |
Merge pull request #1923 from philkr/python3_master
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() |