Browse Source

Original commit from Timur Kristóf (#2475)

Add build option REGENERATE_METADATA   to disable regenerating the metadata.
pull/2483/head
Gilles Vollant 6 years ago
committed by GitHub
parent
commit
59329d03fd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 9 deletions
  1. +24
    -9
      cpp/CMakeLists.txt
  2. +9
    -0
      cpp/README

+ 24
- 9
cpp/CMakeLists.txt View File

@ -79,6 +79,7 @@ endfunction (find_required_program)
# Options that can be passed to CMake using 'cmake -DKEY=VALUE'. # Options that can be passed to CMake using 'cmake -DKEY=VALUE'.
option ("BUILD_GEOCODER" "Build the offline phone number geocoder" "ON") option ("BUILD_GEOCODER" "Build the offline phone number geocoder" "ON")
option ("REGENERATE_METADATA" "Regenerate metadata instead of using it from the source tree" "ON")
option ("USE_ALTERNATE_FORMATS" "Use alternate formats" "ON") option ("USE_ALTERNATE_FORMATS" "Use alternate formats" "ON")
option ("USE_BOOST" "Use Boost" "ON") option ("USE_BOOST" "Use Boost" "ON")
option ("USE_ICU_REGEXP" "Use ICU regexp engine" "ON") option ("USE_ICU_REGEXP" "Use ICU regexp engine" "ON")
@ -145,8 +146,10 @@ endif ()
find_required_program (PROTOC protoc find_required_program (PROTOC protoc
"Google Protocol Buffers compiler (protoc)") "Google Protocol Buffers compiler (protoc)")
find_required_program (JAVA java
"Java Runtime Environment")
if (${REGENERATE_METADATA} STREQUAL "ON")
find_required_program (JAVA java
"Java Runtime Environment")
endif ()
if (APPLE) if (APPLE)
FIND_LIBRARY (COREFOUNDATION_LIB CoreFoundation) FIND_LIBRARY (COREFOUNDATION_LIB CoreFoundation)
@ -286,14 +289,26 @@ function (add_metadata_gen_target TARGET_NAME
set (JAR_PATH "${CMAKE_SOURCE_DIR}/../tools/java/cpp-build/target") 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") set (JAR_PATH "${JAR_PATH}/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar")
add_custom_command (
COMMAND ${JAVA_BIN} -jar
${JAR_PATH} BuildMetadataCppFromXml ${XML_FILE}
${CMAKE_SOURCE_DIR}/src/phonenumbers ${METADATA_TYPE}
if (${REGENERATE_METADATA} STREQUAL "ON")
add_custom_command (
COMMAND ${JAVA_BIN} -jar
${JAR_PATH} BuildMetadataCppFromXml ${XML_FILE}
${CMAKE_SOURCE_DIR}/src/phonenumbers ${METADATA_TYPE}
OUTPUT ${GEN_OUTPUT}
DEPENDS ${XML_FILE}
)
else ()
add_custom_command (
COMMAND echo "skip metadata generation from"
${XML_FILE} "to"
${CMAKE_SOURCE_DIR}/src/phonenumbers ${METADATA_TYPE}
OUTPUT ${GEN_OUTPUT}
DEPENDS ${XML_FILE}
)
endif ()
OUTPUT ${GEN_OUTPUT}
DEPENDS ${XML_FILE}
)
add_custom_target ( add_custom_target (
${TARGET_NAME} ${TARGET_NAME}
DEPENDS ${GEN_OUTPUT} DEPENDS ${GEN_OUTPUT}


+ 9
- 0
cpp/README View File

@ -365,3 +365,12 @@ Supported build parameters
USE_RE2 = ON | OFF [OFF] -- Use RE2. USE_RE2 = ON | OFF [OFF] -- Use RE2.
USE_STD_MAP = ON | OFF [OFF] -- Force the use of std::map. USE_STD_MAP = ON | OFF [OFF] -- Force the use of std::map.
USE_STDMUTEX = ON | OFF [OFF] -- Detect and use C++2011 for multi-threading. USE_STDMUTEX = ON | OFF [OFF] -- Detect and use C++2011 for multi-threading.
REGENERATE_METADATA = ON | OFF [ON] -- When this is set to OFF it will skip
regenerating the metadata with
BuildMetadataCppFromXml. Since the
metadata is included in the source
tree anyway, it is beneficial for
packagers to turn this OFF: it saves
some time, and it also makes it
unnecessary to have java in the build
environment.

Loading…
Cancel
Save