From 10a8f3e5c3151c1abb810fba2994cc30e1232bec Mon Sep 17 00:00:00 2001 From: Zhang Jun Date: Wed, 13 Jan 2021 15:12:28 +0800 Subject: [PATCH] fix bug on compiling inference shared lib with crypto;test=develop (#30269) * fix bug on compiling inference shared lib with crypto;test=develop * fix cmake bug when build inference lib using -DWITH_CRYPTO=OFF * update cmake * remove unnecessary enforce message --- paddle/fluid/framework/io/crypto/cipher.cc | 4 ++-- paddle/fluid/inference/CMakeLists.txt | 22 ++++++++++++++-------- paddle/fluid/inference/api/paddle_api.h | 2 -- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/paddle/fluid/framework/io/crypto/cipher.cc b/paddle/fluid/framework/io/crypto/cipher.cc index 316f8f9c751..6a29419ffb3 100644 --- a/paddle/fluid/framework/io/crypto/cipher.cc +++ b/paddle/fluid/framework/io/crypto/cipher.cc @@ -56,9 +56,9 @@ std::shared_ptr CipherFactory::CreateCipher( } } // namespace framework -#ifdef PADDLE_ON_INFERENCE + std::shared_ptr MakeCipher(const std::string& config_file) { return framework::CipherFactory::CreateCipher(config_file); } -#endif + } // namespace paddle diff --git a/paddle/fluid/inference/CMakeLists.txt b/paddle/fluid/inference/CMakeLists.txt index 1896be4f921..fb55d546362 100644 --- a/paddle/fluid/inference/CMakeLists.txt +++ b/paddle/fluid/inference/CMakeLists.txt @@ -76,14 +76,20 @@ set(SHARED_INFERENCE_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/utils/io_utils.cc ${mkldnn_quantizer_src_file}) -# Create shared inference library defaultly -if(NOT WITH_PSCORE) - cc_library(paddle_fluid_shared SHARED SRCS ${SHARED_INFERENCE_SRCS} - DEPS ${fluid_modules} analysis_predictor) -else() - cc_library(paddle_fluid_shared SHARED SRCS ${SHARED_INFERENCE_SRCS} - DEPS ${fluid_modules} analysis_predictor fleet ps_service) -endif() +# shared inference library deps +set(SHARED_INFERENCE_DEPS ${fluid_modules} analysis_predictor) + +if (WITH_CRYPTO) + set(SHARED_INFERENCE_DEPS ${SHARED_INFERENCE_DEPS} paddle_crypto) +endif (WITH_CRYPTO) + +if (WITH_PSCORE) + set(SHARED_INFERENCE_DEPS ${SHARED_INFERENCE_DEPS} fleet ps_service) +endif () + +# Create shared inference library +cc_library(paddle_fluid_shared SHARED SRCS ${SHARED_INFERENCE_SRCS} + DEPS ${SHARED_INFERENCE_DEPS}) get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES) target_link_libraries(paddle_fluid_shared ${os_dependency_modules}) diff --git a/paddle/fluid/inference/api/paddle_api.h b/paddle/fluid/inference/api/paddle_api.h index 0262ab54517..11f362504b6 100644 --- a/paddle/fluid/inference/api/paddle_api.h +++ b/paddle/fluid/inference/api/paddle_api.h @@ -451,9 +451,7 @@ PD_INFER_DECL std::string get_version(); PD_INFER_DECL std::string UpdateDllFlag(const char* name, const char* value); -#ifdef PADDLE_ON_INFERENCE PD_INFER_DECL std::shared_ptr MakeCipher( const std::string& config_file); -#endif } // namespace paddle -- GitLab