|
|
|
@ -22,20 +22,41 @@ function(copy TARGET)
|
|
|
|
|
|
|
|
|
|
list(LENGTH copy_lib_SRCS copy_lib_SRCS_len)
|
|
|
|
|
list(LENGTH copy_lib_DSTS copy_lib_DSTS_len)
|
|
|
|
|
if(NOT ${copy_lib_SRCS_len} EQUAL ${copy_lib_DSTS_len})
|
|
|
|
|
if (NOT ${copy_lib_SRCS_len} EQUAL ${copy_lib_DSTS_len})
|
|
|
|
|
message(FATAL_ERROR "${TARGET} source numbers are not equal to destination numbers")
|
|
|
|
|
endif()
|
|
|
|
|
endif ()
|
|
|
|
|
math(EXPR len "${copy_lib_SRCS_len} - 1")
|
|
|
|
|
|
|
|
|
|
add_custom_target(${TARGET} DEPENDS ${copy_lib_DEPS})
|
|
|
|
|
foreach(index RANGE ${len})
|
|
|
|
|
foreach (index RANGE ${len})
|
|
|
|
|
list(GET copy_lib_SRCS ${index} src)
|
|
|
|
|
list(GET copy_lib_DSTS ${index} dst)
|
|
|
|
|
if (WIN32)
|
|
|
|
|
# windows cmd shell will not expand wildcard automatically.
|
|
|
|
|
# below expand the files,libs and copy them by rules.
|
|
|
|
|
file(GLOB header_files ${src} "*.h")
|
|
|
|
|
file(GLOB static_lib_files ${src} "*.lib")
|
|
|
|
|
file(GLOB dll_lib_files ${src} "*.dll")
|
|
|
|
|
set(src_files ${header_files} ${static_lib_files} ${dll_lib_files})
|
|
|
|
|
|
|
|
|
|
if (NOT "${src_files}" STREQUAL "")
|
|
|
|
|
list(REMOVE_DUPLICATES src_files)
|
|
|
|
|
endif ()
|
|
|
|
|
add_custom_command(TARGET ${TARGET} PRE_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${dst}"
|
|
|
|
|
)
|
|
|
|
|
foreach (src_file ${src_files})
|
|
|
|
|
add_custom_command(TARGET ${TARGET} PRE_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${src_file}" "${dst}"
|
|
|
|
|
COMMENT "copying ${src_file} -> ${dst}")
|
|
|
|
|
endforeach ()
|
|
|
|
|
else (WIN32) # not windows
|
|
|
|
|
add_custom_command(TARGET ${TARGET} PRE_BUILD
|
|
|
|
|
COMMAND mkdir -p "${dst}"
|
|
|
|
|
COMMAND cp -r "${src}" "${dst}"
|
|
|
|
|
COMMENT "copying ${src} -> ${dst}")
|
|
|
|
|
endforeach()
|
|
|
|
|
endif (WIN32) # not windows
|
|
|
|
|
endforeach ()
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
# third party
|
|
|
|
@ -44,46 +65,46 @@ copy(eigen3_lib
|
|
|
|
|
SRCS ${EIGEN_INCLUDE_DIR}/Eigen/Core ${EIGEN_INCLUDE_DIR}/Eigen/src ${EIGEN_INCLUDE_DIR}/unsupported/Eigen
|
|
|
|
|
DSTS ${dst_dir}/Eigen ${dst_dir}/Eigen ${dst_dir}/unsupported
|
|
|
|
|
DEPS eigen3
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(dst_dir "${FLUID_INSTALL_DIR}/third_party/install/gflags")
|
|
|
|
|
copy(gflags_lib
|
|
|
|
|
SRCS ${GFLAGS_INCLUDE_DIR} ${GFLAGS_LIBRARIES}
|
|
|
|
|
DSTS ${dst_dir} ${dst_dir}/lib
|
|
|
|
|
DEPS gflags
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(dst_dir "${FLUID_INSTALL_DIR}/third_party/install/glog")
|
|
|
|
|
copy(glog_lib
|
|
|
|
|
SRCS ${GLOG_INCLUDE_DIR} ${GLOG_LIBRARIES}
|
|
|
|
|
DSTS ${dst_dir} ${dst_dir}/lib
|
|
|
|
|
DEPS glog
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(dst_dir "${FLUID_INSTALL_DIR}/third_party/boost/")
|
|
|
|
|
copy(boost_lib
|
|
|
|
|
SRCS ${BOOST_INCLUDE_DIR}/boost
|
|
|
|
|
DSTS ${dst_dir}
|
|
|
|
|
DEPS boost
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(dst_dir "${FLUID_INSTALL_DIR}/third_party/install/xxhash")
|
|
|
|
|
copy(xxhash_lib
|
|
|
|
|
SRCS ${XXHASH_INCLUDE_DIR} ${XXHASH_LIBRARIES}
|
|
|
|
|
DSTS ${dst_dir} ${dst_dir}/lib
|
|
|
|
|
DEPS xxhash
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if(NOT PROTOBUF_FOUND)
|
|
|
|
|
if (NOT PROTOBUF_FOUND)
|
|
|
|
|
set(dst_dir "${FLUID_INSTALL_DIR}/third_party/install/protobuf")
|
|
|
|
|
copy(protobuf_lib
|
|
|
|
|
SRCS ${PROTOBUF_INCLUDE_DIR} ${PROTOBUF_LIBRARY}
|
|
|
|
|
DSTS ${dst_dir} ${dst_dir}/lib
|
|
|
|
|
DEPS extern_protobuf
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if(NOT CBLAS_FOUND)
|
|
|
|
|
if (NOT CBLAS_FOUND)
|
|
|
|
|
set(dst_dir "${FLUID_INSTALL_DIR}/third_party/install/openblas")
|
|
|
|
|
copy(openblas_lib
|
|
|
|
|
SRCS ${CBLAS_INSTALL_DIR}/lib ${CBLAS_INSTALL_DIR}/include
|
|
|
|
@ -97,19 +118,19 @@ elseif (WITH_MKLML)
|
|
|
|
|
DSTS ${dst_dir}/lib ${dst_dir}/lib ${dst_dir}
|
|
|
|
|
DEPS mklml
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if(WITH_MKLDNN)
|
|
|
|
|
if (WITH_MKLDNN)
|
|
|
|
|
set(dst_dir "${FLUID_INSTALL_DIR}/third_party/install/mkldnn")
|
|
|
|
|
copy(mkldnn_lib
|
|
|
|
|
SRCS ${MKLDNN_INC_DIR} ${MKLDNN_SHARED_LIB}
|
|
|
|
|
DSTS ${dst_dir} ${dst_dir}/lib
|
|
|
|
|
DEPS mkldnn
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if (NOT WIN32)
|
|
|
|
|
if(NOT MOBILE_INFERENCE AND NOT RPI)
|
|
|
|
|
if (NOT MOBILE_INFERENCE AND NOT RPI)
|
|
|
|
|
set(dst_dir "${FLUID_INSTALL_DIR}/third_party/install/snappy")
|
|
|
|
|
copy(snappy_lib
|
|
|
|
|
SRCS ${SNAPPY_INCLUDE_DIR} ${SNAPPY_LIBRARIES}
|
|
|
|
@ -127,27 +148,27 @@ if(NOT MOBILE_INFERENCE AND NOT RPI)
|
|
|
|
|
SRCS ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARIES}
|
|
|
|
|
DSTS ${dst_dir} ${dst_dir}/lib
|
|
|
|
|
DEPS zlib)
|
|
|
|
|
endif()
|
|
|
|
|
endif(NOT WIN32)
|
|
|
|
|
endif ()
|
|
|
|
|
endif (NOT WIN32)
|
|
|
|
|
|
|
|
|
|
# paddle fluid module
|
|
|
|
|
set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid")
|
|
|
|
|
set(dst_dir "${FLUID_INSTALL_DIR}/paddle/fluid")
|
|
|
|
|
set(module "framework")
|
|
|
|
|
if (NOT WIN32)
|
|
|
|
|
set(framework_lib_deps framework_py_proto)
|
|
|
|
|
endif(NOT WIN32)
|
|
|
|
|
set(framework_lib_deps framework_py_proto)
|
|
|
|
|
endif (NOT WIN32)
|
|
|
|
|
copy(framework_lib DEPS ${framework_lib_deps}
|
|
|
|
|
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/details/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/framework/framework.pb.h
|
|
|
|
|
${src_dir}/${module}/ir/*.h
|
|
|
|
|
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/details ${dst_dir}/${module} ${dst_dir}/${module}/ir
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(module "memory")
|
|
|
|
|
copy(memory_lib
|
|
|
|
|
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/detail/*.h
|
|
|
|
|
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/detail
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(inference_deps paddle_fluid_shared paddle_fluid)
|
|
|
|
|
|
|
|
|
@ -159,7 +180,7 @@ if (WITH_ANAKIN AND WITH_MKL)
|
|
|
|
|
${ANAKIN_INSTALL_DIR} # anakin release
|
|
|
|
|
DSTS ${FLUID_INSTALL_DIR}/third_party/install/anakin ${FLUID_INSTALL_DIR}/third_party/install/anakin)
|
|
|
|
|
list(APPEND inference_deps anakin_inference_lib)
|
|
|
|
|
endif()
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
set(module "inference")
|
|
|
|
|
copy(inference_lib DEPS ${inference_deps}
|
|
|
|
@ -167,25 +188,25 @@ copy(inference_lib DEPS ${inference_deps}
|
|
|
|
|
${src_dir}/${module}/api/paddle_*.h
|
|
|
|
|
${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/paddle_inference_pass.h
|
|
|
|
|
DSTS ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(module "platform")
|
|
|
|
|
copy(platform_lib DEPS profiler_py_proto
|
|
|
|
|
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/dynload/*.h ${src_dir}/${module}/details/*.h
|
|
|
|
|
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/dynload ${dst_dir}/${module}/details
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(module "string")
|
|
|
|
|
copy(string_lib
|
|
|
|
|
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/tinyformat/*.h
|
|
|
|
|
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/tinyformat
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(module "pybind")
|
|
|
|
|
copy(pybind_lib
|
|
|
|
|
SRCS ${CMAKE_CURRENT_BINARY_DIR}/paddle/fluid/${module}/pybind.h
|
|
|
|
|
DSTS ${dst_dir}/${module}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# CMakeCache Info
|
|
|
|
|
copy(cmake_cache
|
|
|
|
@ -200,7 +221,7 @@ add_custom_target(fluid_lib_dist DEPENDS ${fluid_lib_dist_dep})
|
|
|
|
|
copy(third_party DEPS fluid_lib_dist
|
|
|
|
|
SRCS ${FLUID_INSTALL_DIR}/third_party ${FLUID_INSTALL_DIR}/CMakeCache.txt
|
|
|
|
|
DSTS ${FLUID_INFERENCE_INSTALL_DIR} ${FLUID_INFERENCE_INSTALL_DIR}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# only need libpaddle_fluid.so/a and paddle_*.h for inference-only library
|
|
|
|
|
copy(inference_api_lib DEPS fluid_lib_dist
|
|
|
|
@ -222,11 +243,11 @@ function(version version_file)
|
|
|
|
|
"WITH_MKL: ${WITH_MKL}\n"
|
|
|
|
|
"WITH_MKLDNN: ${WITH_MKLDNN}\n"
|
|
|
|
|
"WITH_GPU: ${WITH_GPU}\n")
|
|
|
|
|
if(WITH_GPU)
|
|
|
|
|
if (WITH_GPU)
|
|
|
|
|
file(APPEND ${version_file}
|
|
|
|
|
"CUDA version: ${CUDA_VERSION}\n"
|
|
|
|
|
"CUDNN version: v${CUDNN_MAJOR_VERSION}\n")
|
|
|
|
|
endif()
|
|
|
|
|
endif ()
|
|
|
|
|
endfunction()
|
|
|
|
|
version(${FLUID_INSTALL_DIR}/version.txt)
|
|
|
|
|
version(${FLUID_INFERENCE_INSTALL_DIR}/version.txt)
|
|
|
|
|