提交 6cd4b6e0 编写于 作者: L liaogang

Update external libs

上级 280994fa
......@@ -12,14 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
INCLUDE(ExternalProject)
FIND_PACKAGE(NumPy)
SET(NUMPY_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/numpy)
SET(NUMPY_INSTALL_DIR ${PROJECT_BINARY_DIR}/numpy)
set(NUMPY_VERSION "v1.11.3")
IF(NOT ${NUMPY_FOUND})
# setuptools
ExternalProject_Add(setuptools
INCLUDE(ExternalProject)
SET(NUMPY_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/numpy)
SET(NUMPY_INSTALL_DIR ${PROJECT_BINARY_DIR}/numpy)
set(NUMPY_VERSION "v1.11.3")
ExternalProject_Add(setuptools
PREFIX ${PYTHON_SOURCES_DIR}/setuptools
URL http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
URL_MD5 7df2a529a074f613b509fb44feefe74e
......@@ -30,9 +33,9 @@ ExternalProject_Add(setuptools
INSTALL_COMMAND ""
BUILD_COMMAND ${PYTHON_EXECUTABLE} setup.py install
DEPENDS python zlib
)
)
ExternalProject_Add(cython
ExternalProject_Add(cython
PREFIX ${PYTHON_SOURCES_DIR}/cython
GIT_REPOSITORY https://github.com/cython/cython.git
BUILD_IN_SOURCE 1
......@@ -42,9 +45,9 @@ ExternalProject_Add(cython
INSTALL_COMMAND ""
BUILD_COMMAND ${PYTHON_EXECUTABLE} setup.py install
DEPENDS python
)
)
ExternalProject_Add(numpy
ExternalProject_Add(numpy
GIT_REPOSITORY https://github.com/numpy/numpy.git
GIT_TAG ${NUMPY_VERSION}
CONFIGURE_COMMAND ""
......@@ -54,4 +57,19 @@ ExternalProject_Add(numpy
INSTALL_COMMAND ${PYTHON_EXECUTABLE} setup.py install
BUILD_IN_SOURCE 1
DEPENDS python setuptools cython
)
)
# find numpy include directory
FILE(WRITE ${PROJECT_BINARY_DIR}/FindNumpyPath.py
"try: import numpy; print(numpy.get_include())\nexcept:pass\n")
EXEC_PROGRAM("${PYTHON_EXECUTABLE}" ${PROJECT_BINARY_DIR}
ARGS "FindNumpyPath.py"
OUTPUT_VARIABLE NUMPY_PATH)
FIND_PATH(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h
HINTS "${NUMPY_PATH}" "${PYTHON_INCLUDE_PATH}")
INCLUDE_DIRECTORIES(${PYTHON_NUMPY_INCLUDE_DIR})
ENDIF()
......@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# INCLUDE(cblas)
INCLUDE(ExternalProject)
SET(CBLAS_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/openblas)
......
......@@ -12,37 +12,42 @@
# See the License for the specific language governing permissions and
# limitations under the License.
INCLUDE(ExternalProject)
FIND_PACKAGE(PythonLibs 2.7)
FIND_PACKAGE(PythonInterp 2.7)
SET(PYTHON_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/python)
SET(PYTHON_INSTALL_DIR ${PROJECT_BINARY_DIR}/python)
IF((NOT ${PYTHONINTERP_FOUND}) OR (NOT ${PYTHONLIBS_FOUND}))
if(MSVC)
list(APPEND EXTERNAL_PROJECT_OPTIONAL_ARGS
INCLUDE(ExternalProject)
SET(PYTHON_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/python)
SET(PYTHON_INSTALL_DIR ${PROJECT_BINARY_DIR}/python)
IF(MSVC)
LIST(APPEND EXTERNAL_PROJECT_OPTIONAL_ARGS
PATCH_COMMAND ${CMAKE_COMMAND}
-DPYTHON_SRC_DIR:PATH=${_python_SOURCE_DIR}
-P ${CMAKE_CURRENT_LIST_DIR}/PythonPatch.cmake
)
endif()
ENDIF()
if(APPLE)
list(APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS
IF(APPLE)
LIST(APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS
-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON
)
endif()
ENDIF()
set(EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS)
SET(EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS)
# Force Python build to "Release".
if(CMAKE_CONFIGURATION_TYPES)
set(SAVED_CMAKE_CFG_INTDIR ${CMAKE_CFG_INTDIR})
set(CMAKE_CFG_INTDIR "Release")
else()
list(APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
# Force Python build to "Release".
IF(CMAKE_CONFIGURATION_TYPES)
SET(SAVED_CMAKE_CFG_INTDIR ${CMAKE_CFG_INTDIR})
SET(CMAKE_CFG_INTDIR "Release")
ELSE()
LIST(APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Release)
endif()
ENDIF()
ExternalProject_Add(python
ExternalProject_Add(python
GIT_REPOSITORY "https://github.com/python-cmake-buildsystem/python-cmake-buildsystem.git"
GIT_TAG "ed5f9bcee540e47f82fa17f8360b820591aa6d66"
PREFIX ${PYTHON_SOURCES_DIR}
......@@ -60,24 +65,28 @@ ExternalProject_Add(python
${EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS}
${EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS}
DEPENDS zlib
)
)
SET(_python_DIR ${PYTHON_INSTALL_DIR})
IF(UNIX)
SET(_python_IMPORT_SUFFIX a)
IF(APPLE)
SET(_python_IMPORT_SUFFIX lib)
ENDIF()
SET(PYTHON_INCLUDE_DIR "${PYTHON_INSTALL_DIR}/include/python2.7" CACHE PATH "Python include dir" FORCE)
SET(PYTHON_LIBRARIES "${PYTHON_INSTALL_DIR}/lib/libpython2.7.${_python_IMPORT_SUFFIX}" CACHE FILEPATH "Python library" FORCE)
SET(PYTHON_EXECUTABLE ${PYTHON_INSTALL_DIR}/bin/python CACHE FILEPATH "Python executable" FORCE)
SET(PY_SITE_PACKAGES_PATH "${PYTHON_INSTALL_DIR}/lib/python2.7/site-packages" CACHE PATH "Python site-packages path" FORCE)
ELSEIF(WIN32)
SET(PYTHON_INCLUDE_DIR "${PYTHON_INSTALL_DIR}/include" CACHE PATH "Python include dir" FORCE)
SET(PYTHON_LIBRARIES "${PYTHON_INSTALL_DIR}/libs/python27.lib" CACHE FILEPATH "Python library" FORCE)
SET(PYTHON_EXECUTABLE "${PYTHON_INSTALL_DIR}/bin/python.exe" CACHE FILEPATH "Python executable" FORCE)
SET(PY_SITE_PACKAGES_PATH "${PYTHON_INSTALL_DIR}/Lib/site-packages" CACHE PATH "Python site-packages path" FORCE)
ELSE()
MESSAGE(FATAL_ERROR "Unknown system !")
ENDIF()
set(_python_DIR ${PYTHON_INSTALL_DIR})
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
if(UNIX)
set(_python_IMPORT_SUFFIX so)
if(APPLE)
set(_python_IMPORT_SUFFIX dylib)
endif()
set(PYTHON_INCLUDE_DIR "${PYTHON_INSTALL_DIR}/include/python2.7" CACHE PATH "Python include dir" FORCE)
set(PYTHON_LIBRARY "${PYTHON_INSTALL_DIR}/lib/libpython2.7.${_python_IMPORT_SUFFIX}" CACHE FILEPATH "Python library" FORCE)
set(PYTHON_EXECUTABLE ${PYTHON_INSTALL_DIR}/bin/python CACHE FILEPATH "Python executable" FORCE)
set(PY_SITE_PACKAGES_PATH "${PYTHON_INSTALL_DIR}/lib/python2.7/site-packages" CACHE PATH "Python site-packages path" FORCE)
elseif(WIN32)
set(PYTHON_INCLUDE_DIR "${PYTHON_INSTALL_DIR}/include" CACHE PATH "Python include dir" FORCE)
set(PYTHON_LIBRARY "${PYTHON_INSTALL_DIR}/libs/python27.lib" CACHE FILEPATH "Python library" FORCE)
set(PYTHON_EXECUTABLE "${PYTHON_INSTALL_DIR}/bin/python.exe" CACHE FILEPATH "Python executable" FORCE)
set(PY_SITE_PACKAGES_PATH "${PYTHON_INSTALL_DIR}/Lib/site-packages" CACHE PATH "Python site-packages path" FORCE)
else()
message(FATAL_ERROR "Unknown system !")
endif()
ENDIF()
......@@ -13,9 +13,9 @@
# limitations under the License.
# Look for system swig
# FIND_PACKAGE(SWIG)
FIND_PACKAGE(SWIG)
#IF(NOT ${SWIG_FOUND})
IF(NOT ${SWIG_FOUND})
# build swig as an external project
INCLUDE(ExternalProject)
SET(SWIG_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/swig)
......@@ -62,14 +62,28 @@
./configure
--prefix=${SWIG_INSTALL_DIR}
--with-pcre-prefix=${SWIG_INSTALL_DIR}/pcre
--with-python=${PYTHON_EXECUTABLE}
BUILD_COMMAND cd ${SWIG_SOURCES_DIR}/src/swig && make
INSTALL_COMMAND cd ${SWIG_SOURCES_DIR}/src/swig && make install
DEPENDS pcre python
DEPENDS pcre
)
set(SWIG_DIR ${SWIG_INSTALL_DIR}/share/swig/${SWIG_TARGET_VERSION} CACHE FILEPATH "SWIG Directory" FORCE)
set(SWIG_EXECUTABLE ${SWIG_INSTALL_DIR}/bin/swig CACHE FILEPATH "SWIG Executable" FORCE)
ENDIF(WIN32)
#ENDIF()
ENDIF()
FUNCTION(generate_python_api target_name)
ADD_CUSTOM_COMMAND(OUTPUT ${PROJ_ROOT}/paddle/py_paddle/swig_paddle.py
${PROJ_ROOT}/paddle/Paddle_wrap.cxx
${PROJ_ROOT}/paddle/Paddle_wrap.h
COMMAND ${SWIG_EXECUTABLE} -python -c++ -outcurrentdir -I../ api/Paddle.swig
&& mv ${PROJ_ROOT}/paddle/swig_paddle.py ${PROJ_ROOT}/paddle/py_paddle/swig_paddle.py
DEPENDS ${PROJ_ROOT}/paddle/api/Paddle.swig
${PROJ_ROOT}/paddle/api/PaddleAPI.h
WORKING_DIRECTORY ${PROJ_ROOT}/paddle
COMMENT "Generate Python API from swig")
ADD_CUSTOM_TARGET(${target_name} ALL DEPENDS
${PROJ_ROOT}/paddle/Paddle_wrap.cxx
${PROJ_ROOT}/paddle/Paddle_wrap.h
${PROJ_ROOT}/paddle/py_paddle/swig_paddle.py)
ENDFUNCTION(generate_python_api)
......@@ -17,22 +17,29 @@ INCLUDE(ExternalProject)
SET(WARPCTC_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/warpctc)
SET(WARPCTC_INSTALL_DIR ${PROJECT_BINARY_DIR}/warpctc)
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(USE_OMP ON)
ELSE()
SET(USE_OMP OFF)
ENDIF()
ExternalProject_Add(
warpctc
GIT_REPOSITORY "https://github.com/gangliao/warp-ctc.git"
PREFIX ${WARPCTC_SOURCES_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${WARPCTC_INSTALL_DIR}
CMAKE_ARGS -DWITH_GPU=${CUDA_FOUND}
CMAKE_ARGS -DWITH_OMP=${USE_OMP}
)
SET(WARPCTC_INCLUDE_DIR "${WARP_INSTALL_DIR}/include" CACHE PATH "Warp-ctc Directory" FORCE)
INCLUDE_DIRECTORIES(${WARPCTC_INCLUDE_DIR})
IF(WIN32)
set(WARPCTC_LIBRARIES
SET(WARPCTC_LIBRARIES
"${WARPCTC_INSTALL_DIR}/lib/warpctc.dll" CACHE FILEPATH "Warp-ctc Library" FORCE)
ELSE(WIN32)
set(WARPCTC_LIBRARIES
SET(WARPCTC_LIBRARIES
"${WARPCTC_INSTALL_DIR}/lib/libwarpctc.so" CACHE FILEPATH "Warp-ctc Library" FORCE)
ENDIF(WIN32)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册