2021-07-25 15:10:51 -04:00
|
|
|
option(ENABLE_UNICODE_DATABASE_DOWNLOAD "Enable download of Unicode UCD files at build time" ON)
|
|
|
|
|
|
|
|
set(UNICODE_DATA_URL https://www.unicode.org/Public/13.0.0/ucd/UnicodeData.txt)
|
|
|
|
set(UNICODE_DATA_PATH ${CMAKE_BINARY_DIR}/UCD/UnicodeData.txt)
|
|
|
|
|
2021-07-27 10:39:37 -04:00
|
|
|
set(SPECIAL_CASING_URL https://www.unicode.org/Public/13.0.0/ucd/SpecialCasing.txt)
|
|
|
|
set(SPECIAL_CASING_PATH ${CMAKE_BINARY_DIR}/UCD/SpecialCasing.txt)
|
|
|
|
|
2021-07-27 17:37:47 -04:00
|
|
|
set(PROP_LIST_URL https://www.unicode.org/Public/13.0.0/ucd/PropList.txt)
|
|
|
|
set(PROP_LIST_PATH ${CMAKE_BINARY_DIR}/UCD/PropList.txt)
|
|
|
|
|
2021-07-27 18:24:39 -04:00
|
|
|
set(WORD_BREAK_URL https://www.unicode.org/Public/13.0.0/ucd/auxiliary/WordBreakProperty.txt)
|
|
|
|
set(WORD_BREAK_PATH ${CMAKE_BINARY_DIR}/UCD/WordBreakProperty.txt)
|
|
|
|
|
2021-07-25 15:10:51 -04:00
|
|
|
if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
|
|
|
|
if (NOT EXISTS ${UNICODE_DATA_PATH})
|
|
|
|
message(STATUS "Downloading UCD UnicodeData.txt from ${UNICODE_DATA_URL}...")
|
|
|
|
file(DOWNLOAD ${UNICODE_DATA_URL} ${UNICODE_DATA_PATH} INACTIVITY_TIMEOUT 10)
|
|
|
|
endif()
|
2021-07-27 10:39:37 -04:00
|
|
|
if (NOT EXISTS ${SPECIAL_CASING_PATH})
|
|
|
|
message(STATUS "Downloading UCD SpecialCasing.txt from ${SPECIAL_CASING_URL}...")
|
|
|
|
file(DOWNLOAD ${SPECIAL_CASING_URL} ${SPECIAL_CASING_PATH} INACTIVITY_TIMEOUT 10)
|
|
|
|
endif()
|
2021-07-27 17:37:47 -04:00
|
|
|
if (NOT EXISTS ${PROP_LIST_PATH})
|
|
|
|
message(STATUS "Downloading UCD PropList.txt from ${PROP_LIST_URL}...")
|
|
|
|
file(DOWNLOAD ${PROP_LIST_URL} ${PROP_LIST_PATH} INACTIVITY_TIMEOUT 10)
|
|
|
|
endif()
|
2021-07-27 18:24:39 -04:00
|
|
|
if (NOT EXISTS ${WORD_BREAK_PATH})
|
|
|
|
message(STATUS "Downloading UCD WordBreakProperty.txt from ${WORD_BREAK_URL}...")
|
|
|
|
file(DOWNLOAD ${WORD_BREAK_URL} ${WORD_BREAK_PATH} INACTIVITY_TIMEOUT 10)
|
|
|
|
endif()
|
2021-07-25 15:10:51 -04:00
|
|
|
|
2021-07-29 04:18:52 -04:00
|
|
|
set(UNICODE_DATA_HEADER LibUnicode/UnicodeData.h)
|
|
|
|
set(UNICODE_DATA_IMPLEMENTATION LibUnicode/UnicodeData.cpp)
|
2021-07-25 15:10:51 -04:00
|
|
|
|
2021-07-29 04:18:52 -04:00
|
|
|
if (CMAKE_CURRENT_BINARY_DIR MATCHES ".*/LibUnicode") # Serenity build.
|
|
|
|
set(UNICODE_DATA_HEADER UnicodeData.h)
|
|
|
|
set(UNICODE_DATA_IMPLEMENTATION UnicodeData.cpp)
|
2021-07-25 15:15:47 -04:00
|
|
|
endif()
|
|
|
|
|
2021-07-25 15:10:51 -04:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${UNICODE_DATA_HEADER}
|
2021-07-29 04:18:52 -04:00
|
|
|
COMMAND ${write_if_different} ${UNICODE_DATA_HEADER} $<TARGET_FILE:GenerateUnicodeData> -h -u ${UNICODE_DATA_PATH} -s ${SPECIAL_CASING_PATH} -p ${PROP_LIST_PATH} -w ${WORD_BREAK_PATH}
|
2021-07-25 15:10:51 -04:00
|
|
|
VERBATIM
|
|
|
|
DEPENDS GenerateUnicodeData
|
2021-07-27 10:39:37 -04:00
|
|
|
MAIN_DEPENDENCY ${UNICODE_DATA_PATH} ${SPECIAL_CASING_PATH}
|
2021-07-25 15:10:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${UNICODE_DATA_IMPLEMENTATION}
|
2021-07-29 04:18:52 -04:00
|
|
|
COMMAND ${write_if_different} ${UNICODE_DATA_IMPLEMENTATION} $<TARGET_FILE:GenerateUnicodeData> -c -u ${UNICODE_DATA_PATH} -s ${SPECIAL_CASING_PATH} -p ${PROP_LIST_PATH} -w ${WORD_BREAK_PATH}
|
2021-07-25 15:10:51 -04:00
|
|
|
VERBATIM
|
|
|
|
DEPENDS GenerateUnicodeData
|
2021-07-27 10:39:37 -04:00
|
|
|
MAIN_DEPENDENCY ${UNICODE_DATA_PATH} ${SPECIAL_CASING_PATH}
|
2021-07-25 15:10:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
set(UNICODE_DATA_SOURCES ${UNICODE_DATA_HEADER} ${UNICODE_DATA_IMPLEMENTATION})
|
|
|
|
add_compile_definitions(ENABLE_UNICODE_DATA=1)
|
|
|
|
else()
|
|
|
|
add_compile_definitions(ENABLE_UNICODE_DATA=0)
|
|
|
|
endif()
|