From ca3ba378c7b259ec787597bf2cc9c022fc1b810b Mon Sep 17 00:00:00 2001 From: wopeizl Date: Mon, 20 May 2019 11:20:59 +0800 Subject: [PATCH] fix the random compilation failure on windows test=develop (#17475) * fix the random compilation failure on windows --- cmake/external/dgc.cmake | 2 -- cmake/external/gflags.cmake | 9 +-------- cmake/external/glog.cmake | 9 +-------- cmake/external/snappy.cmake | 7 +------ cmake/external/warpctc.cmake | 7 +------ cmake/external/xxhash.cmake | 7 +------ cmake/external/zlib.cmake | 7 +------ cmake/generic.cmake | 2 +- paddle/fluid/inference/api/demo_ci/CMakeLists.txt | 9 ++------- 9 files changed, 9 insertions(+), 50 deletions(-) diff --git a/cmake/external/dgc.cmake b/cmake/external/dgc.cmake index a58b8c68d..05e63bfe3 100644 --- a/cmake/external/dgc.cmake +++ b/cmake/external/dgc.cmake @@ -38,5 +38,3 @@ ADD_LIBRARY(dgc STATIC IMPORTED GLOBAL) SET_PROPERTY(TARGET dgc PROPERTY IMPORTED_LOCATION ${DGC_LIBRARIES}) ADD_DEPENDENCIES(dgc extern_dgc) -LIST(APPEND external_project_dependencies dgc) - diff --git a/cmake/external/gflags.cmake b/cmake/external/gflags.cmake index 911920ed6..343b75447 100644 --- a/cmake/external/gflags.cmake +++ b/cmake/external/gflags.cmake @@ -18,7 +18,7 @@ SET(GFLAGS_SOURCES_DIR ${THIRD_PARTY_PATH}/gflags) SET(GFLAGS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gflags) SET(GFLAGS_INCLUDE_DIR "${GFLAGS_INSTALL_DIR}/include" CACHE PATH "gflags include directory." FORCE) IF(WIN32) - set(GFLAGS_LIBRARIES "${GFLAGS_INSTALL_DIR}/lib/libgflags.lib" CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE) + set(GFLAGS_LIBRARIES "${GFLAGS_INSTALL_DIR}/lib/gflags_static.lib" CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE) ELSE(WIN32) set(GFLAGS_LIBRARIES "${GFLAGS_INSTALL_DIR}/lib/libgflags.a" CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE) ENDIF(WIN32) @@ -50,13 +50,6 @@ ExternalProject_Add( -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} ) -IF(WIN32) - IF(NOT EXISTS "${GFLAGS_INSTALL_DIR}/lib/libgflags.lib") - add_custom_command(TARGET extern_gflags POST_BUILD - COMMAND cmake -E copy ${GFLAGS_INSTALL_DIR}/lib/gflags_static.lib ${GFLAGS_INSTALL_DIR}/lib/libgflags.lib - ) - ENDIF() -ENDIF(WIN32) ADD_LIBRARY(gflags STATIC IMPORTED GLOBAL) SET_PROPERTY(TARGET gflags PROPERTY IMPORTED_LOCATION ${GFLAGS_LIBRARIES}) ADD_DEPENDENCIES(gflags extern_gflags) diff --git a/cmake/external/glog.cmake b/cmake/external/glog.cmake index 7fa17ce6b..ac6294048 100644 --- a/cmake/external/glog.cmake +++ b/cmake/external/glog.cmake @@ -19,7 +19,7 @@ SET(GLOG_INSTALL_DIR ${THIRD_PARTY_PATH}/install/glog) SET(GLOG_INCLUDE_DIR "${GLOG_INSTALL_DIR}/include" CACHE PATH "glog include directory." FORCE) IF(WIN32) - SET(GLOG_LIBRARIES "${GLOG_INSTALL_DIR}/lib/libglog.lib" CACHE FILEPATH "glog library." FORCE) + SET(GLOG_LIBRARIES "${GLOG_INSTALL_DIR}/lib/glog.lib" CACHE FILEPATH "glog library." FORCE) SET(GLOG_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4530") ELSE(WIN32) SET(GLOG_LIBRARIES "${GLOG_INSTALL_DIR}/lib/libglog.a" CACHE FILEPATH "glog library." FORCE) @@ -60,13 +60,6 @@ ExternalProject_Add( -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} ) -IF(WIN32) - IF(NOT EXISTS "${GLOG_INSTALL_DIR}/lib/libglog.lib") - add_custom_command(TARGET extern_glog POST_BUILD - COMMAND cmake -E copy ${GLOG_INSTALL_DIR}/lib/glog.lib ${GLOG_INSTALL_DIR}/lib/libglog.lib - ) - ENDIF() -ENDIF(WIN32) ADD_LIBRARY(glog STATIC IMPORTED GLOBAL) SET_PROPERTY(TARGET glog PROPERTY IMPORTED_LOCATION ${GLOG_LIBRARIES}) diff --git a/cmake/external/snappy.cmake b/cmake/external/snappy.cmake index 1e01057aa..3fb6b49f4 100644 --- a/cmake/external/snappy.cmake +++ b/cmake/external/snappy.cmake @@ -53,12 +53,7 @@ ExternalProject_Add( -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} ) IF(WIN32) - IF(NOT EXISTS "${SNAPPY_INSTALL_DIR}/lib/libsnappy.lib") - add_custom_command(TARGET extern_snappy POST_BUILD - COMMAND cmake -E copy ${SNAPPY_INSTALL_DIR}/lib/snappy.lib ${SNAPPY_INSTALL_DIR}/lib/libsnappy.lib - ) - ENDIF() - set(SNAPPY_LIBRARIES "${SNAPPY_INSTALL_DIR}/lib/libsnappy.lib") + set(SNAPPY_LIBRARIES "${SNAPPY_INSTALL_DIR}/lib/snappy.lib") else(WIN32) set(SNAPPY_LIBRARIES "${SNAPPY_INSTALL_DIR}/lib/libsnappy.a") endif (WIN32) diff --git a/cmake/external/warpctc.cmake b/cmake/external/warpctc.cmake index 012283c6e..5fc46ae8e 100644 --- a/cmake/external/warpctc.cmake +++ b/cmake/external/warpctc.cmake @@ -64,12 +64,7 @@ ExternalProject_Add( -DCMAKE_INSTALL_PREFIX:PATH=${WARPCTC_INSTALL_DIR} ) IF(WIN32) - IF(NOT EXISTS "${WARPCTC_INSTALL_DIR}/lib/warpctc${CMAKE_SHARED_LIBRARY_SUFFIX}") - add_custom_command(TARGET extern_warpctc POST_BUILD - COMMAND cmake -E copy ${WARPCTC_INSTALL_DIR}/bin/warpctc${CMAKE_SHARED_LIBRARY_SUFFIX} ${WARPCTC_INSTALL_DIR}/lib/warpctc${CMAKE_SHARED_LIBRARY_SUFFIX} - ) - ENDIF() - SET(WARPCTC_LIBRARIES "${WARPCTC_INSTALL_DIR}/lib/warpctc${CMAKE_SHARED_LIBRARY_SUFFIX}" + SET(WARPCTC_LIBRARIES "${WARPCTC_INSTALL_DIR}/bin/warpctc${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE FILEPATH "Warp-ctc Library" FORCE) else(WIN32) SET(WARPCTC_LIBRARIES "${WARPCTC_INSTALL_DIR}/lib/libwarpctc${CMAKE_SHARED_LIBRARY_SUFFIX}" diff --git a/cmake/external/xxhash.cmake b/cmake/external/xxhash.cmake index 23b1e0210..262d47f6f 100644 --- a/cmake/external/xxhash.cmake +++ b/cmake/external/xxhash.cmake @@ -56,12 +56,7 @@ else() endif() if (WIN32) - IF(NOT EXISTS "${XXHASH_INSTALL_DIR}/lib/libxxhash.lib") - add_custom_command(TARGET extern_xxhash POST_BUILD - COMMAND cmake -E copy ${XXHASH_INSTALL_DIR}/lib/xxhash.lib ${XXHASH_INSTALL_DIR}/lib/libxxhash.lib - ) - ENDIF() - set(XXHASH_LIBRARIES "${XXHASH_INSTALL_DIR}/lib/libxxhash.lib") + set(XXHASH_LIBRARIES "${XXHASH_INSTALL_DIR}/lib/xxhash.lib") else() set(XXHASH_LIBRARIES "${XXHASH_INSTALL_DIR}/lib/libxxhash.a") endif () diff --git a/cmake/external/zlib.cmake b/cmake/external/zlib.cmake index 5569fefe9..58881ac22 100644 --- a/cmake/external/zlib.cmake +++ b/cmake/external/zlib.cmake @@ -44,12 +44,7 @@ ExternalProject_Add( -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} ) IF(WIN32) - IF(NOT EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.lib") - add_custom_command(TARGET extern_zlib POST_BUILD - COMMAND cmake -E copy ${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib ${ZLIB_INSTALL_DIR}/lib/libz.lib - ) - ENDIF() - SET(ZLIB_LIBRARIES "${ZLIB_INSTALL_DIR}/lib/libz.lib" CACHE FILEPATH "zlib library." FORCE) + SET(ZLIB_LIBRARIES "${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib" CACHE FILEPATH "zlib library." FORCE) ELSE(WIN32) SET(ZLIB_LIBRARIES "${ZLIB_INSTALL_DIR}/lib/libz.a" CACHE FILEPATH "zlib library." FORCE) ENDIF(WIN32) diff --git a/cmake/generic.cmake b/cmake/generic.cmake index 6679a09df..295259f5e 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -701,7 +701,7 @@ function(py_proto_compile TARGET_NAME) cmake_parse_arguments(py_proto_compile "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(py_srcs) protobuf_generate_python(py_srcs ${py_proto_compile_SRCS}) - add_custom_target(${TARGET_NAME} ALL DEPENDS ${py_srcs}) + add_custom_target(${TARGET_NAME} ALL DEPENDS ${py_srcs} protobuf) endfunction() function(py_test TARGET_NAME) diff --git a/paddle/fluid/inference/api/demo_ci/CMakeLists.txt b/paddle/fluid/inference/api/demo_ci/CMakeLists.txt index 19ef402d6..8c4ce84fa 100644 --- a/paddle/fluid/inference/api/demo_ci/CMakeLists.txt +++ b/paddle/fluid/inference/api/demo_ci/CMakeLists.txt @@ -53,10 +53,8 @@ if (WIN32) safe_set_static_flag() add_definitions(-DSTATIC_LIB) endif() - set(CMAKE_STATIC_LIBRARY_PREFIX "lib") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - set(CMAKE_STATIC_LIBRARY_PREFIX "") endif() message("flags" ${CMAKE_CXX_FLAGS}) @@ -125,11 +123,8 @@ if (NOT WIN32) else() set(DEPS ${DEPS} ${MATH_LIB} ${MKLDNN_LIB} - ${CMAKE_STATIC_LIBRARY_PREFIX}glog ${CMAKE_STATIC_LIBRARY_PREFIX}gflags ${CMAKE_STATIC_LIBRARY_PREFIX}protobuf - ${CMAKE_STATIC_LIBRARY_PREFIX}snappy ${CMAKE_STATIC_LIBRARY_PREFIX}z ${CMAKE_STATIC_LIBRARY_PREFIX}xxhash - snappystream ${EXTERNAL_LIB}) - get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES) - set(DEPS ${DEPS} libcmt ${os_dependency_modules}) + glog gflags_static protobuf snappy zlibstatic xxhash snappystream ${EXTERNAL_LIB}) + set(DEPS ${DEPS} libcmt shlwapi.lib) endif(NOT WIN32) if(WITH_GPU) -- GitLab