From cb7937f8000fb509486432f66f319e33a9d85400 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 14 Apr 2017 06:54:47 +0000 Subject: Try of a fix for Windows cython find mechanism git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2347 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4c93e7042d79bfea7c758e726f6393b97334c798 --- src/cmake/modules/FindCython.cmake | 44 +++++++++++++++++++++++ src/cmake/modules/GUDHI_third_party_libraries.txt | 19 +++------- src/cython/CMakeLists.txt | 6 ++-- 3 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 src/cmake/modules/FindCython.cmake diff --git a/src/cmake/modules/FindCython.cmake b/src/cmake/modules/FindCython.cmake new file mode 100644 index 00000000..04aed1f8 --- /dev/null +++ b/src/cmake/modules/FindCython.cmake @@ -0,0 +1,44 @@ +# Find the Cython compiler. +# +# This code sets the following variables: +# +# CYTHON_EXECUTABLE +# +# See also UseCython.cmake + +#============================================================================= +# Copyright 2011 Kitware, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +# Use the Cython executable that lives next to the Python executable +# if it is a local installation. +find_package( PythonInterp ) +if( PYTHONINTERP_FOUND ) + get_filename_component( _python_path ${PYTHON_EXECUTABLE} PATH ) + find_program( CYTHON_EXECUTABLE + NAMES cython cython.bat cython3 + HINTS ${_python_path} + ) +else() + find_program( CYTHON_EXECUTABLE + NAMES cython cython.bat cython3 + ) +endif() + + +include( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( Cython REQUIRED_VARS CYTHON_EXECUTABLE ) + +mark_as_advanced( CYTHON_EXECUTABLE ) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.txt b/src/cmake/modules/GUDHI_third_party_libraries.txt index 2ddc9f1f..5f84c602 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.txt +++ b/src/cmake/modules/GUDHI_third_party_libraries.txt @@ -121,33 +121,24 @@ endmacro( find_the_lib ) # Find the correct Python interpreter. # Can be set with -DPYTHON_EXECUTABLE=/usr/bin/python3 or -DPython_ADDITIONAL_VERSIONS=3 for instance. -if(PYTHON_EXECUTABLE) - if(NOT EXISTS "${PYTHON_EXECUTABLE}") - message(FATAL_ERROR "ERROR: ${PYTHON_EXECUTABLE} does not exist.") - endif(NOT EXISTS "${PYTHON_EXECUTABLE}") -endif(PYTHON_EXECUTABLE) -find_package(PythonInterp) +find_package(Cython) if(NOT GUDHI_CYTHON_PATH) message(FATAL_ERROR "ERROR: GUDHI_CYTHON_PATH is not valid.") endif(NOT GUDHI_CYTHON_PATH) -if(PYTHONINTERP_FOUND) +if(PYTHONINTERP_FOUND AND CYTHON_FOUND) + # Unitary tests are available through py.test + find_program( PYTEST_PATH py.test ) # Default found version 2 if(PYTHON_VERSION_MAJOR EQUAL 2) - FIND_PROGRAM(CYTHON_PATH cython) - # Unitary tests are available through py.test - find_program( PYTEST_PATH py.test ) # Documentation generation is available through sphinx find_program( SPHINX_PATH sphinx-build ) elseif(PYTHON_VERSION_MAJOR EQUAL 3) - FIND_PROGRAM(CYTHON_PATH cython3) - # Unitary tests are available through py.test - find_program( PYTEST_PATH py.test ) # Documentation generation is available through sphinx set(SPHINX_PATH "${CMAKE_SOURCE_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") else() message(FATAL_ERROR "ERROR: Try to compile the Cython interface. Python version ${PYTHON_VERSION_STRING} is not valid.") endif(PYTHON_VERSION_MAJOR EQUAL 2) -endif(PYTHONINTERP_FOUND) +endif(PYTHONINTERP_FOUND AND CYTHON_FOUND) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 51c208aa..96c2acb3 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 2.8) project(Cython) -if(CYTHON_PATH) - message("${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_PATH} - py.test is ${PYTEST_PATH} - Sphinx is ${SPHINX_PATH}") +if(CYTHON_FOUND) + message("++ ${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_EXECUTABLE} - py.test is ${PYTEST_PATH} - Sphinx is ${SPHINX_PATH}") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_RESULT_OF_USE_DECLTYPE', ") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_ALL_NO_LIB', ") @@ -281,4 +281,4 @@ if(CYTHON_PATH) COMMAND make.bat html doctest) endif (UNIX) endif(SPHINX_PATH) -endif(CYTHON_PATH) +endif(CYTHON_FOUND) -- cgit v1.2.3