Qt build improvements and documentation (#277)

* Qt build improvements and documentation

* Update include/mbgl/actor/actor_ref.hpp

Co-authored-by: Oliver Wipfli <oliver.wipfli@leichteralsluft.ch>
This commit is contained in:
Tadej Novak
2022-06-16 20:52:52 +02:00
committed by GitHub
parent 6dbc711e07
commit 9cd70bfe7f
29 changed files with 401 additions and 148 deletions

5
.github/actions/qt5-build/Dockerfile vendored Normal file
View File

@@ -0,0 +1,5 @@
FROM ghcr.io/maplibre/linux-builder:centos7
# Copy and set the entry point
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

6
.github/actions/qt5-build/action.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
# action.yml
name: 'Qt5 Linux Builder'
description: 'Helper action to build in a specific Docker container'
runs:
using: 'docker'
image: 'Dockerfile'

19
.github/actions/qt5-build/entrypoint.sh vendored Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash -l
source scl_source enable devtoolset-8 rh-git218
set -e
set -x
export CCACHE_DIR="$GITHUB_WORKSPACE/.ccache"
export PATH="$Qt5_Dir/bin:$PATH"
mkdir build && cd build
cmake ../source/ \
-G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DMBGL_WITH_QT=ON \
-DMBGL_QT_LIBRARY_ONLY=ON \
-DCMAKE_INSTALL_PREFIX="../install/"
ninja
ninja install

View File

@@ -70,6 +70,11 @@ jobs:
strategy: strategy:
matrix: matrix:
include: include:
- name: Linux
os: ubuntu-latest
static: OFF
qt: 5.15.2
qt_target: desktop
- name: macOS - name: macOS
os: macos-latest os: macos-latest
static: OFF static: OFF
@@ -80,11 +85,11 @@ jobs:
static: ON static: ON
qt: 5.15.2 qt: 5.15.2
qt_target: desktop qt_target: desktop
# - name: iOS_static - name: iOS_static
# os: macos-latest os: macos-latest
# static: ON static: ON
# qt: 5.15.2 qt: 5.15.2
# qt_target: ios qt_target: ios
- name: macOS - name: macOS
os: macos-latest os: macos-latest
static: ON static: ON
@@ -97,7 +102,7 @@ jobs:
qt_target: desktop qt_target: desktop
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
BUILD_TYPE: Debug BUILD_TYPE: RelWithDebInfo
BUILD_MODE: ${{ matrix.static }} BUILD_MODE: ${{ matrix.static }}
QT_VERSION: ${{ matrix.qt }} QT_VERSION: ${{ matrix.qt }}
@@ -109,7 +114,7 @@ jobs:
submodules: recursive submodules: recursive
fetch-depth: 0 fetch-depth: 0
- name: Install dependencies - name: Install macOS dependencies
if: runner.os == 'macOS' if: runner.os == 'macOS'
env: env:
HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_AUTO_UPDATE: 1
@@ -120,6 +125,7 @@ jobs:
brew list ninja || brew install ninja brew list ninja || brew install ninja
- name: Setup Xcode - name: Setup Xcode
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1 uses: maxim-lobanov/setup-xcode@v1
with: with:
xcode-version: latest-stable xcode-version: latest-stable
@@ -128,9 +134,11 @@ jobs:
uses: jurplel/install-qt-action@v2 uses: jurplel/install-qt-action@v2
with: with:
version: ${{ env.QT_VERSION }} version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}
target: ${{ matrix.qt_target }} target: ${{ matrix.qt_target }}
- name: Prepare ccache - name: Prepare ccache
if: runner.os == 'macOS'
run: | run: |
ccache --clear ccache --clear
ccache --set-config cache_dir=~/.ccache ccache --set-config cache_dir=~/.ccache
@@ -148,6 +156,7 @@ jobs:
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.name }}-${{ matrix.qt }}-${{ github.job }} ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.name }}-${{ matrix.qt }}-${{ github.job }}
- name: Clear ccache statistics - name: Clear ccache statistics
if: runner.os == 'macOS'
run: | run: |
ccache --zero-stats ccache --zero-stats
ccache --max-size=2G ccache --max-size=2G
@@ -161,7 +170,6 @@ jobs:
-G Ninja \ -G Ninja \
-DMBGL_WITH_QT=ON \ -DMBGL_WITH_QT=ON \
-DMBGL_QT_STATIC=${BUILD_MODE} \ -DMBGL_QT_STATIC=${BUILD_MODE} \
-DMBGL_QT_WITH_INTERNAL_SQLITE=OFF \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=../install \ -DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
@@ -174,22 +182,25 @@ jobs:
run: | run: |
mkdir build && cd build mkdir build && cd build
cmake ../source/ \ cmake ../source/ \
-DCMAKE_TOOLCHAIN_FILE=../source/platform/ios/platform/ios/toolchain.cmake \ -G"Ninja Multi-Config" \
-G XCode \ -DCMAKE_SYSTEM_NAME=iOS \
-DPLATFORM=OS64COMBINED \ -DCMAKE_CONFIGURATION_TYPES="Release;Debug" \
-DDEPLOYMENT_TARGET=12.0 \ -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DENABLE_BITCODE=ON \ -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \
-DMBGL_WITH_QT=ON \ -DMBGL_WITH_QT=ON \
-DMBGL_WITH_WERROR=OFF \
-DMBGL_QT_LIBRARY_ONLY=ON \
-DMBGL_QT_STATIC=${BUILD_MODE} \ -DMBGL_QT_STATIC=${BUILD_MODE} \
-DMBGL_QT_WITH_INTERNAL_SQLITE=OFF \ -DMBGL_QT_LIBRARY_ONLY=ON \
-DMBGL_QT_WITH_IOS_CCACHE=ON \ -DMBGL_QT_WITH_IOS_CCACHE=ON \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_INSTALL_PREFIX=../install -DCMAKE_FIND_ROOT_PATH="$Qt5_Dir" \
-DCMAKE_PREFIX_PATH="$Qt5_Dir"
cmake --build . --config Release cmake --build . --config Release
cmake --install . --config Release cmake --install . --config Release
- name: Build maplibre-gl-native (Linux)
if: runner.os == 'Linux'
uses: ./source/.github/actions/qt5-build
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
@@ -197,5 +208,6 @@ jobs:
path: install path: install
- name: Show ccache statistics - name: Show ccache statistics
if: runner.os == 'macOS'
run: | run: |
ccache --show-stats -v ccache --show-stats -v

