diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d685587a7a7f388167f79cc8874003ab445f433..7ef9368ef5aca23363c2b9d74479ffe487570512 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 ec68b53d440185f869566e2975a65d0c3fec5bc5..d7f523bc8d9bce00ba72c41284d2b3eb3cde6529 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 78505c85e1b9c8b87612a3f17c294035e221774f..6180b2efbcad87e511a4b981d533f204f45fb5dc 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()