python.cmake 1.4 KB
Newer Older
L
liaogang 已提交
1
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
X
xuwei06 已提交
2
#
L
liaogang 已提交
3 4 5
# 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
X
xuwei06 已提交
6
#
L
liaogang 已提交
7
# http://www.apache.org/licenses/LICENSE-2.0
X
xuwei06 已提交
8
#
L
liaogang 已提交
9 10 11 12 13 14
# 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.

L
liaogang 已提交
15
INCLUDE(ExternalProject)
16 17 18
INCLUDE(python_module)

FIND_PACKAGE(PythonInterp 2.7)
19 20 21
IF(WITH_PYTHON)
    FIND_PACKAGE(PythonLibs 2.7)
ENDIF(WITH_PYTHON)
22

L
liaogang 已提交
23
SET(py_env "")
X
xuwei06 已提交
24
SET(USE_VIRTUALENV_FOR_TEST 1)
25
IF(PYTHONINTERP_FOUND)
26 27 28 29 30
    find_python_module(pip REQUIRED)
    find_python_module(numpy REQUIRED)
    find_python_module(wheel REQUIRED)
    find_python_module(google.protobuf REQUIRED)
    FIND_PACKAGE(NumPy REQUIRED)
R
reyoung 已提交
31
    IF(${PY_GOOGLE.PROTOBUF_VERSION} AND ${PY_GOOGLE.PROTOBUF_VERSION} VERSION_LESS "3.0.0")
L
liaogang 已提交
32
        MESSAGE(FATAL_ERROR "Found Python Protobuf ${PY_GOOGLE.PROTOBUF_VERSION} < 3.0.0, "
R
reyoung 已提交
33 34
        "please use pip to upgrade protobuf. pip install -U protobuf")
    ENDIF()
35
ENDIF(PYTHONINTERP_FOUND)
L
liaogang 已提交
36

37 38 39 40
IF(WITH_PYTHON)
    INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
    INCLUDE_DIRECTORIES(${PYTHON_NUMPY_INCLUDE_DIR})
ELSE()
L
liaogang 已提交
41
    SET(PYTHON_LIBRARIES "")
L
liaogang 已提交
42
ENDIF()