Commits

Anonymous committed cb73715

Modified cmake rules to generate alternate format metadata files.

  • Participants
  • Parent commits 9ddb953
  • Branches default

Comments (0)

Files changed (1)

File cpp/CMakeLists.txt

   "src/phonenumbers/geocoding/geocoding_data.cc"
   "src/phonenumbers/geocoding/mapping_file_provider.cc"
   "src/phonenumbers/logger.cc"
-  "src/phonenumbers/metadata.h"          # Generated by build tools.
   "src/phonenumbers/phonemetadata.pb.cc" # Generated by Protocol Buffers.
   "src/phonenumbers/phonenumber.cc"
   "src/phonenumbers/phonenumber.pb.cc"   # Generated by Protocol Buffers.
   add_definitions (-DUSE_ICU_REGEXP)
   list (APPEND SOURCES "src/phonenumbers/regexp_adapter_icu.cc")
   # The phone number matcher needs ICU.
+  list (APPEND SOURCES "src/phonenumbers/alternate_format.cc")
   list (APPEND SOURCES "src/phonenumbers/phonenumbermatch.cc")
   list (APPEND SOURCES "src/phonenumbers/phonenumbermatcher.cc")
 endif ()
 # code generation targets.
 function (add_metadata_gen_target TARGET_NAME
                                   XML_FILE
-                                  METADATA_TYPE)
+                                  METADATA_TYPE
+                                  METADATA_HEADER)
   set (METADATA_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/phonenumbers")
   set (GEN_OUTPUT "${METADATA_SOURCE_DIR}/${METADATA_TYPE}.cc"
-                  "${METADATA_SOURCE_DIR}/metadata.h")
+                  "${METADATA_SOURCE_DIR}/${METADATA_HEADER}.h")
   set (JAR_PATH "${CMAKE_SOURCE_DIR}/../tools/java/cpp-build/target")
   set (JAR_PATH "${JAR_PATH}/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar")
 
     ${METADATA_TARGET}
     "${RESOURCES_DIR}/PhoneNumberMetaData.xml"
     "lite_metadata"
+    "metadata"
   )
   list (APPEND SOURCES "src/phonenumbers/lite_metadata.cc")
 else ()
     ${METADATA_TARGET}
     "${RESOURCES_DIR}/PhoneNumberMetaData.xml"
     "metadata"
+    "metadata"
   )
   list (APPEND SOURCES "src/phonenumbers/metadata.cc")
 endif ()
   ${TEST_METADATA_TARGET}
   "${RESOURCES_DIR}/PhoneNumberMetaDataForTesting.xml"
   "test_metadata"
+  "metadata"
 )
 list (APPEND TESTING_LIBRARY_SOURCES "src/phonenumbers/test_metadata.cc")
 
+if (${USE_ICU_REGEXP} STREQUAL "ON")
+  # Add alternate format metadata generation for the phone number matcher
+  set (ALT_FORMAT_METADATA_TARGET "generate-alt-format-metadata")
+  add_metadata_gen_target (
+    ${ALT_FORMAT_METADATA_TARGET}
+    "${RESOURCES_DIR}/PhoneNumberAlternateFormats.xml"
+    "alternate_format"
+    "alternate_format"
+  )
+endif ()
+
 if (NOT WIN32)
   add_definitions ("-Wall -Werror")
 endif ()
 # Build a static library (without -fPIC).
 add_library (phonenumber STATIC ${SOURCES})
 add_dependencies (phonenumber generate-sources ${METADATA_TARGET})
+if (${USE_ICU_REGEXP} STREQUAL "ON")
+  add_dependencies (phonenumber ${ALT_FORMAT_METADATA_TARGET})
+endif ()
 
 # Build a shared library (with -fPIC).
 set (BUILD_SHARED_LIB true)
 if (BUILD_SHARED_LIB)
   add_library (phonenumber-shared SHARED ${SOURCES})
   add_dependencies (phonenumber-shared generate-sources ${METADATA_TARGET})
+  if (${USE_ICU_REGEXP} STREQUAL "ON")
+    add_dependencies (phonenumber ${ALT_FORMAT_METADATA_TARGET})
+  endif ()
   set_target_properties (phonenumber-shared
     PROPERTIES
       OUTPUT_NAME "phonenumber"