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:
5
.github/actions/qt5-build/Dockerfile
vendored
Normal file
5
.github/actions/qt5-build/Dockerfile
vendored
Normal 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
6
.github/actions/qt5-build/action.yml
vendored
Normal 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
19
.github/actions/qt5-build/entrypoint.sh
vendored
Executable 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
|
||||
48
.github/workflows/qt-ci.yml
vendored
48
.github/workflows/qt-ci.yml
vendored
@@ -70,6 +70,11 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- name: Linux
|
||||
os: ubuntu-latest
|
||||
static: OFF
|
||||
qt: 5.15.2
|
||||
qt_target: desktop
|
||||
- name: macOS
|
||||
os: macos-latest
|
||||
static: OFF
|
||||
@@ -80,11 +85,11 @@ jobs:
|
||||
static: ON
|
||||
qt: 5.15.2
|
||||
qt_target: desktop
|
||||
# - name: iOS_static
|
||||
# os: macos-latest
|
||||
# static: ON
|
||||
# qt: 5.15.2
|
||||
# qt_target: ios
|
||||
- name: iOS_static
|
||||
os: macos-latest
|
||||
static: ON
|
||||
qt: 5.15.2
|
||||
qt_target: ios
|
||||
- name: macOS
|
||||
os: macos-latest
|
||||
static: ON
|
||||
@@ -97,7 +102,7 @@ jobs:
|
||||
qt_target: desktop
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
BUILD_TYPE: Debug
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
BUILD_MODE: ${{ matrix.static }}
|
||||
QT_VERSION: ${{ matrix.qt }}
|
||||
|
||||
@@ -109,7 +114,7 @@ jobs:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Install macOS dependencies
|
||||
if: runner.os == 'macOS'
|
||||
env:
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
@@ -120,6 +125,7 @@ jobs:
|
||||
brew list ninja || brew install ninja
|
||||
|
||||
- name: Setup Xcode
|
||||
if: runner.os == 'macOS'
|
||||
uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: latest-stable
|
||||
@@ -128,9 +134,11 @@ jobs:
|
||||
uses: jurplel/install-qt-action@v2
|
||||
with:
|
||||
version: ${{ env.QT_VERSION }}
|
||||
dir: ${{ github.workspace }}
|
||||
target: ${{ matrix.qt_target }}
|
||||
|
||||
- name: Prepare ccache
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
ccache --clear
|
||||
ccache --set-config cache_dir=~/.ccache
|
||||
@@ -148,6 +156,7 @@ jobs:
|
||||
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.name }}-${{ matrix.qt }}-${{ github.job }}
|
||||
|
||||
- name: Clear ccache statistics
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
ccache --zero-stats
|
||||
ccache --max-size=2G
|
||||
@@ -161,7 +170,6 @@ jobs:
|
||||
-G Ninja \
|
||||
-DMBGL_WITH_QT=ON \
|
||||
-DMBGL_QT_STATIC=${BUILD_MODE} \
|
||||
-DMBGL_QT_WITH_INTERNAL_SQLITE=OFF \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=../install \
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||
@@ -174,22 +182,25 @@ jobs:
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ../source/ \
|
||||
-DCMAKE_TOOLCHAIN_FILE=../source/platform/ios/platform/ios/toolchain.cmake \
|
||||
-G XCode \
|
||||
-DPLATFORM=OS64COMBINED \
|
||||
-DDEPLOYMENT_TARGET=12.0 \
|
||||
-DENABLE_BITCODE=ON \
|
||||
-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_WITH_WERROR=OFF \
|
||||
-DMBGL_QT_LIBRARY_ONLY=ON \
|
||||
-DMBGL_QT_STATIC=${BUILD_MODE} \
|
||||
-DMBGL_QT_WITH_INTERNAL_SQLITE=OFF \
|
||||
-DMBGL_QT_LIBRARY_ONLY=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 --install . --config Release
|
||||
|
||||
- name: Build maplibre-gl-native (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
uses: ./source/.github/actions/qt5-build
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
@@ -197,5 +208,6 @@ jobs:
|
||||
path: install
|
||||
|
||||
- name: Show ccache statistics
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
ccache --show-stats -v
|
||||
|
||||
@@ -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_COVERAGE "Enable code coverage collection" 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_RTTI "Compile with runtime type information" OFF)
|
||||
option(MBGL_WITH_OPENGL "Build with OpenGL renderer" ON)
|
||||
@@ -55,6 +54,7 @@ target_compile_options(
|
||||
-fsanitize-blacklist=${UBSAN_BLACKLIST}>
|
||||
$<$<STREQUAL:${MBGL_WITH_SANITIZER},undefined>:-fsanitize=float-divide-by-zero,
|
||||
-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:$<PLATFORM_ID:Windows>>>:-Wall>
|
||||
$<$<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-property-ivar>
|
||||
$<$<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>:/wd4244> # types
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/wd4828> # encoding
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/D_SILENCE_ALL_CXX17_DEPRECATION_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_REQUIRED ON)
|
||||
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_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
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)
|
||||
else()
|
||||
add_library(mbgl-core STATIC)
|
||||
@@ -1020,6 +1024,38 @@ target_link_libraries(
|
||||
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(
|
||||
mbgl-core
|
||||
PROPERTIES
|
||||
|
||||
@@ -38,7 +38,11 @@ public:
|
||||
template <typename Fn, class... Args>
|
||||
auto ask(Fn fn, Args&&... args) const {
|
||||
// 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;
|
||||
#endif
|
||||
|
||||
std::promise<ResultType> promise;
|
||||
auto future = promise.get_future();
|
||||
|
||||
@@ -1,108 +1,44 @@
|
||||
# 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)
|
||||
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.
|
||||
## Supported platforms
|
||||
|
||||
You should build this repository if you want to develop/contribute using the low level Qt C++ bindings or
|
||||
want to contribute to the MapLibre GL Native project using the Qt port for debugging.
|
||||
- macOS
|
||||
- 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`:
|
||||
|
||||
```
|
||||
$ sudo apt-get install qt5-default
|
||||
```shell
|
||||
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):
|
||||
|
||||
```
|
||||
$ brew install qt5
|
||||
```shell
|
||||
mkdir build && cd build
|
||||
cmake ../maplibre-gl-native/ \
|
||||
-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.
|
||||
|
||||
```
|
||||
export PATH=/usr/local/opt/qt5/bin:$PATH
|
||||
```
|
||||
|
||||
### 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
|
||||
```
|
||||
For platform-specific details look at build scripts provided
|
||||
in the [scripts](scripts) folder. Each script requires (at least) paths
|
||||
to source and installation locations.
|
||||
|
||||
@@ -9,10 +9,14 @@
|
||||
|
||||
// This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style
|
||||
|
||||
#if defined(QT_BUILD_MAPBOXGL_LIB)
|
||||
# define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT
|
||||
#if !defined(QT_MAPBOXGL_STATIC)
|
||||
# if defined(QT_BUILD_MAPBOXGL_LIB)
|
||||
# define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT
|
||||
# define Q_MAPBOXGL_EXPORT
|
||||
#endif
|
||||
|
||||
namespace QMapbox {
|
||||
|
||||
@@ -4,13 +4,13 @@ message(STATUS "Configuring GL-Native with Qt bindings")
|
||||
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
|
||||
set(MBGL_QT_VERSION_COMPATIBILITY 2.0.0)
|
||||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
||||
message(STATUS "Version ${MBGL_QT_VERSION}")
|
||||
|
||||
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_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${QT_VERSION_MAJOR}
|
||||
@@ -63,10 +63,10 @@ endif()
|
||||
if(ANDROID)
|
||||
message(STATUS "Building for ABI: ${ANDROID_ABI}")
|
||||
set(CMAKE_STATIC_LIBRARY_SUFFIX "_${ANDROID_ABI}.a")
|
||||
elseif(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CMAKE_STATIC_LIBRARY_SUFFIX "d.lib")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CMAKE_STATIC_LIBRARY_SUFFIX "d.a")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
|
||||
set(CMAKE_DEBUG_POSTFIX "_debug")
|
||||
elseif(MSVC OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
endif()
|
||||
|
||||
target_sources(
|
||||
@@ -150,7 +150,7 @@ set_property(TARGET mbgl-core PROPERTY AUTOMOC ON)
|
||||
target_link_libraries(
|
||||
mbgl-core
|
||||
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}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
@@ -166,12 +166,10 @@ set(qmapboxgl_headers
|
||||
${PROJECT_SOURCE_DIR}/platform/qt/include/qmapboxgl.hpp
|
||||
)
|
||||
|
||||
if(MBGL_QT_STATIC)
|
||||
if(MBGL_QT_INSIDE_QT_PLUGIN)
|
||||
add_library(qmapboxgl OBJECT)
|
||||
else()
|
||||
add_library(qmapboxgl STATIC)
|
||||
endif()
|
||||
if (MBGL_QT_INSIDE_PLUGIN)
|
||||
add_library(qmapboxgl OBJECT)
|
||||
elseif(MBGL_QT_STATIC)
|
||||
add_library(qmapboxgl STATIC)
|
||||
else()
|
||||
add_library(qmapboxgl SHARED)
|
||||
endif()
|
||||
@@ -206,7 +204,7 @@ set_target_properties(
|
||||
SOVERSION ${MBGL_QT_VERSION_COMPATIBILITY}
|
||||
PUBLIC_HEADER "${qmapboxgl_headers}"
|
||||
)
|
||||
if (NOT MBGL_QT_STATIC)
|
||||
if (NOT MBGL_QT_STATIC AND NOT MBGL_QT_INSIDE_PLUGIN)
|
||||
set_target_properties(
|
||||
qmapboxgl PROPERTIES
|
||||
FRAMEWORK ON
|
||||
@@ -232,6 +230,8 @@ install(EXPORT QMapboxGLTargets
|
||||
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
COMPONENT development)
|
||||
|
||||
export(EXPORT QMapboxGLTargets)
|
||||
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/QMapboxGLConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/QMapboxGLConfigVersion.cmake"
|
||||
@@ -305,7 +305,7 @@ if(NOT MBGL_QT_LIBRARY_ONLY)
|
||||
target_compile_definitions(
|
||||
mbgl-qt
|
||||
PRIVATE
|
||||
$<$<BOOL:${MBGL_QT_STATIC}>:QT_MAPBOXGL_STATIC>
|
||||
$<$<OR:$<BOOL:${MBGL_QT_STATIC}>,$<BOOL:${MBGL_QT_INSIDE_PLUGIN}>>:QT_MAPBOXGL_STATIC>
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
@@ -320,7 +320,7 @@ if(NOT MBGL_QT_LIBRARY_ONLY)
|
||||
|
||||
target_include_directories(
|
||||
mbgl-qt
|
||||
PUBLIC ${PROJECT_SOURCE_DIR}/platform/qt/include
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/platform/qt/include
|
||||
)
|
||||
|
||||
add_executable(
|
||||
@@ -330,7 +330,7 @@ if(NOT MBGL_QT_LIBRARY_ONLY)
|
||||
|
||||
target_include_directories(
|
||||
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(
|
||||
|
||||
34
platform/qt/scripts/configure_Qt5_Android_static.sh
Executable file
34
platform/qt/scripts/configure_Qt5_Android_static.sh
Executable 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"
|
||||
17
platform/qt/scripts/configure_Qt5_Linux.sh
Executable file
17
platform/qt/scripts/configure_Qt5_Linux.sh
Executable 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"
|
||||
8
platform/qt/scripts/configure_Qt5_Windows.ps1
Normal file
8
platform/qt/scripts/configure_Qt5_Windows.ps1
Normal 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
|
||||
10
platform/qt/scripts/configure_Qt5_Windows_static.ps1
Normal file
10
platform/qt/scripts/configure_Qt5_Windows_static.ps1
Normal 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
|
||||
29
platform/qt/scripts/configure_Qt5_iOS_static.sh
Executable file
29
platform/qt/scripts/configure_Qt5_iOS_static.sh
Executable 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"
|
||||
18
platform/qt/scripts/configure_Qt5_macOS.sh
Executable file
18
platform/qt/scripts/configure_Qt5_macOS.sh
Executable 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"
|
||||
20
platform/qt/scripts/configure_Qt5_macOS_static.sh
Executable file
20
platform/qt/scripts/configure_Qt5_macOS_static.sh
Executable 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"
|
||||
8
platform/qt/scripts/configure_Qt6_Windows.ps1
Normal file
8
platform/qt/scripts/configure_Qt6_Windows.ps1
Normal 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
|
||||
19
platform/qt/scripts/configure_Qt6_macOS.sh
Executable file
19
platform/qt/scripts/configure_Qt6_macOS.sh
Executable 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"
|
||||
21
platform/qt/scripts/configure_Qt6_macOS_static.sh
Executable file
21
platform/qt/scripts/configure_Qt6_macOS_static.sh
Executable 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"
|
||||
@@ -68,6 +68,11 @@
|
||||
|
||||
using namespace QMapbox;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4805)
|
||||
#endif
|
||||
|
||||
// mbgl::GLContextMode
|
||||
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");
|
||||
@@ -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::NorthLeftwards) == mbgl::underlying_type(mbgl::NorthOrientation::Leftwards), "error");
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
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)
|
||||
{
|
||||
return d_ptr->mapObj->addAnnotation(*asMapboxGLAnnotation(annotation));
|
||||
return static_cast<QMapbox::AnnotationID>(d_ptr->mapObj->addAnnotation(*asMapboxGLAnnotation(annotation)));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#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"
|
||||
|
||||
|
||||
@@ -18,7 +18,11 @@ void Timer::Impl::start(uint64_t timeout, uint64_t repeat_, std::function<void (
|
||||
callback = std::move(cb);
|
||||
|
||||
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() {
|
||||
@@ -28,7 +32,11 @@ void Timer::Impl::stop() {
|
||||
void Timer::Impl::timerFired() {
|
||||
if (repeat) {
|
||||
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();
|
||||
|
||||
@@ -18,7 +18,11 @@ int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
#ifdef WORK_DIRECTORY
|
||||
#ifdef _MSC_VER
|
||||
const int result = _chdir(xstr(WORK_DIRECTORY));
|
||||
#else
|
||||
const int result = chdir(xstr(WORK_DIRECTORY));
|
||||
#endif
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "failed to change directory: %s\n", strerror(errno));
|
||||
return errno;
|
||||
|
||||
@@ -229,4 +229,11 @@ target_link_libraries(
|
||||
$<$<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)
|
||||
|
||||
6
vendor/csscolorparser.cmake
vendored
6
vendor/csscolorparser.cmake
vendored
@@ -2,7 +2,7 @@ if(TARGET mbgl-vendor-csscolorparser)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(MBGL_QT_STATIC)
|
||||
if(MBGL_WITH_QT AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
|
||||
add_library(mbgl-vendor-csscolorparser OBJECT)
|
||||
else()
|
||||
add_library(mbgl-vendor-csscolorparser STATIC)
|
||||
@@ -23,6 +23,10 @@ target_include_directories(
|
||||
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/csscolorparser
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(mbgl-vendor-csscolorparser PRIVATE /wd4244)
|
||||
endif()
|
||||
|
||||
set_target_properties(
|
||||
mbgl-vendor-csscolorparser
|
||||
PROPERTIES
|
||||
|
||||
5
vendor/icu.cmake
vendored
5
vendor/icu.cmake
vendored
@@ -43,3 +43,8 @@ target_include_directories(
|
||||
)
|
||||
|
||||
set_property(TARGET mbgl-vendor-icu PROPERTY FOLDER Core)
|
||||
|
||||
export(TARGETS
|
||||
mbgl-vendor-icu
|
||||
APPEND FILE MapboxCoreTargets.cmake
|
||||
)
|
||||
|
||||
11
vendor/nunicode.cmake
vendored
11
vendor/nunicode.cmake
vendored
@@ -2,7 +2,7 @@ if(TARGET mbgl-vendor-nunicode)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(MBGL_QT_STATIC)
|
||||
if(MBGL_WITH_QT AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
|
||||
add_library(mbgl-vendor-nunicode OBJECT)
|
||||
else()
|
||||
add_library(mbgl-vendor-nunicode STATIC)
|
||||
@@ -24,7 +24,9 @@ target_compile_definitions(
|
||||
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)
|
||||
endif()
|
||||
|
||||
@@ -32,3 +34,8 @@ target_include_directories(
|
||||
mbgl-vendor-nunicode SYSTEM
|
||||
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/nunicode/include
|
||||
)
|
||||
|
||||
export(TARGETS
|
||||
mbgl-vendor-nunicode
|
||||
APPEND FILE MapboxCoreTargets.cmake
|
||||
)
|
||||
|
||||
2
vendor/parsedate.cmake
vendored
2
vendor/parsedate.cmake
vendored
@@ -2,7 +2,7 @@ if(TARGET mbgl-vendor-parsedate)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(MBGL_QT_STATIC)
|
||||
if(MBGL_WITH_QT AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
|
||||
add_library(mbgl-vendor-parsedate OBJECT)
|
||||
else()
|
||||
add_library(mbgl-vendor-parsedate STATIC)
|
||||
|
||||
5
vendor/sqlite.cmake
vendored
5
vendor/sqlite.cmake
vendored
@@ -27,3 +27,8 @@ target_include_directories(
|
||||
mbgl-vendor-sqlite SYSTEM
|
||||
INTERFACE ${CMAKE_CURRENT_LIST_DIR}/sqlite/include
|
||||
)
|
||||
|
||||
export(TARGETS
|
||||
mbgl-vendor-sqlite
|
||||
APPEND FILE MapboxCoreTargets.cmake
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user