[CMake] add boost regex icu check

This commit is contained in:
Mathis Logemann 2021-10-13 10:16:39 +02:00
parent 01dccee231
commit 5ef2e27e8e
2 changed files with 32 additions and 2 deletions

View file

@ -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)

View file

@ -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 <boost/regex/icu.hpp>
#include <unicode/unistr.h>
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)