From 5ef2e27e8e0f18cbef015e4943e70abfb4679c1b Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 13 Oct 2021 10:16:39 +0200 Subject: [PATCH] [CMake] add boost regex icu check --- CMakeLists.txt | 11 +++++++++-- cmake/CheckBoostRegexIcu.cmake | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 cmake/CheckBoostRegexIcu.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ed5392ba3..47bbaa15d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,22 +129,29 @@ set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") # needs to be before the first call of find_boost. if(USE_MULTITHREADED) - message(STATUS "multithreaded enabled") set(Boost_USE_MULTITHREADED ON) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_THREADSAFE) else() set(Boost_USE_MULTITHREADED OFF) - message(STATUS "multithreaded disabled") endif() + find_package(PkgConfig) mapnik_find_threads() mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) + mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system regex) +list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU) if(USE_BOOST_REGEX_ICU_WORKAROUND) message(STATUS "using boost regex workaround") set_property(TARGET Boost::regex PROPERTY INTERFACE_LINK_LIBRARIES) endif() +include(CheckBoostRegexIcu) +check_boost_regex() +if(BOOST_REGEX_HAS_ICU) + message(STATUS "boost regex has icu support") + list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU) +endif() mapnik_find_package(Freetype REQUIRED) diff --git a/cmake/CheckBoostRegexIcu.cmake b/cmake/CheckBoostRegexIcu.cmake new file mode 100644 index 000000000..b2e7b9430 --- /dev/null +++ b/cmake/CheckBoostRegexIcu.cmake @@ -0,0 +1,23 @@ +include(CheckCXXSourceRuns) + +function(check_boost_regex) + set(CMAKE_REQUIRED_LIBRARIES ICU::uc ICU::data ICU::i18n Boost::headers Boost::regex) + check_cxx_source_runs([[ + #include + #include + int main() + { + U_NAMESPACE_QUALIFIER UnicodeString ustr; + try { + boost::u32regex pattern = boost::make_u32regex(ustr); + } + // an exception is fine, still indicates support is + // likely compiled into regex + catch (...) { + return 0; + } + return 0; + } + ]] BOOST_REGEX_HAS_ICU) + set(BOOST_REGEX_HAS_ICU ${BOOST_REGEX_HAS_ICU} PARENT_SCOPE) +endfunction(check_boost_regex)