From 1eb9c36fd2a13ff5d267b0280a7f3448290b2c04 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Wed, 30 Nov 2016 12:50:14 +0800 Subject: [PATCH] Make ApproximatelyEquals fit for protobuf2 --- CMakeLists.txt | 11 ++++++++++ proto/CMakeLists.txt | 9 -------- .../tests/CMakeLists.txt | 22 ++++++++++++------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d685587a7a..7ef9368ef5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,17 @@ include(package) find_package(SWIG 2.0) find_package(CUDA QUIET) find_package(Protobuf REQUIRED) + +# Check protobuf library version. +execute_process(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --version + OUTPUT_VARIABLE PROTOBUF_VERSION) +string(REPLACE "libprotoc " "" PROTOBUF_VERSION ${PROTOBUF_VERSION}) + +set(PROTOBUF_3 OFF) +if (${PROTOBUF_VERSION} VERSION_GREATER "3.0.0" OR ${PROTOBUF_VERSION} VERSION_EQUAL "3.0.0") + set(PROTOBUF_3 ON) +endif() + find_package(PythonLibs 2.7 REQUIRED) find_package(PythonInterp 2.7 REQUIRED) find_package(ZLIB REQUIRED) diff --git a/proto/CMakeLists.txt b/proto/CMakeLists.txt index ec68b53d440..d7f523bc8d9 100644 --- a/proto/CMakeLists.txt +++ b/proto/CMakeLists.txt @@ -1,12 +1,3 @@ -execute_process(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --version - OUTPUT_VARIABLE PROTOBUF_VERSION) -string(REPLACE "libprotoc " "" PROTOBUF_VERSION ${PROTOBUF_VERSION}) - -set(PROTOBUF_3 OFF) -if (${PROTOBUF_VERSION} VERSION_GREATER "3.0.0" OR ${PROTOBUF_VERSION} VERSION_EQUAL "3.0.0") - set(PROTOBUF_3 ON) -endif() - set(proto_filenames DataConfig.proto DataFormat.proto diff --git a/python/paddle/trainer_config_helpers/tests/CMakeLists.txt b/python/paddle/trainer_config_helpers/tests/CMakeLists.txt index 78505c85e1b..6180b2efbca 100644 --- a/python/paddle/trainer_config_helpers/tests/CMakeLists.txt +++ b/python/paddle/trainer_config_helpers/tests/CMakeLists.txt @@ -4,11 +4,17 @@ add_test(NAME layers_test python ${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/layers_test.py WORKING_DIRECTORY ${PROJ_ROOT}/python/paddle) -add_paddle_exe(protobuf_equal - ProtobufEqualMain.cpp) - -add_test(NAME test_layerHelpers - COMMAND - ${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh - ${CMAKE_CURRENT_BINARY_DIR}/protobuf_equal -) +if (PROTOBUF_3) + add_paddle_exe(protobuf_equal + ProtobufEqualMain.cpp) + add_test(NAME test_layerHelpers + COMMAND + ${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh + ${CMAKE_CURRENT_BINARY_DIR}/protobuf_equal + ) +else() + add_test(NAME test_layerHelpers + COMMAND + ${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh + ) +endif() -- GitLab