From 338dc3ee923e0757420b6466f91dc60d19850b2a Mon Sep 17 00:00:00 2001 From: liaogang Date: Wed, 28 Dec 2016 00:20:15 +0800 Subject: [PATCH] Fix external denpendencies build order --- cmake/external/numpy.cmake | 2 ++ cmake/external/protobuf.cmake | 12 +++++++++--- cmake/external/python.cmake | 3 +++ cmake/external/swig.cmake | 7 ++++++- cmake/external/warpctc.cmake | 8 +++++++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/cmake/external/numpy.cmake b/cmake/external/numpy.cmake index 9d686ecaa..d01cff972 100644 --- a/cmake/external/numpy.cmake +++ b/cmake/external/numpy.cmake @@ -59,6 +59,8 @@ IF(NOT ${NUMPY_FOUND}) DEPENDS python setuptools cython ) + LIST(APPEND external_project_dependencies numpy) + # find numpy include directory FILE(WRITE ${PROJECT_BINARY_DIR}/FindNumpyPath.py "try: import numpy; print(numpy.get_include())\nexcept:pass\n") diff --git a/cmake/external/protobuf.cmake b/cmake/external/protobuf.cmake index 0138f082d..efd07eb80 100644 --- a/cmake/external/protobuf.cmake +++ b/cmake/external/protobuf.cmake @@ -42,10 +42,16 @@ IF(WIN32) "${PROTOBUF_INSTALL_DIR}/lib/libprotoc.lib" CACHE FILEPATH "protobuf libraries." FORCE) SET(PROTOBUF_PROTOC_EXECUTABLE "${PROTOBUF_INSTALL_DIR}/bin/protoc.exe" CACHE FILEPATH "protobuf executable." FORCE) ELSE(WIN32) + FIND_PATH(PROTOBUF_LIBS_DIR libprotoc.a + PATHS + ${PROTOBUF_INSTALL_DIR}/lib64 + ${PROTOBUF_INSTALL_DIR}/lib + NO_DEFAULT_PATH + ) SET(PROTOBUF_LIBRARIES - "${PROTOBUF_INSTALL_DIR}/lib/libprotobuf-lite.a" - "${PROTOBUF_INSTALL_DIR}/lib/libprotobuf.a" - "${PROTOBUF_INSTALL_DIR}/lib/libprotoc.a" CACHE FILEPATH "protobuf libraries." FORCE) + "${PROTOBUF_LIBS_DIR}/libprotobuf-lite.a" + "${PROTOBUF_LIBS_DIR}/libprotobuf.a" + "${PROTOBUF_LIBS_DIR}/libprotoc.a" CACHE FILEPATH "protobuf libraries." FORCE) SET(PROTOBUF_PROTOC_EXECUTABLE "${PROTOBUF_INSTALL_DIR}/bin/protoc" CACHE FILEPATH "protobuf executable." FORCE) ENDIF(WIN32) diff --git a/cmake/external/python.cmake b/cmake/external/python.cmake index 7b66cb44e..d6cdf535f 100644 --- a/cmake/external/python.cmake +++ b/cmake/external/python.cmake @@ -87,6 +87,9 @@ IF((NOT ${PYTHONINTERP_FOUND}) OR (NOT ${PYTHONLIBS_FOUND})) MESSAGE(FATAL_ERROR "Unknown system !") ENDIF() +LIST(APPEND external_project_dependencies python) + ENDIF() INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR}) + diff --git a/cmake/external/swig.cmake b/cmake/external/swig.cmake index 1ec61660b..2da826d37 100644 --- a/cmake/external/swig.cmake +++ b/cmake/external/swig.cmake @@ -70,6 +70,9 @@ IF(NOT ${SWIG_FOUND}) 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) + + LIST(APPEND external_project_dependencies swig) + ENDIF() FUNCTION(generate_python_api target_name) @@ -80,10 +83,12 @@ FUNCTION(generate_python_api target_name) && 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 + ${external_project_dependencies} 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) + ${PROJ_ROOT}/paddle/py_paddle/swig_paddle.py + ${external_project_dependencies}) ENDFUNCTION(generate_python_api) diff --git a/cmake/external/warpctc.cmake b/cmake/external/warpctc.cmake index d59e5e9c3..2e678aadc 100644 --- a/cmake/external/warpctc.cmake +++ b/cmake/external/warpctc.cmake @@ -40,8 +40,14 @@ IF(WIN32) SET(WARPCTC_LIBRARIES "${WARPCTC_INSTALL_DIR}/lib/warpctc.dll" CACHE FILEPATH "Warp-ctc Library" FORCE) ELSE(WIN32) + IF(APPLE) + SET(_warpctc_SHARED_SUFFIX dylib) + ELSE(APPLE) + SET(_warpctc_SHARED_SUFFIX so) + ENDIF(APPLE) + SET(WARPCTC_LIBRARIES - "${WARPCTC_INSTALL_DIR}/lib/libwarpctc.dylib" CACHE FILEPATH "Warp-ctc Library" FORCE) + "${WARPCTC_INSTALL_DIR}/lib/libwarpctc.${_warpctc_SHARED_SUFFIX}" CACHE FILEPATH "Warp-ctc Library" FORCE) ENDIF(WIN32) LIST(APPEND external_project_dependencies warpctc) -- GitLab