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

Update external libs

上级 280994fa
...@@ -12,46 +12,64 @@ ...@@ -12,46 +12,64 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) FIND_PACKAGE(NumPy)
SET(NUMPY_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/numpy) IF(NOT ${NUMPY_FOUND})
SET(NUMPY_INSTALL_DIR ${PROJECT_BINARY_DIR}/numpy)
set(NUMPY_VERSION "v1.11.3") INCLUDE(ExternalProject)
# setuptools SET(NUMPY_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/numpy)
ExternalProject_Add(setuptools SET(NUMPY_INSTALL_DIR ${PROJECT_BINARY_DIR}/numpy)
PREFIX ${PYTHON_SOURCES_DIR}/setuptools set(NUMPY_VERSION "v1.11.3")
URL http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
URL_MD5 7df2a529a074f613b509fb44feefe74e ExternalProject_Add(setuptools
BUILD_IN_SOURCE 1 PREFIX ${PYTHON_SOURCES_DIR}/setuptools
UPDATE_COMMAND "" URL http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
PATCH_COMMAND "" URL_MD5 7df2a529a074f613b509fb44feefe74e
CONFIGURE_COMMAND "" BUILD_IN_SOURCE 1
INSTALL_COMMAND "" UPDATE_COMMAND ""
BUILD_COMMAND ${PYTHON_EXECUTABLE} setup.py install PATCH_COMMAND ""
DEPENDS python zlib CONFIGURE_COMMAND ""
) INSTALL_COMMAND ""
BUILD_COMMAND ${PYTHON_EXECUTABLE} setup.py install
ExternalProject_Add(cython DEPENDS python zlib
PREFIX ${PYTHON_SOURCES_DIR}/cython )
GIT_REPOSITORY https://github.com/cython/cython.git
BUILD_IN_SOURCE 1 ExternalProject_Add(cython
CONFIGURE_COMMAND "" PREFIX ${PYTHON_SOURCES_DIR}/cython
UPDATE_COMMAND "" GIT_REPOSITORY https://github.com/cython/cython.git
PATCH_COMMAND "" BUILD_IN_SOURCE 1
INSTALL_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND ${PYTHON_EXECUTABLE} setup.py install UPDATE_COMMAND ""
DEPENDS python PATCH_COMMAND ""
) INSTALL_COMMAND ""
BUILD_COMMAND ${PYTHON_EXECUTABLE} setup.py install
ExternalProject_Add(numpy DEPENDS python
GIT_REPOSITORY https://github.com/numpy/numpy.git )
GIT_TAG ${NUMPY_VERSION}
CONFIGURE_COMMAND "" ExternalProject_Add(numpy
UPDATE_COMMAND "" GIT_REPOSITORY https://github.com/numpy/numpy.git
PREFIX ${NUMPY_SOURCES_DIR} GIT_TAG ${NUMPY_VERSION}
BUILD_COMMAND ${PYTHON_EXECUTABLE} setup.py build CONFIGURE_COMMAND ""
INSTALL_COMMAND ${PYTHON_EXECUTABLE} setup.py install UPDATE_COMMAND ""
BUILD_IN_SOURCE 1 PREFIX ${NUMPY_SOURCES_DIR}
DEPENDS python setuptools cython BUILD_COMMAND ${PYTHON_EXECUTABLE} setup.py build
) 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 @@ ...@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# INCLUDE(cblas)
INCLUDE(ExternalProject) INCLUDE(ExternalProject)
SET(CBLAS_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/openblas) SET(CBLAS_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/openblas)
......
...@@ -12,72 +12,81 @@ ...@@ -12,72 +12,81 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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) IF((NOT ${PYTHONINTERP_FOUND}) OR (NOT ${PYTHONLIBS_FOUND}))
SET(PYTHON_INSTALL_DIR ${PROJECT_BINARY_DIR}/python)
if(MSVC) INCLUDE(ExternalProject)
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()
if(APPLE) SET(PYTHON_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/python)
list(APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS SET(PYTHON_INSTALL_DIR ${PROJECT_BINARY_DIR}/python)
-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON
)
endif()
set(EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS) 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()
# Force Python build to "Release". IF(APPLE)
if(CMAKE_CONFIGURATION_TYPES) LIST(APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS
set(SAVED_CMAKE_CFG_INTDIR ${CMAKE_CFG_INTDIR}) -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON
set(CMAKE_CFG_INTDIR "Release") )
else() ENDIF()
list(APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Release)
endif()
ExternalProject_Add(python SET(EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS)
GIT_REPOSITORY "https://github.com/python-cmake-buildsystem/python-cmake-buildsystem.git"
GIT_TAG "ed5f9bcee540e47f82fa17f8360b820591aa6d66"
PREFIX ${PYTHON_SOURCES_DIR}
UPDATE_COMMAND ""
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${PYTHON_INSTALL_DIR}
-DBUILD_SHARED:BOOL=OFF
-DBUILD_STATIC:BOOL=ON
-DUSE_SYSTEM_LIBRARIES:BOOL=OFF
-DZLIB_ROOT:FILEPATH=${ZLIB_ROOT}
-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INCLUDE_DIR}
-DZLIB_LIBRARY:FILEPATH=${ZLIB_LIBRARIES}
-DDOWNLOAD_SOURCES:BOOL=ON
-DINSTALL_WINDOWS_TRADITIONAL:BOOL=OFF
${EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS}
${EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS}
DEPENDS zlib
)
set(_python_DIR ${PYTHON_INSTALL_DIR}) # 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()
if(UNIX) ExternalProject_Add(python
set(_python_IMPORT_SUFFIX so) GIT_REPOSITORY "https://github.com/python-cmake-buildsystem/python-cmake-buildsystem.git"
if(APPLE) GIT_TAG "ed5f9bcee540e47f82fa17f8360b820591aa6d66"
set(_python_IMPORT_SUFFIX dylib) PREFIX ${PYTHON_SOURCES_DIR}
endif() UPDATE_COMMAND ""
set(PYTHON_INCLUDE_DIR "${PYTHON_INSTALL_DIR}/include/python2.7" CACHE PATH "Python include dir" FORCE) CMAKE_CACHE_ARGS
set(PYTHON_LIBRARY "${PYTHON_INSTALL_DIR}/lib/libpython2.7.${_python_IMPORT_SUFFIX}" CACHE FILEPATH "Python library" FORCE) -DCMAKE_INSTALL_PREFIX:PATH=${PYTHON_INSTALL_DIR}
set(PYTHON_EXECUTABLE ${PYTHON_INSTALL_DIR}/bin/python CACHE FILEPATH "Python executable" FORCE) -DBUILD_SHARED:BOOL=OFF
set(PY_SITE_PACKAGES_PATH "${PYTHON_INSTALL_DIR}/lib/python2.7/site-packages" CACHE PATH "Python site-packages path" FORCE) -DBUILD_STATIC:BOOL=ON
elseif(WIN32) -DUSE_SYSTEM_LIBRARIES:BOOL=OFF
set(PYTHON_INCLUDE_DIR "${PYTHON_INSTALL_DIR}/include" CACHE PATH "Python include dir" FORCE) -DZLIB_ROOT:FILEPATH=${ZLIB_ROOT}
set(PYTHON_LIBRARY "${PYTHON_INSTALL_DIR}/libs/python27.lib" CACHE FILEPATH "Python library" FORCE) -DZLIB_INCLUDE_DIR:PATH=${ZLIB_INCLUDE_DIR}
set(PYTHON_EXECUTABLE "${PYTHON_INSTALL_DIR}/bin/python.exe" CACHE FILEPATH "Python executable" FORCE) -DZLIB_LIBRARY:FILEPATH=${ZLIB_LIBRARIES}
set(PY_SITE_PACKAGES_PATH "${PYTHON_INSTALL_DIR}/Lib/site-packages" CACHE PATH "Python site-packages path" FORCE) -DDOWNLOAD_SOURCES:BOOL=ON
else() -DINSTALL_WINDOWS_TRADITIONAL:BOOL=OFF
message(FATAL_ERROR "Unknown system !") ${EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS}
endif() ${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()
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
ENDIF()
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
# limitations under the License. # limitations under the License.
# Look for system swig # Look for system swig
# FIND_PACKAGE(SWIG) FIND_PACKAGE(SWIG)
#IF(NOT ${SWIG_FOUND}) IF(NOT ${SWIG_FOUND})
# build swig as an external project # build swig as an external project
INCLUDE(ExternalProject) INCLUDE(ExternalProject)
SET(SWIG_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/swig) SET(SWIG_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/swig)
...@@ -62,14 +62,28 @@ ...@@ -62,14 +62,28 @@
./configure ./configure
--prefix=${SWIG_INSTALL_DIR} --prefix=${SWIG_INSTALL_DIR}
--with-pcre-prefix=${SWIG_INSTALL_DIR}/pcre --with-pcre-prefix=${SWIG_INSTALL_DIR}/pcre
--with-python=${PYTHON_EXECUTABLE}
BUILD_COMMAND cd ${SWIG_SOURCES_DIR}/src/swig && make BUILD_COMMAND cd ${SWIG_SOURCES_DIR}/src/swig && make
INSTALL_COMMAND cd ${SWIG_SOURCES_DIR}/src/swig && make install 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_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) set(SWIG_EXECUTABLE ${SWIG_INSTALL_DIR}/bin/swig CACHE FILEPATH "SWIG Executable" FORCE)
ENDIF(WIN32) 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) ...@@ -17,22 +17,29 @@ INCLUDE(ExternalProject)
SET(WARPCTC_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/warpctc) SET(WARPCTC_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/warpctc)
SET(WARPCTC_INSTALL_DIR ${PROJECT_BINARY_DIR}/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( ExternalProject_Add(
warpctc warpctc
GIT_REPOSITORY "https://github.com/gangliao/warp-ctc.git" GIT_REPOSITORY "https://github.com/gangliao/warp-ctc.git"
PREFIX ${WARPCTC_SOURCES_DIR} PREFIX ${WARPCTC_SOURCES_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${WARPCTC_INSTALL_DIR} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${WARPCTC_INSTALL_DIR}
CMAKE_ARGS -DWITH_GPU=${CUDA_FOUND} 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) SET(WARPCTC_INCLUDE_DIR "${WARP_INSTALL_DIR}/include" CACHE PATH "Warp-ctc Directory" FORCE)
INCLUDE_DIRECTORIES(${WARPCTC_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${WARPCTC_INCLUDE_DIR})
IF(WIN32) IF(WIN32)
set(WARPCTC_LIBRARIES SET(WARPCTC_LIBRARIES
"${WARPCTC_INSTALL_DIR}/lib/warpctc.dll" CACHE FILEPATH "Warp-ctc Library" FORCE) "${WARPCTC_INSTALL_DIR}/lib/warpctc.dll" CACHE FILEPATH "Warp-ctc Library" FORCE)
ELSE(WIN32) ELSE(WIN32)
set(WARPCTC_LIBRARIES SET(WARPCTC_LIBRARIES
"${WARPCTC_INSTALL_DIR}/lib/libwarpctc.so" CACHE FILEPATH "Warp-ctc Library" FORCE) "${WARPCTC_INSTALL_DIR}/lib/libwarpctc.so" CACHE FILEPATH "Warp-ctc Library" FORCE)
ENDIF(WIN32) ENDIF(WIN32)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册