View File

@@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
option(MBGL_WITH_CORE_ONLY "Build only the core bits, no platform code" OFF) option(MBGL_WITH_CORE_ONLY "Build only the core bits, no platform code" OFF)
option(MBGL_WITH_COVERAGE "Enable code coverage collection" OFF) option(MBGL_WITH_COVERAGE "Enable code coverage collection" OFF)
option(MBGL_WITH_QT "Build Mapbox GL Qt bindings" OFF) option(MBGL_WITH_QT "Build Mapbox GL Qt bindings" OFF)
option(MBGL_QT_STATIC "Build Mapbox GL Qt bindings staticly" OFF)
option(MBGL_WITH_SANITIZER "Use [address|thread|undefined] here" OFF) option(MBGL_WITH_SANITIZER "Use [address|thread|undefined] here" OFF)
option(MBGL_WITH_RTTI "Compile with runtime type information" OFF) option(MBGL_WITH_RTTI "Compile with runtime type information" OFF)
option(MBGL_WITH_OPENGL "Build with OpenGL renderer" ON) option(MBGL_WITH_OPENGL "Build with OpenGL renderer" ON)
@@ -55,6 +54,7 @@ target_compile_options(
-fsanitize-blacklist=${UBSAN_BLACKLIST}> -fsanitize-blacklist=${UBSAN_BLACKLIST}>
$<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=float-divide-by-zero, $<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=float-divide-by-zero,
-fsanitize-blacklist=${UBSAN_BLACKLIST}> -fsanitize-blacklist=${UBSAN_BLACKLIST}>
$<$<PLATFORM_ID:iOS>:-fembed-bitcode>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<OR:$<BOOL:${MBGL_WITH_RTTI}>,$<CXX_COMPILER_ID:MSVC>>>>:-fno-rtti> $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<OR:$<BOOL:${MBGL_WITH_RTTI}>,$<CXX_COMPILER_ID:MSVC>>>>:-fno-rtti>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wall> $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wall>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wshadow> $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wshadow>
@@ -68,10 +68,10 @@ target_compile_options(
$<$<AND:$<CXX_COMPILER_ID:AppleClang>,$<NOT:$<BOOL:${MBGL_WITH_QT}>>>:-Wno-error=unused-parameter> $<$<AND:$<CXX_COMPILER_ID:AppleClang>,$<NOT:$<BOOL:${MBGL_WITH_QT}>>>:-Wno-error=unused-parameter>
$<$<AND:$<CXX_COMPILER_ID:AppleClang>,$<NOT:$<BOOL:${MBGL_WITH_QT}>>>:-Wno-error=unused-property-ivar> $<$<AND:$<CXX_COMPILER_ID:AppleClang>,$<NOT:$<BOOL:${MBGL_WITH_QT}>>>:-Wno-error=unused-property-ivar>
$<$<CXX_COMPILER_ID:MSVC>:/utf-8> $<$<CXX_COMPILER_ID:MSVC>:/utf-8>
# $<$<CXX_COMPILER_ID:MSVC>:/WX> # all warnings as errors $<$<CXX_COMPILER_ID:MSVC>:/WX> # all warnings as errors
$<$<CXX_COMPILER_ID:MSVC>:/EHsc> # exceptions
$<$<CXX_COMPILER_ID:MSVC>:/wd4068> # pragma $<$<CXX_COMPILER_ID:MSVC>:/wd4068> # pragma
$<$<CXX_COMPILER_ID:MSVC>:/wd4244> # types $<$<CXX_COMPILER_ID:MSVC>:/D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:/wd4828> # encoding
$<$<CXX_COMPILER_ID:MSVC>:/D_CRT_SECURE_NO_WARNINGS> $<$<CXX_COMPILER_ID:MSVC>:/D_CRT_SECURE_NO_WARNINGS>
) )
@@ -93,12 +93,16 @@ set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_C_VISIBILITY_PRESET hidden)
if (CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
set(CMAKE_CROSS_CONFIGS "all")
set(CMAKE_DEFAULT_CONFIGS "all")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL ON) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
if(MBGL_QT_STATIC) if(MBGL_WITH_QT AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
add_library(mbgl-core OBJECT) add_library(mbgl-core OBJECT)
else() else()
add_library(mbgl-core STATIC) add_library(mbgl-core STATIC)
@@ -1020,6 +1024,38 @@ target_link_libraries(
Mapbox::Base::variant Mapbox::Base::variant
) )
export(TARGETS
mbgl-core
mapbox-base
mapbox-base-cheap-ruler-cpp
mapbox-base-extras-expected-lite
mapbox-base-extras-kdbush.hpp
mapbox-base-extras-rapidjson
mapbox-base-geojson-vt-cpp
mapbox-base-geojson.hpp
mapbox-base-geometry.hpp
mapbox-base-jni.hpp
mapbox-base-optional
mapbox-base-pixelmatch-cpp
mapbox-base-shelf-pack-cpp
mapbox-base-supercluster.hpp
mapbox-base-variant
mbgl-compiler-options
mbgl-vendor-boost
mbgl-vendor-csscolorparser
mbgl-vendor-earcut.hpp
mbgl-vendor-eternal
mbgl-vendor-parsedate
mbgl-vendor-polylabel
mbgl-vendor-protozero
mbgl-vendor-unique_resource
mbgl-vendor-vector-tile
mbgl-vendor-wagyu
FILE MapboxCoreTargets.cmake
)
set_target_properties( set_target_properties(
mbgl-core mbgl-core
PROPERTIES PROPERTIES

View File

@@ -38,7 +38,11 @@ public:
template <typename Fn, class... Args> template <typename Fn, class... Args>
auto ask(Fn fn, Args&&... args) const { auto ask(Fn fn, Args&&... args) const {
// Result type is deduced from the function's return type // Result type is deduced from the function's return type
#if __cplusplus >= 201703L
using ResultType = std::invoke_result_t<decltype(fn), Object, Args...>;
#else
using ResultType = typename std::result_of<decltype(fn)(Object, Args...)>::type; using ResultType = typename std::result_of<decltype(fn)(Object, Args...)>::type;
#endif
std::promise<ResultType> promise; std::promise<ResultType> promise;
auto future = promise.get_future(); auto future = promise.get_future();

View File

@@ -1,108 +1,44 @@
# MapLibre Maps SDK for Qt # MapLibre Maps SDK for Qt
## Developing This is a community maintained MapLibre SDK for usage in Qt apps.
Both Qt5 (minimal 5.6) and Qt6 are supported.
Note that only OpenGL rendering is supported at the moment.
This is the foundation for the [Mapbox GL plugin](https://doc.qt.io/qt-5/location-plugin-mapboxgl.html) ## Supported platforms
available in the Qt SDK since Qt 5.9. Use the [Qt bugtracker](https://bugreports.qt.io) for bugs related
to the plugin and this GitHub repository for bugs related to MapLibre GL Native and the Qt bindings.
You should build this repository if you want to develop/contribute using the low level Qt C++ bindings or - macOS
want to contribute to the MapLibre GL Native project using the Qt port for debugging. - iOS
- Android
- Linux
- Windows
### Build dependencies ## Building
#### Linux This project uses out of source build. CMake 3.10 or later is used to generate
make files. Ninja is recommended.
For Linux (tested on Ubuntu) desktop, together with these [build instructions](../linux/README.md), you also need: Before the project can be built Qt installation needs to be added to the `PATH`:
``` ```shell
$ sudo apt-get install qt5-default export PATH=<path_to_Qt>/Qt/<Qt_version>/<Qt_platform>/bin:$PATH
``` ```
#### macOS A minimal set of commands to build and install is
For macOS desktop, you can install Qt 5 via [Homebrew](https://brew.sh): ```shell
mkdir build && cd build
``` cmake ../maplibre-gl-native/ \
$ brew install qt5 -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=<installation_prefix> \
-DMBGL_WITH_QT=ON
ninja
ninja install
``` ```
Since Homebrew doesn't add Qt to the path, you'll have to do that manually before running any Make target: `<installation_prefix>` above should be replaced with a wished installation path.
Files installed there can later be used as the dependency for your app.
``` For platform-specific details look at build scripts provided
export PATH=/usr/local/opt/qt5/bin:$PATH in the [scripts](scripts) folder. Each script requires (at least) paths
``` to source and installation locations.
### Windows
The Windows build will assume you have installed and on the default path:
- Microsoft Visual Studio 2019
- [CMake 3.10.1+](https://cmake.org/download/)
- [Ninja](https://github.com/ninja-build/ninja/releases)
- [Qt 5.4+](https://www.qt.io/download) with "msvc2019" (or later) support.
At runtime, you will also need installed:
- [OpenSSL 1.0.2+](https://slproweb.com/products/Win32OpenSSL.html)
- DirectX
#### QNX 7.0
To build for QNX 7.0, you need to install the QNX Software Development Platform (SDP) on a Linux host.
http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.qnxsdp.nav/topic/bookset.html
After installing the SDP, you need to source the QNX environment script:
```
source <SDP_DIRECTORY>/qnxsdp-env.sh
```
You also need to Build Qt for QNX.
http://wiki.qt.io/Building_Qt_for_QNX_Neutrino_OS
After building Qt for QNX, you need to add Qt installation's bin directory to the path.
```
export PATH=<INSTALLFOLDER>/bin:$PATH
```
### Build instructions
Public API headers can be found in the [platform/qt/include](include) directory.
#### Linux and macOS
#### QMapboxGL example application
```
$ make qt-lib # Will build libqmapboxgl.so
$ make qt-app # Will build the test app and libqmapboxgl.so if not built yet
$ make run-qt-app # Will build and run the test app
```
#### Windows
```
$ mkdir build
$ cd build
$ cmake -G Ninja -DMBGL_WITH_QT=ON -DCMAKE_BUILD_TYPE=Release ..
$ ninja
```
You may need to specify the path to Qt:
```
$ cmake -G Ninja -DMBGL_WITH_QT=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=C:\Qt\5.15.2\msvc2019_64\lib\cmake ..
```
#### QNX 7.0
Building the repository for QNX 7.0 is very similar to other platforms (e.g. Linux and macOS).
```
$ make qnx-qt-lib # Will build libqmapboxgl.so
```

View File

@@ -9,10 +9,14 @@
// This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style // This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style
#if defined(QT_BUILD_MAPBOXGL_LIB) #if !defined(QT_MAPBOXGL_STATIC)
# if defined(QT_BUILD_MAPBOXGL_LIB)
# define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT # define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT
#else # else
# define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT # define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT
# endif
#else
# define Q_MAPBOXGL_EXPORT
#endif #endif
namespace QMapbox { namespace QMapbox {

View File

@@ -4,13 +4,13 @@ message(STATUS "Configuring GL-Native with Qt bindings")
file(READ "${PROJECT_SOURCE_DIR}/platform/qt/VERSION" MBGL_QT_VERSION) file(READ "${PROJECT_SOURCE_DIR}/platform/qt/VERSION" MBGL_QT_VERSION)
string(REGEX REPLACE "\n" "" MBGL_QT_VERSION "${MBGL_QT_VERSION}") # get rid of the newline at the end string(REGEX REPLACE "\n" "" MBGL_QT_VERSION "${MBGL_QT_VERSION}") # get rid of the newline at the end
set(MBGL_QT_VERSION_COMPATIBILITY 2.0.0) set(MBGL_QT_VERSION_COMPATIBILITY 2.0.0)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Version ${MBGL_QT_VERSION}") message(STATUS "Version ${MBGL_QT_VERSION}")
option(MBGL_QT_LIBRARY_ONLY "Build only libraries" OFF) option(MBGL_QT_LIBRARY_ONLY "Build only libraries" OFF)
option(MBGL_QT_INSIDE_QT_PLUGIN "Build qmapboxgl as OBJECT library, so it can be bundled into separate single plugin lib." OFF) option(MBGL_QT_STATIC "Build Mapbox GL Qt bindings staticly" OFF)
option(MBGL_QT_INSIDE_PLUGIN "Build qmapboxgl as OBJECT library, so it can be bundled into separate single plugin lib." OFF)
option(MBGL_WITH_QT_HEADLESS "Build Mapbox GL Qt with headless support" ON) option(MBGL_WITH_QT_HEADLESS "Build Mapbox GL Qt with headless support" ON)
option(MBGL_QT_WITH_INTERNAL_SQLITE "Build Mapbox GL Qt bindings with internal sqlite" $<NOT:$<BOOL:${MBGL_QT_STATIC}>>) option(MBGL_QT_WITH_INTERNAL_SQLITE "Build Mapbox GL Qt bindings with internal sqlite" OFF)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} find_package(Qt${QT_VERSION_MAJOR}
@@ -63,10 +63,10 @@ endif()
if(ANDROID) if(ANDROID)
message(STATUS "Building for ABI: ${ANDROID_ABI}") message(STATUS "Building for ABI: ${ANDROID_ABI}")
set(CMAKE_STATIC_LIBRARY_SUFFIX "_${ANDROID_ABI}.a") set(CMAKE_STATIC_LIBRARY_SUFFIX "_${ANDROID_ABI}.a")
elseif(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
set(CMAKE_STATIC_LIBRARY_SUFFIX "d.lib") set(CMAKE_DEBUG_POSTFIX "_debug")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_BUILD_TYPE STREQUAL "Debug") elseif(MSVC OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_STATIC_LIBRARY_SUFFIX "d.a") set(CMAKE_DEBUG_POSTFIX "d")
endif() endif()
target_sources( target_sources(
@@ -150,7 +150,7 @@ set_property(TARGET mbgl-core PROPERTY AUTOMOC ON)
target_link_libraries( target_link_libraries(
mbgl-core mbgl-core
PRIVATE PRIVATE
$<$<NOT:$<PLATFORM_ID:Windows,Emscripten>>:z> $<$<NOT:$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Emscripten>>>:z>
Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Network
@@ -166,12 +166,10 @@ set(qmapboxgl_headers
${PROJECT_SOURCE_DIR}/platform/qt/include/qmapboxgl.hpp ${PROJECT_SOURCE_DIR}/platform/qt/include/qmapboxgl.hpp
) )
if(MBGL_QT_STATIC) if (MBGL_QT_INSIDE_PLUGIN)
if(MBGL_QT_INSIDE_QT_PLUGIN)
add_library(qmapboxgl OBJECT) add_library(qmapboxgl OBJECT)
else() elseif(MBGL_QT_STATIC)
add_library(qmapboxgl STATIC) add_library(qmapboxgl STATIC)
endif()
else() else()
add_library(qmapboxgl SHARED) add_library(qmapboxgl SHARED)
endif() endif()
@@ -206,7 +204,7 @@ set_target_properties(
SOVERSION ${MBGL_QT_VERSION_COMPATIBILITY} SOVERSION ${MBGL_QT_VERSION_COMPATIBILITY}
PUBLIC_HEADER "${qmapboxgl_headers}" PUBLIC_HEADER "${qmapboxgl_headers}"
) )
if (NOT MBGL_QT_STATIC) if (NOT MBGL_QT_STATIC AND NOT MBGL_QT_INSIDE_PLUGIN)
set_target_properties( set_target_properties(
qmapboxgl PROPERTIES qmapboxgl PROPERTIES
FRAMEWORK ON FRAMEWORK ON
@@ -232,6 +230,8 @@ install(EXPORT QMapboxGLTargets
DESTINATION ${CMAKECONFIG_INSTALL_DIR} DESTINATION ${CMAKECONFIG_INSTALL_DIR}
COMPONENT development) COMPONENT development)
export(EXPORT QMapboxGLTargets)
install(FILES install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/QMapboxGLConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/QMapboxGLConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/QMapboxGLConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/QMapboxGLConfigVersion.cmake"
@@ -305,7 +305,7 @@ if(NOT MBGL_QT_LIBRARY_ONLY)
target_compile_definitions( target_compile_definitions(
mbgl-qt mbgl-qt
PRIVATE PRIVATE
$<$<BOOL:${MBGL_QT_STATIC}>:QT_MAPBOXGL_STATIC> $<$<OR:$<BOOL:${MBGL_QT_STATIC}>,$<BOOL:${MBGL_QT_INSIDE_PLUGIN}>>:QT_MAPBOXGL_STATIC>
) )
target_link_libraries( target_link_libraries(
@@ -320,7 +320,7 @@ if(NOT MBGL_QT_LIBRARY_ONLY)
target_include_directories( target_include_directories(
mbgl-qt mbgl-qt
PUBLIC ${PROJECT_SOURCE_DIR}/platform/qt/include PRIVATE ${PROJECT_SOURCE_DIR}/platform/qt/include
) )
add_executable( add_executable(
@@ -330,7 +330,7 @@ if(NOT MBGL_QT_LIBRARY_ONLY)
target_include_directories( target_include_directories(
mbgl-test-runner mbgl-test-runner
PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include
) )
target_compile_definitions( target_compile_definitions(

View File

@@ -0,0 +1,34 @@
#!/bin/bash
if [[ -z ${1+x} ]]; then
echo "Error: Pass the path to maplibre-gl-native as first argument" 1>&2
exit 1
fi
if [[ -z ${2+x} ]]; then
echo "Error: Pass the install prefix as the second argument" 1>&2
exit 2
fi
if [[ -z ${3+x} ]]; then
echo "Error: Pass Qt installation path as the third argument" 1>&2
exit 3
fi
if [[ -z ${4+x} ]]; then
echo "Error: Pass Android ABI as the fourth argument" 1>&2
exit 3
fi
cmake "$1" \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI="$4" \
-DANDROID_NATIVE_API_LEVEL=21 \
-G Ninja \
-DMBGL_WITH_QT=ON \
-DMBGL_QT_STATIC=ON \
-DMBGL_QT_LIBRARY_ONLY=ON \
-DCMAKE_CXX_FLAGS_RELEASE=-g0 \
-DCMAKE_INSTALL_PREFIX="$2" \
-DCMAKE_FIND_ROOT_PATH="$3/android" \
-DCMAKE_PREFIX_PATH="$3/android"

View File

@@ -0,0 +1,17 @@
#!/bin/bash
if [[ -z ${1+x} ]]; then
echo "Error: Pass the path to maplibre-gl-native as first argument" 1>&2
exit 1
fi
if [[ -z ${2+x} ]]; then
echo "Error: Pass the install prefix as the second argument" 1>&2
exit 2
fi
cmake "$1" \
-G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DMBGL_WITH_QT=ON \
-DCMAKE_INSTALL_PREFIX="$2"

View File

@@ -0,0 +1,8 @@
$path = $args[0]
$install = $args[1]
cmake -S "$path" `
-GNinja `
-DCMAKE_BUILD_TYPE="Release" `
-DCMAKE_INSTALL_PREFIX="$install" `
-DMBGL_WITH_QT=ON

View File

@@ -0,0 +1,10 @@
$path = $args[0]
$install = $args[1]
cmake -S "$path" `
-GNinja `
-DCMAKE_BUILD_TYPE="Release" `
-DCMAKE_INSTALL_PREFIX="$install" `
-DMBGL_WITH_QT=ON `
-DMBGL_QT_STATIC=ON `
-DMBGL_QT_LIBRARY_ONLY=ON

View File

@@ -0,0 +1,29 @@
#!/bin/bash
if [[ -z ${1+x} ]]; then
echo "Error: Pass the path to maplibre-gl-native as first argument" 1>&2
exit 1
fi
if [[ -z ${2+x} ]]; then
echo "Error: Pass the install prefix as the second argument" 1>&2
exit 2
fi
if [[ -z ${3+x} ]]; then
echo "Error: Pass Qt installation path as the third argument" 1>&2
exit 3
fi
cmake "$1" \
-G"Ninja Multi-Config" \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_CONFIGURATION_TYPES="Release;Debug" \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \
-DMBGL_WITH_QT=ON \
-DMBGL_QT_STATIC=ON \
-DMBGL_QT_LIBRARY_ONLY=ON \
-DCMAKE_INSTALL_PREFIX="$2" \
-DCMAKE_FIND_ROOT_PATH="$3/ios" \
-DCMAKE_PREFIX_PATH="$3/ios"

View File

@@ -0,0 +1,18 @@
#!/bin/bash
if [[ -z ${1+x} ]]; then
echo "Error: Pass the path to maplibre-gl-native as first argument" 1>&2
exit 1
fi
if [[ -z ${2+x} ]]; then
echo "Error: Pass the install prefix as the second argument" 1>&2
exit 2
fi
cmake "$1" \
-G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
-DMBGL_WITH_QT=ON \
-DCMAKE_INSTALL_PREFIX="$2"

View File

@@ -0,0 +1,20 @@
#!/bin/bash
if [[ -z ${1+x} ]]; then
echo "Error: Pass the path to maplibre-gl-native as first argument" 1>&2
exit 1
fi
if [[ -z ${2+x} ]]; then
echo "Error: Pass the install prefix as the second argument" 1>&2
exit 2
fi
cmake "$1" \
-G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
-DMBGL_WITH_QT=ON \
-DMBGL_QT_STATIC=ON \
-DMBGL_QT_LIBRARY_ONLY=ON \
-DCMAKE_INSTALL_PREFIX="$2"

View File

@@ -0,0 +1,8 @@
$path = $args[0]
$install = $args[1]
qt-cmake -S "$path" `
-GNinja `
-DCMAKE_BUILD_TYPE="Release" `
-DCMAKE_INSTALL_PREFIX="$install" `
-DMBGL_WITH_QT=ON

View File

@@ -0,0 +1,19 @@
#!/bin/bash
if [[ -z ${1+x} ]]; then
echo "Error: Pass the path to maplibre-gl-native as first argument" 1>&2
exit 1
fi
if [[ -z ${2+x} ]]; then
echo "Error: Pass the install prefix as the second argument" 1>&2
exit 2
fi
qt-cmake "$1" \
-G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
-DMBGL_WITH_QT=ON \
-DCMAKE_INSTALL_PREFIX="$2"

View File

@@ -0,0 +1,21 @@
#!/bin/bash
if [[ -z ${1+x} ]]; then
echo "Error: Pass the path to maplibre-gl-native as first argument" 1>&2
exit 1
fi
if [[ -z ${2+x} ]]; then
echo "Error: Pass the install prefix as the second argument" 1>&2
exit 2
fi
qt-cmake "$1" \
-G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
-DMBGL_WITH_QT=ON \
-DMBGL_QT_STATIC=ON \
-DMBGL_QT_LIBRARY_ONLY=ON \
-DCMAKE_INSTALL_PREFIX="$2"

View File

@@ -68,6 +68,11 @@
using namespace QMapbox; using namespace QMapbox;
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4805)
#endif
// mbgl::GLContextMode // mbgl::GLContextMode
static_assert(mbgl::underlying_type(QMapboxGLSettings::UniqueGLContext) == mbgl::underlying_type(mbgl::gfx::ContextMode::Unique), "error"); static_assert(mbgl::underlying_type(QMapboxGLSettings::UniqueGLContext) == mbgl::underlying_type(mbgl::gfx::ContextMode::Unique), "error");
static_assert(mbgl::underlying_type(QMapboxGLSettings::SharedGLContext) == mbgl::underlying_type(mbgl::gfx::ContextMode::Shared), "error"); static_assert(mbgl::underlying_type(QMapboxGLSettings::SharedGLContext) == mbgl::underlying_type(mbgl::gfx::ContextMode::Shared), "error");
@@ -91,6 +96,11 @@ static_assert(mbgl::underlying_type(QMapboxGL::NorthRightwards) == mbgl::underly
static_assert(mbgl::underlying_type(QMapboxGL::NorthDownwards) == mbgl::underlying_type(mbgl::NorthOrientation::Downwards), "error"); static_assert(mbgl::underlying_type(QMapboxGL::NorthDownwards) == mbgl::underlying_type(mbgl::NorthOrientation::Downwards), "error");
static_assert(mbgl::underlying_type(QMapboxGL::NorthLeftwards) == mbgl::underlying_type(mbgl::NorthOrientation::Leftwards), "error"); static_assert(mbgl::underlying_type(QMapboxGL::NorthLeftwards) == mbgl::underlying_type(mbgl::NorthOrientation::Leftwards), "error");
#ifdef _MSC_VER
#pragma warning(pop)
#endif
namespace { namespace {
QThreadStorage<std::shared_ptr<mbgl::util::RunLoop>> loop; QThreadStorage<std::shared_ptr<mbgl::util::RunLoop>> loop;
@@ -984,7 +994,7 @@ mbgl::optional<mbgl::Annotation> asMapboxGLAnnotation(const QMapbox::Annotation
*/ */
QMapbox::AnnotationID QMapboxGL::addAnnotation(const QMapbox::Annotation &annotation) QMapbox::AnnotationID QMapboxGL::addAnnotation(const QMapbox::Annotation &annotation)
{ {
return d_ptr->mapObj->addAnnotation(*asMapboxGLAnnotation(annotation)); return static_cast<QMapbox::AnnotationID>(d_ptr->mapObj->addAnnotation(*asMapboxGLAnnotation(annotation)));
} }
/*! /*!

View File

@@ -1,7 +1,4 @@
#include "qt_geojson.hpp" #include "qt_geojson.hpp"
#include <mapbox/geojson.hpp>
#include <mbgl/util/geometry.hpp>
#include <mbgl/util/feature.hpp>
#pragma clang diagnostic ignored "-Wenum-compare-switch" #pragma clang diagnostic ignored "-Wenum-compare-switch"

View File

@@ -18,7 +18,11 @@ void Timer::Impl::start(uint64_t timeout, uint64_t repeat_, std::function<void (
callback = std::move(cb); callback = std::move(cb);
timer.setSingleShot(true); timer.setSingleShot(true);
timer.start(timeout); #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
timer.start(static_cast<std::chrono::milliseconds>(timeout));
#else
timer.start(static_cast<int>(timeout));
#endif
} }
void Timer::Impl::stop() { void Timer::Impl::stop() {
@@ -28,7 +32,11 @@ void Timer::Impl::stop() {
void Timer::Impl::timerFired() { void Timer::Impl::timerFired() {
if (repeat) { if (repeat) {
timer.setSingleShot(false); timer.setSingleShot(false);
timer.start(repeat); #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
timer.start(static_cast<std::chrono::milliseconds>(repeat));
#else
timer.start(static_cast<int>(repeat));
#endif
} }
callback(); callback();

View File

@@ -18,7 +18,11 @@ int main(int argc, char *argv[]) {
QApplication app(argc, argv); QApplication app(argc, argv);
#ifdef WORK_DIRECTORY #ifdef WORK_DIRECTORY
#ifdef _MSC_VER
const int result = _chdir(xstr(WORK_DIRECTORY));
#else
const int result = chdir(xstr(WORK_DIRECTORY)); const int result = chdir(xstr(WORK_DIRECTORY));
#endif
if (result != 0) { if (result != 0) {
fprintf(stderr, "failed to change directory: %s\n", strerror(errno)); fprintf(stderr, "failed to change directory: %s\n", strerror(errno));
return errno; return errno;

View File

@@ -229,4 +229,11 @@ target_link_libraries(
$<$<AND:$<PLATFORM_ID:Windows>,$<BOOL:MINGW>>:psapi> $<$<AND:$<PLATFORM_ID:Windows>,$<BOOL:MINGW>>:psapi>
) )
if(MSVC)
target_compile_definitions(
mbgl-test
PRIVATE MBGL_BUILDING_LIB
)
endif()
set_property(TARGET mbgl-test PROPERTY FOLDER Core) set_property(TARGET mbgl-test PROPERTY FOLDER Core)

View File

@@ -2,7 +2,7 @@ if(TARGET mbgl-vendor-csscolorparser)
return() return()
endif() endif()
if(MBGL_QT_STATIC) if(MBGL_WITH_QT AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
add_library(mbgl-vendor-csscolorparser OBJECT) add_library(mbgl-vendor-csscolorparser OBJECT)
else() else()
add_library(mbgl-vendor-csscolorparser STATIC) add_library(mbgl-vendor-csscolorparser STATIC)
@@ -23,6 +23,10 @@ target_include_directories(
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/csscolorparser PUBLIC ${CMAKE_CURRENT_LIST_DIR}/csscolorparser
) )
if(MSVC)
target_compile_options(mbgl-vendor-csscolorparser PRIVATE /wd4244)
endif()
set_target_properties( set_target_properties(
mbgl-vendor-csscolorparser mbgl-vendor-csscolorparser
PROPERTIES PROPERTIES

5
vendor/icu.cmake vendored
View File

@@ -43,3 +43,8 @@ target_include_directories(
) )
set_property(TARGET mbgl-vendor-icu PROPERTY FOLDER Core) set_property(TARGET mbgl-vendor-icu PROPERTY FOLDER Core)
export(TARGETS
mbgl-vendor-icu
APPEND FILE MapboxCoreTargets.cmake
)

11
vendor/nunicode.cmake vendored
View File

@@ -2,7 +2,7 @@ if(TARGET mbgl-vendor-nunicode)
return() return()
endif() endif()
if(MBGL_QT_STATIC) if(MBGL_WITH_QT AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
add_library(mbgl-vendor-nunicode OBJECT) add_library(mbgl-vendor-nunicode OBJECT)
else() else()
add_library(mbgl-vendor-nunicode STATIC) add_library(mbgl-vendor-nunicode STATIC)
@@ -24,7 +24,9 @@ target_compile_definitions(
PRIVATE NU_BUILD_STATIC PRIVATE NU_BUILD_STATIC
) )
if(NOT MSVC) if(MSVC)
target_compile_options(mbgl-vendor-nunicode PRIVATE /wd4146)
else()
target_compile_options(mbgl-vendor-nunicode PRIVATE -Wno-error) target_compile_options(mbgl-vendor-nunicode PRIVATE -Wno-error)
endif() endif()
@@ -32,3 +34,8 @@ target_include_directories(
mbgl-vendor-nunicode SYSTEM mbgl-vendor-nunicode SYSTEM
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/nunicode/include PUBLIC ${CMAKE_CURRENT_LIST_DIR}/nunicode/include
) )
export(TARGETS
mbgl-vendor-nunicode
APPEND FILE MapboxCoreTargets.cmake
)

View File

@@ -2,7 +2,7 @@ if(TARGET mbgl-vendor-parsedate)
return() return()
endif() endif()
if(MBGL_QT_STATIC) if(MBGL_WITH_QT AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
add_library(mbgl-vendor-parsedate OBJECT) add_library(mbgl-vendor-parsedate OBJECT)
else() else()
add_library(mbgl-vendor-parsedate STATIC) add_library(mbgl-vendor-parsedate STATIC)

5
vendor/sqlite.cmake vendored
View File

@@ -27,3 +27,8 @@ target_include_directories(
mbgl-vendor-sqlite SYSTEM mbgl-vendor-sqlite SYSTEM
INTERFACE ${CMAKE_CURRENT_LIST_DIR}/sqlite/include INTERFACE ${CMAKE_CURRENT_LIST_DIR}/sqlite/include
) )
export(TARGETS
mbgl-vendor-sqlite
APPEND FILE MapboxCoreTargets.cmake
)