diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9428b305e..51f87e8ff 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -64,6 +64,22 @@ if (PROTOC STREQUAL "PROTOC-NOTFOUND") "Please read README.") endif () +# Find Protocol Buffers library +find_path (PROTOBUF_INCLUDE_DIR google/protobuf/message_lite.h) + +if (PROTOBUF_INCLUDE_DIR STREQUAL "PROTOBUF_INCLUDE_DIR-NOTFOUND") + message (FATAL_ERROR + "Can't find Google Protocol headers. Please read README.") +endif () + +include_directories (${PROTOBUF_INCLUDE_DIR}) + +find_library (PROTOBUF_LIB protobuf) + +if (PROTOBUF_LIB STREQUAL "PROTOBUF_LIB-NOTFOUND") + message (FATAL_ERROR + "Can't find Google Protocol Buffers library. Please read README.") +endif () # Find ICU find_path (ICU_INCLUDE_DIR unicode/unistr.h unicode/normlzr.h) @@ -176,7 +192,7 @@ include_directories (".") add_library (phonenumber STATIC ${SOURCES}) add_dependencies (phonenumber generate-sources) -target_link_libraries (phonenumber re2 protobuf icui18n) +target_link_libraries (phonenumber ${RE2_LIB} ${PROTOBUF_LIB} ${ICU_LIB}) # Tests @@ -190,4 +206,4 @@ set (TEST_SOURCES add_executable (libphonenumber_test ${TEST_SOURCES}) -target_link_libraries (libphonenumber_test phonenumber gtest pthread) +target_link_libraries (libphonenumber_test phonenumber ${GTEST_LIB} pthread) diff --git a/cpp/README b/cpp/README index 90534646d..37b0e49e6 100644 --- a/cpp/README +++ b/cpp/README @@ -14,6 +14,18 @@ Requirements: You can install it very easily on a Debian-based GNU/Linux distribution: $ sudo apt-get install cmake + - Protocol Buffers + http://code.google.com/p/protobuf/ + + You can install it very easily on a Debian-based GNU/Linux distribution: + $ sudo apt-get install libprotobuf-dev + + - Google Test + http://code.google.com/p/googletest/ + + You can install it very easily on a Debian-based GNU/Linux distribution: + $ sudo apt-get install libgtest-dev + - RE2 http://code.google.com/p/re2/ @@ -46,5 +58,5 @@ How to build libphonenumber C++: $ cd libphonenumber $ mkdir build $ cd build - $ cmake .. + $ cmake ../cpp/ $ make