summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-06-21 14:44:00 +0200
committerKonstantin Käfer <mail@kkaefer.com>2018-09-11 11:43:54 +0200
commit30e570aae7d2ba5522feafb962b334ef3f35459e (patch)
tree5a8f787197772ed302e1fbf45839d973feb80838 /cmake
parent536652ca201ce59190ae5c41d1202372d28d6d6d (diff)
downloadqtlocation-mapboxgl-30e570aae7d2ba5522feafb962b334ef3f35459e.tar.gz
[core] add polyfill for codecvt for STLs that don't have it yet
Diffstat (limited to 'cmake')
-rw-r--r--cmake/codecvt.cmake19
-rw-r--r--cmake/core.cmake2
2 files changed, 21 insertions, 0 deletions
diff --git a/cmake/codecvt.cmake b/cmake/codecvt.cmake
new file mode 100644
index 0000000000..8228a6df6b
--- /dev/null
+++ b/cmake/codecvt.cmake
@@ -0,0 +1,19 @@
+add_library(codecvt INTERFACE)
+
+# Determine if the STL has codecvt
+file(WRITE "${CMAKE_BINARY_DIR}/features/codecvt/main.cpp" "#include <codecvt>\nint main() {}")
+try_compile(STL_SUPPORTS_CODECVT
+ "${CMAKE_BINARY_DIR}/features/codecvt"
+ SOURCES "${CMAKE_BINARY_DIR}/features/codecvt/main.cpp"
+ CMAKE_FLAGS "-DCMAKE_MACOSX_BUNDLE:STRING=YES" "-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED:STRING=NO"
+ COMPILE_DEFINITIONS "-std=c++14" # CXX_STANDARD wasn't added to try_compile until CMake 3.8
+ OUTPUT_VARIABLE CODECVT_TEST_OUTPUT
+)
+
+if (NOT STL_SUPPORTS_CODECVT)
+ if ($ENV{V})
+ message("codecvt support not detected: ${CODECVT_TEST_OUTPUT}")
+ endif()
+ target_include_directories(codecvt INTERFACE platform/default/codecvt)
+ target_add_mason_package(codecvt INTERFACE boost)
+endif()
diff --git a/cmake/core.cmake b/cmake/core.cmake
index 32e77f5d55..1b29b4fb08 100644
--- a/cmake/core.cmake
+++ b/cmake/core.cmake
@@ -7,6 +7,8 @@ target_include_directories(mbgl-core
PRIVATE src
)
+target_link_libraries(mbgl-core PRIVATE codecvt)
+
target_add_mason_package(mbgl-core PUBLIC geometry)
target_add_mason_package(mbgl-core PUBLIC variant)
target_add_mason_package(mbgl-core PRIVATE unique_resource)