diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-09-25 21:35:04 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-09-28 13:48:36 -0400 |
commit | 64c75b442c4d387e4867757abf49462c561e5955 (patch) | |
tree | 63f572961f6309a851d2e85ebe191e6a3cb7e5ab | |
parent | d73e33eb62858b91212314d97bfe9cf49e857141 (diff) | |
download | qtlocation-mapboxgl-64c75b442c4d387e4867757abf49462c561e5955.tar.gz |
[build] split out DefaultFileSource and dependents to a separate target
We don't want to link it into the node bindings, so keep it in a separate target
25 files changed, 472 insertions, 279 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 530461d1fa..0dd66e98ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,10 +127,12 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/platform/${MBGL_PLATFORM}/config.cmake) message(ERROR "Can't find config.cmake file for platform ${MBGL_PLATFORM}") endif() -include(cmake/loop-uv.cmake) - include(platform/${MBGL_PLATFORM}/config.cmake) +if (COMMAND mbgl_filesource) + include(cmake/filesource.cmake) +endif() + include(cmake/core-files.cmake) include(cmake/core.cmake) @@ -163,5 +165,6 @@ endif() if(CMAKE_GENERATOR STREQUAL "Xcode") write_xcconfig_target_properties( mbgl-core + mbgl-filesource ) endif() diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index c34a0724f4..04f0f7116d 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -309,8 +309,6 @@ set(MBGL_CORE_FILES include/mbgl/storage/resource_transform.hpp include/mbgl/storage/response.hpp src/mbgl/storage/asset_file_source.hpp - src/mbgl/storage/file_source_request.cpp - src/mbgl/storage/file_source_request.hpp src/mbgl/storage/http_file_source.hpp src/mbgl/storage/local_file_source.hpp src/mbgl/storage/network_status.cpp diff --git a/cmake/filesource.cmake b/cmake/filesource.cmake new file mode 100644 index 0000000000..bb1b4e8c05 --- /dev/null +++ b/cmake/filesource.cmake @@ -0,0 +1,57 @@ +add_library(mbgl-filesource STATIC + # File source + include/mbgl/storage/default_file_source.hpp + platform/default/default_file_source.cpp + platform/default/mbgl/storage/file_source_request.hpp + platform/default/file_source_request.cpp + include/mbgl/storage/online_file_source.hpp + platform/default/online_file_source.cpp + src/mbgl/storage/http_file_source.hpp + src/mbgl/storage/asset_file_source.hpp + platform/default/asset_file_source.cpp + src/mbgl/storage/local_file_source.hpp + platform/default/local_file_source.cpp + + # Offline + include/mbgl/storage/offline.hpp + platform/default/mbgl/storage/offline.cpp + platform/default/mbgl/storage/offline_database.hpp + platform/default/mbgl/storage/offline_database.cpp + platform/default/mbgl/storage/offline_download.hpp + platform/default/mbgl/storage/offline_download.cpp + + # Database + platform/default/sqlite3.hpp +) + +target_add_mason_package(mbgl-filesource PUBLIC geometry) +target_add_mason_package(mbgl-filesource PUBLIC variant) +target_add_mason_package(mbgl-filesource PUBLIC any) +target_add_mason_package(mbgl-filesource PRIVATE rapidjson) +target_add_mason_package(mbgl-filesource PRIVATE boost) +target_add_mason_package(mbgl-filesource PRIVATE geojson) + +set_xcode_property(mbgl-filesource GCC_SYMBOLS_PRIVATE_EXTERN YES) + +target_compile_options(mbgl-filesource + PRIVATE -fPIC + PRIVATE -fvisibility-inlines-hidden +) + +target_include_directories(mbgl-filesource + PRIVATE include + PRIVATE src + PRIVATE platform/default +) + +target_link_libraries(mbgl-filesource + PUBLIC mbgl-core +) + +mbgl_filesource() + +create_source_groups(mbgl-filesource) + +xcode_create_scheme(TARGET mbgl-filesource) + +initialize_xcode_cxx_build_settings(mbgl-filesource) diff --git a/cmake/mbgl.cmake b/cmake/mbgl.cmake index 7f7d820a68..d853950c0d 100644 --- a/cmake/mbgl.cmake +++ b/cmake/mbgl.cmake @@ -95,6 +95,16 @@ function(_get_xcconfig_property target var) get_property(result TARGET ${target} PROPERTY INTERFACE_${var} SET) if (result) get_property(result TARGET ${target} PROPERTY INTERFACE_${var}) + if (var STREQUAL "LINK_LIBRARIES") + # Remove target names from the list of linker flags, since Xcode can't deal with them. + set(link_flags) + foreach(item IN LISTS result) + if (NOT TARGET ${item}) + list(APPEND link_flags ${item}) + endif() + endforeach() + set(result "${link_flags}") + endif() string(REPLACE ";-framework " ";-framework;" result "${result}") string(REPLACE ";" "\" \"" result "${result}") string(REPLACE "-" "_" target "${target}") diff --git a/cmake/node.cmake b/cmake/node.cmake index 5a6c7595ad..c256b13f93 100644 --- a/cmake/node.cmake +++ b/cmake/node.cmake @@ -65,7 +65,7 @@ xcode_create_scheme( TYPE node NAME "node tests" ARGS - "`npm bin tape`/tape platform/node/test/js/**/*.test.js" + "node_modules/.bin/tape platform/node/test/js/**/*.test.js" ) xcode_create_scheme( diff --git a/include/mbgl/storage/response.hpp b/include/mbgl/storage/response.hpp index 711f008e83..508400141b 100644 --- a/include/mbgl/storage/response.hpp +++ b/include/mbgl/storage/response.hpp @@ -2,7 +2,6 @@ #include <mbgl/util/chrono.hpp> #include <mbgl/util/optional.hpp> -#include <mbgl/util/variant.hpp> #include <string> #include <memory> diff --git a/platform/android/config.cmake b/platform/android/config.cmake index 227334e0b5..8dd537d36e 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -31,25 +31,6 @@ macro(mbgl_platform_core) PRIVATE platform/android/src/run_loop_impl.hpp PRIVATE platform/android/src/timer.cpp - # File source - PRIVATE platform/android/src/http_file_source.cpp - PRIVATE platform/android/src/asset_manager.hpp - PRIVATE platform/android/src/asset_manager_file_source.cpp - PRIVATE platform/android/src/asset_manager_file_source.hpp - PRIVATE platform/default/default_file_source.cpp - PRIVATE platform/default/asset_file_source.cpp - PRIVATE platform/default/local_file_source.cpp - PRIVATE platform/default/online_file_source.cpp - - # Offline - PRIVATE platform/default/mbgl/storage/offline.cpp - PRIVATE platform/default/mbgl/storage/offline_database.cpp - PRIVATE platform/default/mbgl/storage/offline_database.hpp - PRIVATE platform/default/mbgl/storage/offline_download.cpp - PRIVATE platform/default/mbgl/storage/offline_download.hpp - PRIVATE platform/default/sqlite3.cpp - PRIVATE platform/default/sqlite3.hpp - # Misc PRIVATE platform/android/src/logging_android.cpp PRIVATE platform/android/src/thread.cpp @@ -95,7 +76,6 @@ macro(mbgl_platform_core) PUBLIC platform/default ) - target_add_mason_package(mbgl-core PUBLIC sqlite) target_add_mason_package(mbgl-core PUBLIC nunicode) target_add_mason_package(mbgl-core PUBLIC geojson) target_add_mason_package(mbgl-core PUBLIC jni.hpp) @@ -120,6 +100,37 @@ macro(mbgl_platform_core) ) endmacro() + +macro(mbgl_filesource) + target_sources(mbgl-filesource + # File source + PRIVATE platform/android/src/http_file_source.cpp + PRIVATE platform/android/src/asset_manager.hpp + PRIVATE platform/android/src/asset_manager_file_source.cpp + PRIVATE platform/android/src/asset_manager_file_source.hpp + + # Database + PRIVATE platform/default/sqlite3.cpp + ) + + target_add_mason_package(mbgl-filesource PUBLIC sqlite) + target_add_mason_package(mbgl-filesource PUBLIC jni.hpp) + + target_compile_options(mbgl-filesource + PRIVATE -fvisibility=hidden + PRIVATE -ffunction-sections + PRIVATE -fdata-sections + ) + + target_link_libraries(mbgl-filesource + PUBLIC -llog + PUBLIC -landroid + PUBLIC -lstdc++ + PUBLIC -latomic + ) +endmacro() + + ## Main library ## add_library(mbgl-android STATIC @@ -300,6 +311,7 @@ target_compile_options(mbgl-android ) target_link_libraries(mbgl-android + PUBLIC mbgl-filesource PUBLIC mbgl-core ) diff --git a/src/mbgl/storage/file_source_request.cpp b/platform/default/file_source_request.cpp index 09ea8cc32a..09ea8cc32a 100644 --- a/src/mbgl/storage/file_source_request.cpp +++ b/platform/default/file_source_request.cpp diff --git a/src/mbgl/storage/file_source_request.hpp b/platform/default/mbgl/storage/file_source_request.hpp index 6bd0d44df6..6bd0d44df6 100644 --- a/src/mbgl/storage/file_source_request.hpp +++ b/platform/default/mbgl/storage/file_source_request.hpp diff --git a/platform/ios/app/Assets.xcassets/AppIcon.appiconset/Contents.json b/platform/ios/app/Assets.xcassets/AppIcon.appiconset/Contents.json index e1bc22272f..f4e2027f0f 100644 --- a/platform/ios/app/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/platform/ios/app/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -97,6 +97,11 @@ "idiom" : "ipad", "filename" : "Icon-83.5@2x.png", "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/platform/ios/config.cmake b/platform/ios/config.cmake index 4e873e73ea..c3db194988 100644 --- a/platform/ios/config.cmake +++ b/platform/ios/config.cmake @@ -2,37 +2,29 @@ add_definitions(-DMBGL_USE_GLES2=1) mason_use(icu VERSION 58.1-min-size) -macro(mbgl_platform_core) - set_xcode_property(mbgl-core IPHONEOS_DEPLOYMENT_TARGET "8.0") - set_xcode_property(mbgl-core ENABLE_BITCODE "YES") - set_xcode_property(mbgl-core BITCODE_GENERATION_MODE bitcode) - set_xcode_property(mbgl-core ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>) +macro(initialize_ios_target target) + set_xcode_property(${target} IPHONEOS_DEPLOYMENT_TARGET "8.0") + set_xcode_property(${target} ENABLE_BITCODE "YES") + set_xcode_property(${target} BITCODE_GENERATION_MODE bitcode) + set_xcode_property(${target} ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>) - target_sources(mbgl-core - # Loop - PRIVATE platform/darwin/src/async_task.cpp - PRIVATE platform/darwin/src/run_loop.cpp - PRIVATE platform/darwin/src/timer.cpp + target_compile_options(${target} + PRIVATE -fobjc-arc + ) +endmacro() - # File source - PRIVATE platform/darwin/src/http_file_source.mm - PRIVATE platform/default/asset_file_source.cpp - PRIVATE platform/default/default_file_source.cpp - PRIVATE platform/default/local_file_source.cpp - PRIVATE platform/default/online_file_source.cpp +include(cmake/loop-darwin.cmake) +initialize_ios_target(mbgl-loop-darwin) + + +macro(mbgl_platform_core) + initialize_ios_target(mbgl-core) + + target_sources(mbgl-core # Default styles PRIVATE platform/default/mbgl/util/default_styles.hpp - # Offline - PRIVATE platform/default/mbgl/storage/offline.cpp - PRIVATE platform/default/mbgl/storage/offline_database.cpp - PRIVATE platform/default/mbgl/storage/offline_database.hpp - PRIVATE platform/default/mbgl/storage/offline_download.cpp - PRIVATE platform/default/mbgl/storage/offline_download.hpp - PRIVATE platform/default/sqlite3.cpp - PRIVATE platform/default/sqlite3.hpp - # Misc PRIVATE platform/darwin/mbgl/storage/reachability.h PRIVATE platform/darwin/mbgl/storage/reachability.m @@ -73,7 +65,6 @@ macro(mbgl_platform_core) target_add_mason_package(mbgl-core PRIVATE icu) target_compile_options(mbgl-core - PRIVATE -fobjc-arc PRIVATE -fvisibility=hidden ) @@ -97,6 +88,27 @@ macro(mbgl_platform_core) PUBLIC "-framework ImageIO" PUBLIC "-framework MobileCoreServices" PUBLIC "-framework SystemConfiguration" + ) +endmacro() + + +macro(mbgl_filesource) + initialize_ios_target(mbgl-filesource) + + target_sources(mbgl-filesource + # File source + PRIVATE platform/darwin/src/http_file_source.mm + + # Database + PRIVATE platform/default/sqlite3.cpp + ) + + target_compile_options(mbgl-filesource + PRIVATE -fvisibility=hidden + ) + + target_link_libraries(mbgl-filesource PUBLIC "-lsqlite3" + PUBLIC "-framework Foundation" ) endmacro() diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index debbf1ccf3..a3ccc9337b 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -204,6 +204,10 @@ 558DE7A11E5615E400C7916D /* MGLFoundation_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 558DE79E1E5615E400C7916D /* MGLFoundation_Private.h */; }; 558DE7A21E5615E400C7916D /* MGLFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 558DE79F1E5615E400C7916D /* MGLFoundation.mm */; }; 558DE7A31E5615E400C7916D /* MGLFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 558DE79F1E5615E400C7916D /* MGLFoundation.mm */; }; + 55D120A61F791007004B6D81 /* libmbgl-loop-darwin.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D120A71F791007004B6D81 /* libmbgl-loop-darwin.a */; }; + 55D120A81F79100C004B6D81 /* libmbgl-filesource.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D120A91F79100C004B6D81 /* libmbgl-filesource.a */; }; + 55D120AA1F791015004B6D81 /* libmbgl-filesource.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D120AB1F791015004B6D81 /* libmbgl-filesource.a */; }; + 55D120AC1F791018004B6D81 /* libmbgl-loop-darwin.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D120AD1F791018004B6D81 /* libmbgl-loop-darwin.a */; }; 55E2AD131E5B125400E8C587 /* MGLOfflineStorageTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 55E2AD121E5B125400E8C587 /* MGLOfflineStorageTests.mm */; }; 632281DF1E6F855900D75A5D /* MBXEmbeddedMapViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 632281DE1E6F855900D75A5D /* MBXEmbeddedMapViewController.m */; }; 6407D6701E0085FD00F6A9C3 /* MGLDocumentationExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6407D66F1E0085FD00F6A9C3 /* MGLDocumentationExampleTests.swift */; }; @@ -690,6 +694,10 @@ 556660D71E1D085500E2C41B /* MGLVersionNumber.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MGLVersionNumber.m; path = ../../darwin/test/MGLVersionNumber.m; sourceTree = "<group>"; }; 558DE79E1E5615E400C7916D /* MGLFoundation_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLFoundation_Private.h; sourceTree = "<group>"; }; 558DE79F1E5615E400C7916D /* MGLFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFoundation.mm; sourceTree = "<group>"; }; + 55D120A71F791007004B6D81 /* libmbgl-loop-darwin.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libmbgl-loop-darwin.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 55D120A91F79100C004B6D81 /* libmbgl-filesource.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libmbgl-filesource.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 55D120AB1F791015004B6D81 /* libmbgl-filesource.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libmbgl-filesource.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 55D120AD1F791018004B6D81 /* libmbgl-loop-darwin.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libmbgl-loop-darwin.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 55D8C9941D0F133500F42F10 /* config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = config.xcconfig; path = ../../build/ios/config.xcconfig; sourceTree = "<group>"; }; 55D8C9951D0F18CE00F42F10 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; }; 55E2AD121E5B125400E8C587 /* MGLOfflineStorageTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLOfflineStorageTests.mm; path = ../../darwin/test/MGLOfflineStorageTests.mm; sourceTree = "<group>"; }; @@ -1001,6 +1009,8 @@ buildActionMask = 2147483647; files = ( DAABF73D1CBC59BB005B1825 /* libmbgl-core.a in Frameworks */, + 55D120A61F791007004B6D81 /* libmbgl-loop-darwin.a in Frameworks */, + 55D120A81F79100C004B6D81 /* libmbgl-filesource.a in Frameworks */, DA27C24E1CBB3811000B0ECD /* GLKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1010,6 +1020,8 @@ buildActionMask = 2147483647; files = ( 36F1153D1D46080700878E1A /* libmbgl-core.a in Frameworks */, + 55D120AC1F791018004B6D81 /* libmbgl-loop-darwin.a in Frameworks */, + 55D120AA1F791015004B6D81 /* libmbgl-filesource.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1279,6 +1291,10 @@ DA1DC9921CB6DF24006E619F /* Frameworks */ = { isa = PBXGroup; children = ( + 55D120AD1F791018004B6D81 /* libmbgl-loop-darwin.a */, + 55D120AB1F791015004B6D81 /* libmbgl-filesource.a */, + 55D120A91F79100C004B6D81 /* libmbgl-filesource.a */, + 55D120A71F791007004B6D81 /* libmbgl-loop-darwin.a */, 5549A0371EF1D86B00073113 /* libmbgl-core.a */, 36F1153B1D46080700878E1A /* libmbgl-core.a */, 36F1153C1D46080700878E1A /* libmbgl-platform-ios.a */, @@ -2827,7 +2843,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)"; + HEADER_SEARCH_PATHS = ( + "$(mbgl_core_INCLUDE_DIRECTORIES)", + "$(mbgl_filesource_INCLUDE_DIRECTORIES)", + ); INFOPLIST_FILE = framework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -2842,7 +2861,10 @@ "$(geometry_cflags)", "$(geojson_cflags)", ); - OTHER_LDFLAGS = "$(mbgl_core_LINK_LIBRARIES)"; + OTHER_LDFLAGS = ( + "$(mbgl_core_LINK_LIBRARIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.sdk.ios; PRODUCT_NAME = Mapbox; SKIP_INSTALL = YES; @@ -2862,7 +2884,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)"; + HEADER_SEARCH_PATHS = ( + "$(mbgl_core_INCLUDE_DIRECTORIES)", + "$(mbgl_filesource_INCLUDE_DIRECTORIES)", + ); INFOPLIST_FILE = framework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -2877,7 +2902,10 @@ "$(geometry_cflags)", "$(geojson_cflags)", ); - OTHER_LDFLAGS = "$(mbgl_core_LINK_LIBRARIES)"; + OTHER_LDFLAGS = ( + "$(mbgl_core_LINK_LIBRARIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", + ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.sdk.ios; PRODUCT_NAME = Mapbox; SKIP_INSTALL = YES; @@ -2914,7 +2942,10 @@ baseConfigurationReference = 55D8C9941D0F133500F42F10 /* config.xcconfig */; buildSettings = { BITCODE_GENERATION_MODE = bitcode; - HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)"; + HEADER_SEARCH_PATHS = ( + "$(mbgl_core_INCLUDE_DIRECTORIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", + ); OTHER_CFLAGS = "-fvisibility=hidden"; OTHER_CPLUSPLUSFLAGS = ( "$(OTHER_CFLAGS)", @@ -2928,6 +2959,7 @@ OTHER_LDFLAGS = ( "-ObjC", "$(mbgl_core_LINK_LIBRARIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", ); PRODUCT_NAME = Mapbox; PUBLIC_HEADERS_FOLDER_PATH = Headers; @@ -2941,7 +2973,10 @@ baseConfigurationReference = 55D8C9941D0F133500F42F10 /* config.xcconfig */; buildSettings = { BITCODE_GENERATION_MODE = bitcode; - HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)"; + HEADER_SEARCH_PATHS = ( + "$(mbgl_core_INCLUDE_DIRECTORIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", + ); OTHER_CFLAGS = "-fvisibility=hidden"; OTHER_CPLUSPLUSFLAGS = ( "$(OTHER_CFLAGS)", @@ -2955,6 +2990,7 @@ OTHER_LDFLAGS = ( "-ObjC", "$(mbgl_core_LINK_LIBRARIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", ); PRODUCT_NAME = Mapbox; PUBLIC_HEADERS_FOLDER_PATH = Headers; diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake index badbde408f..47c4c68806 100644 --- a/platform/linux/config.cmake +++ b/platform/linux/config.cmake @@ -11,9 +11,7 @@ mason_use(gtest VERSION 1.8.0${MASON_CXXABI_SUFFIX}) mason_use(benchmark VERSION 1.2.0) mason_use(icu VERSION 58.1-min-size) -# Link with libuv. This is not part of loop-uv.cmake because loop-uv.cmake is also -# used by node.cmake, where we want to link with the libuv provided by node itself. -target_add_mason_package(mbgl-loop-uv PUBLIC libuv) +include(cmake/loop-uv.cmake) macro(mbgl_platform_core) target_add_mason_package(mbgl-core PUBLIC mesa) @@ -48,22 +46,6 @@ macro(mbgl_platform_core) endif() target_sources(mbgl-core - # File source - PRIVATE platform/default/asset_file_source.cpp - PRIVATE platform/default/default_file_source.cpp - PRIVATE platform/default/local_file_source.cpp - PRIVATE platform/default/http_file_source.cpp - PRIVATE platform/default/online_file_source.cpp - - # Offline - PRIVATE platform/default/mbgl/storage/offline.cpp - PRIVATE platform/default/mbgl/storage/offline_database.cpp - PRIVATE platform/default/mbgl/storage/offline_database.hpp - PRIVATE platform/default/mbgl/storage/offline_download.cpp - PRIVATE platform/default/mbgl/storage/offline_download.hpp - PRIVATE platform/default/sqlite3.cpp - PRIVATE platform/default/sqlite3.hpp - # Misc PRIVATE platform/default/logging_stderr.cpp PRIVATE platform/default/string_stdlib.cpp @@ -96,7 +78,6 @@ macro(mbgl_platform_core) PRIVATE platform/default ) - target_add_mason_package(mbgl-core PUBLIC sqlite) target_add_mason_package(mbgl-core PUBLIC nunicode) target_add_mason_package(mbgl-core PUBLIC libpng) target_add_mason_package(mbgl-core PUBLIC libjpeg-turbo) @@ -105,6 +86,22 @@ macro(mbgl_platform_core) target_link_libraries(mbgl-core PUBLIC -lz + ) +endmacro() + + +macro(mbgl_filesource) + target_sources(mbgl-filesource + # File source + PRIVATE platform/default/http_file_source.cpp + + # Database + PRIVATE platform/default/sqlite3.cpp + ) + + target_add_mason_package(mbgl-filesource PUBLIC sqlite) + + target_link_libraries(mbgl-filesource PUBLIC -lcurl ) endmacro() @@ -112,9 +109,12 @@ endmacro() macro(mbgl_platform_glfw) target_link_libraries(mbgl-glfw + PRIVATE mbgl-filesource PRIVATE mbgl-loop-uv ) + target_add_mason_package(mbgl-glfw PUBLIC libuv) + add_custom_command( TARGET mbgl-glfw POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy @@ -126,15 +126,21 @@ endmacro() macro(mbgl_platform_render) target_link_libraries(mbgl-render + PRIVATE mbgl-filesource PRIVATE mbgl-loop-uv ) + + target_add_mason_package(mbgl-render PUBLIC libuv) endmacro() macro(mbgl_platform_offline) target_link_libraries(mbgl-offline + PRIVATE mbgl-filesource PRIVATE mbgl-loop-uv ) + + target_add_mason_package(mbgl-offline PUBLIC libuv) endmacro() @@ -150,8 +156,11 @@ macro(mbgl_platform_test) ) target_link_libraries(mbgl-test + PRIVATE mbgl-filesource PRIVATE mbgl-loop-uv ) + + target_add_mason_package(mbgl-test PUBLIC libuv) endmacro() @@ -167,8 +176,11 @@ macro(mbgl_platform_benchmark) ) target_link_libraries(mbgl-benchmark + PRIVATE mbgl-filesource PRIVATE mbgl-loop-uv ) + + target_add_mason_package(mbgl-benchmark PUBLIC libuv) endmacro() diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake index bb2cc9ac1c..aca99f9b40 100644 --- a/platform/macos/config.cmake +++ b/platform/macos/config.cmake @@ -6,29 +6,11 @@ mason_use(gtest VERSION 1.8.0) mason_use(benchmark VERSION 1.2.0) mason_use(icu VERSION 58.1-min-size) +include(cmake/loop-uv.cmake) include(cmake/loop-darwin.cmake) macro(mbgl_platform_core) target_sources(mbgl-core - # File source - PRIVATE platform/darwin/src/http_file_source.mm - PRIVATE platform/default/asset_file_source.cpp - PRIVATE platform/default/default_file_source.cpp - PRIVATE platform/default/local_file_source.cpp - PRIVATE platform/default/online_file_source.cpp - - # Default styles - PRIVATE platform/default/mbgl/util/default_styles.hpp - - # Offline - PRIVATE platform/default/mbgl/storage/offline.cpp - PRIVATE platform/default/mbgl/storage/offline_database.cpp - PRIVATE platform/default/mbgl/storage/offline_database.hpp - PRIVATE platform/default/mbgl/storage/offline_download.cpp - PRIVATE platform/default/mbgl/storage/offline_download.hpp - PRIVATE platform/default/sqlite3.cpp - PRIVATE platform/default/sqlite3.hpp - # Misc PRIVATE platform/darwin/mbgl/storage/reachability.h PRIVATE platform/darwin/mbgl/storage/reachability.m @@ -86,23 +68,47 @@ macro(mbgl_platform_core) PUBLIC "-framework ImageIO" PUBLIC "-framework CoreServices" PUBLIC "-framework SystemConfiguration" + ) +endmacro() + + +macro(mbgl_filesource) + target_sources(mbgl-filesource + # File source + PRIVATE platform/darwin/src/http_file_source.mm + + # Database + PRIVATE platform/default/sqlite3.cpp + ) + + target_compile_options(mbgl-filesource + PRIVATE -fobjc-arc + PRIVATE -fvisibility=hidden + ) + + target_link_libraries(mbgl-filesource PUBLIC "-lsqlite3" + PUBLIC "-framework Foundation" ) endmacro() macro(mbgl_platform_glfw) target_link_libraries(mbgl-glfw + PRIVATE mbgl-filesource PRIVATE mbgl-loop-darwin ) + target_compile_options(mbgl-glfw PRIVATE -fvisibility=hidden ) + endmacro() macro(mbgl_platform_render) target_link_libraries(mbgl-render + PRIVATE mbgl-filesource PRIVATE mbgl-loop-darwin ) target_compile_options(mbgl-render @@ -113,6 +119,7 @@ endmacro() macro(mbgl_platform_offline) target_link_libraries(mbgl-offline + PRIVATE mbgl-filesource PRIVATE mbgl-loop-darwin ) target_compile_options(mbgl-offline @@ -137,6 +144,7 @@ macro(mbgl_platform_test) ) target_link_libraries(mbgl-test + PRIVATE mbgl-filesource PRIVATE mbgl-loop-darwin ) endmacro() @@ -157,6 +165,7 @@ macro(mbgl_platform_benchmark) ) target_link_libraries(mbgl-benchmark + PRIVATE mbgl-filesource PRIVATE mbgl-loop-darwin ) endmacro() diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index fcb0544479..34f8860686 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -80,6 +80,8 @@ 556660D61E1D07E400E2C41B /* MGLVersionNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 556660D51E1D07E400E2C41B /* MGLVersionNumber.m */; }; 558DE7A61E56161C00C7916D /* MGLFoundation_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 558DE7A41E56161C00C7916D /* MGLFoundation_Private.h */; }; 558DE7A71E56161C00C7916D /* MGLFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 558DE7A51E56161C00C7916D /* MGLFoundation.mm */; }; + 55D120A31F7906E6004B6D81 /* libmbgl-filesource.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D120A41F7906E6004B6D81 /* libmbgl-filesource.a */; }; + 55D120A51F790A0C004B6D81 /* libmbgl-filesource.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D120A41F7906E6004B6D81 /* libmbgl-filesource.a */; }; 55E2AD111E5B0A6900E8C587 /* MGLOfflineStorageTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 55E2AD101E5B0A6900E8C587 /* MGLOfflineStorageTests.mm */; }; 92092EF01F5EB10E00AF5130 /* MGLMapSnapshotter.h in Headers */ = {isa = PBXBuildFile; fileRef = 92092EEE1F5EB10E00AF5130 /* MGLMapSnapshotter.h */; settings = {ATTRIBUTES = (Public, ); }; }; 92092EF11F5EB10E00AF5130 /* MGLMapSnapshotter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 92092EEF1F5EB10E00AF5130 /* MGLMapSnapshotter.mm */; }; @@ -353,6 +355,7 @@ 556660D51E1D07E400E2C41B /* MGLVersionNumber.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MGLVersionNumber.m; path = ../../darwin/test/MGLVersionNumber.m; sourceTree = "<group>"; }; 558DE7A41E56161C00C7916D /* MGLFoundation_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLFoundation_Private.h; sourceTree = "<group>"; }; 558DE7A51E56161C00C7916D /* MGLFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFoundation.mm; sourceTree = "<group>"; }; + 55D120A41F7906E6004B6D81 /* libmbgl-filesource.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libmbgl-filesource.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 55D9B4B01D005D3900C1CCE2 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; 55E2AD101E5B0A6900E8C587 /* MGLOfflineStorageTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLOfflineStorageTests.mm; path = ../../darwin/test/MGLOfflineStorageTests.mm; sourceTree = "<group>"; }; 55FE0E8D1D100A0900FD240B /* config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = config.xcconfig; path = ../../build/macos/config.xcconfig; sourceTree = "<group>"; }; @@ -609,6 +612,7 @@ buildActionMask = 2147483647; files = ( 5548BE781D09E718005DDE81 /* libmbgl-core.a in Frameworks */, + 55D120A31F7906E6004B6D81 /* libmbgl-filesource.a in Frameworks */, 52B5D17F1E5E26DF00BBCB48 /* libmbgl-loop-darwin.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -618,6 +622,7 @@ buildActionMask = 2147483647; files = ( DAE0DD7A1D5F015A005A6BB1 /* libmbgl-core.a in Frameworks */, + 55D120A51F790A0C004B6D81 /* libmbgl-filesource.a in Frameworks */, DAE6C3321CC30DB200DB3429 /* Mapbox.framework in Frameworks */, 52B5D1801E5E26DF00BBCB48 /* libmbgl-loop-darwin.a in Frameworks */, ); @@ -979,6 +984,7 @@ DAE6C31E1CC308BC00DB3429 /* Frameworks */ = { isa = PBXGroup; children = ( + 55D120A41F7906E6004B6D81 /* libmbgl-filesource.a */, 5548BE7B1D0ACBBD005DDE81 /* libmbgl-loop-darwin.a */, 55D9B4B01D005D3900C1CCE2 /* libz.tbd */, 52BECB091CC5A26F009CD791 /* SystemConfiguration.framework */, @@ -1818,7 +1824,10 @@ DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_VERSION = A; - HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)"; + HEADER_SEARCH_PATHS = ( + "$(mbgl_core_INCLUDE_DIRECTORIES)", + "$(mbgl_filesource_INCLUDE_DIRECTORIES)", + ); INFOPLIST_FILE = "$(SRCROOT)/sdk/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; @@ -1829,7 +1838,7 @@ OTHER_CFLAGS = "-fvisibility=hidden"; OTHER_LDFLAGS = ( "$(mbgl_core_LINK_LIBRARIES)", - "$(mbgl_loop_LINK_LIBRARIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; PRODUCT_NAME = Mapbox; @@ -1852,14 +1861,17 @@ DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_VERSION = A; - HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)"; + HEADER_SEARCH_PATHS = ( + "$(mbgl_core_INCLUDE_DIRECTORIES)", + "$(mbgl_filesource_INCLUDE_DIRECTORIES)", + ); INFOPLIST_FILE = "$(SRCROOT)/sdk/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; OTHER_CFLAGS = "-fvisibility=hidden"; OTHER_LDFLAGS = ( "$(mbgl_core_LINK_LIBRARIES)", - "$(mbgl_loop_LINK_LIBRARIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", ); PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; PRODUCT_NAME = Mapbox; @@ -1876,7 +1888,10 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; - HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)"; + HEADER_SEARCH_PATHS = ( + "$(mbgl_core_INCLUDE_DIRECTORIES)", + "$(mbgl_filesource_INCLUDE_DIRECTORIES)", + ); INFOPLIST_FILE = test/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; LIBRARY_SEARCH_PATHS = ( @@ -1905,7 +1920,10 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; - HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)"; + HEADER_SEARCH_PATHS = ( + "$(mbgl_core_INCLUDE_DIRECTORIES)", + "$(mbgl_filesource_INCLUDE_DIRECTORIES)", + ); INFOPLIST_FILE = test/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; OTHER_CFLAGS = "-fvisibility=hidden"; diff --git a/platform/qt/config.cmake b/platform/qt/config.cmake index 732fb1de28..a7fdbf3542 100644 --- a/platform/qt/config.cmake +++ b/platform/qt/config.cmake @@ -15,7 +15,7 @@ endif() macro(mbgl_platform_core) target_sources(mbgl-core - ${MBGL_QT_FILES} + ${MBGL_QT_CORE_FILES} ) target_include_directories(mbgl-core @@ -24,7 +24,7 @@ macro(mbgl_platform_core) ) target_link_libraries(mbgl-core - ${MBGL_QT_LIBRARIES} + ${MBGL_QT_CORE_LIBRARIES} ) if(NOT WITH_QT_DECODERS) @@ -50,17 +50,23 @@ macro(mbgl_platform_core) endmacro() + +macro(mbgl_filesource) + target_sources(mbgl-filesource + ${MBGL_QT_FILESOURCE_FILES} + ) + + target_link_libraries(mbgl-filesource + ${MBGL_QT_FILESOURCE_LIBRARIES} + ) +endmacro() + + macro(mbgl_platform_test) target_sources(mbgl-test - PRIVATE platform/default/mbgl/gl/headless_frontend.cpp - PRIVATE platform/default/mbgl/gl/headless_frontend.hpp - PRIVATE platform/default/mbgl/gl/headless_backend.cpp - PRIVATE platform/default/mbgl/gl/headless_backend.hpp - PRIVATE platform/default/mbgl/gl/headless_display.cpp - PRIVATE platform/default/mbgl/gl/headless_display.hpp - PRIVATE platform/qt/test/headless_backend_qt.cpp PRIVATE platform/qt/test/main.cpp - PRIVATE platform/qt/test/qmapboxgl.cpp + PRIVATE platform/qt/test/qmapboxgl.test.cpp + PRIVATE platform/qt/test/qmapboxgl.test.cpp ) set_source_files_properties( @@ -72,7 +78,7 @@ macro(mbgl_platform_test) target_link_libraries(mbgl-test PRIVATE qmapboxgl - ${MBGL_QT_TEST_LIBRARIES} + PRIVATE mbgl-filesource ) endmacro() diff --git a/platform/qt/qt.cmake b/platform/qt/qt.cmake index 489ae5ed08..2346d7d820 100644 --- a/platform/qt/qt.cmake +++ b/platform/qt/qt.cmake @@ -10,22 +10,16 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -D__QT__") set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(MBGL_QT_FILES - # File source - PRIVATE platform/default/asset_file_source.cpp - PRIVATE platform/default/default_file_source.cpp - PRIVATE platform/default/local_file_source.cpp - PRIVATE platform/default/online_file_source.cpp - - # Offline - PRIVATE platform/default/mbgl/storage/offline.cpp - PRIVATE platform/default/mbgl/storage/offline_database.cpp - PRIVATE platform/default/mbgl/storage/offline_database.hpp - PRIVATE platform/default/mbgl/storage/offline_download.cpp - PRIVATE platform/default/mbgl/storage/offline_download.hpp - PRIVATE platform/default/sqlite3.hpp +set(MBGL_QT_CORE_FILES + # Headless view + PRIVATE platform/default/mbgl/gl/headless_frontend.cpp + PRIVATE platform/default/mbgl/gl/headless_frontend.hpp + PRIVATE platform/default/mbgl/gl/headless_backend.cpp + PRIVATE platform/default/mbgl/gl/headless_backend.hpp + PRIVATE platform/default/mbgl/gl/headless_display.cpp + PRIVATE platform/default/mbgl/gl/headless_display.hpp + PRIVATE platform/qt/src/headless_backend_qt.cpp # Misc PRIVATE platform/default/logging_stderr.cpp @@ -42,22 +36,24 @@ set(MBGL_QT_FILES # Platform integration PRIVATE platform/qt/src/async_task.cpp PRIVATE platform/qt/src/async_task_impl.hpp - PRIVATE platform/qt/src/http_file_source.cpp - PRIVATE platform/qt/src/http_file_source.hpp - PRIVATE platform/qt/src/http_request.cpp - PRIVATE platform/qt/src/http_request.hpp PRIVATE platform/qt/src/qt_image.cpp PRIVATE platform/qt/src/run_loop.cpp PRIVATE platform/qt/src/run_loop_impl.hpp - PRIVATE platform/qt/src/sqlite3.cpp PRIVATE platform/qt/src/string_stdlib.cpp PRIVATE platform/qt/src/timer.cpp PRIVATE platform/qt/src/timer_impl.hpp PRIVATE platform/qt/src/utf.cpp ) -include_directories( - PRIVATE platform/qt/include +set(MBGL_QT_FILESOURCE_FILES + # File source + PRIVATE platform/qt/src/http_file_source.cpp + PRIVATE platform/qt/src/http_file_source.hpp + PRIVATE platform/qt/src/http_request.cpp + PRIVATE platform/qt/src/http_request.hpp + + # Database + PRIVATE platform/qt/src/sqlite3.cpp ) # Shared library @@ -72,6 +68,17 @@ add_library(qmapboxgl SHARED platform/default/mbgl/util/default_styles.hpp ) +target_include_directories(qmapboxgl + PUBLIC platform/qt/include +) + +target_link_libraries(qmapboxgl + PRIVATE mbgl-core + PRIVATE mbgl-filesource + ${MBGL_QT_CORE_LIBRARIES} + ${MBGL_QT_FILESOURCE_LIBRARIES} +) + # C++ app add_executable(mbgl-qt platform/qt/app/main.cpp @@ -80,6 +87,20 @@ add_executable(mbgl-qt platform/qt/resources/common.qrc ) +target_compile_options(qmapboxgl + PRIVATE -std=c++03 +) + +target_link_libraries(mbgl-qt + PRIVATE qmapboxgl +) + +if(WITH_QT_4) + include(platform/qt/qt4.cmake) +else() + include(platform/qt/qt5.cmake) +endif() + xcode_create_scheme(TARGET mbgl-qt) if(WITH_QT_4) @@ -90,22 +111,22 @@ endif() # OS specific configurations if (MASON_PLATFORM STREQUAL "osx" OR MASON_PLATFORM STREQUAL "ios") - list(APPEND MBGL_QT_FILES + list(APPEND MBGL_QT_CORE_FILES PRIVATE platform/darwin/src/nsthread.mm ) - list(APPEND MBGL_QT_LIBRARIES + list(APPEND MBGL_QT_CORE_LIBRARIES PRIVATE "-framework Foundation" PRIVATE "-framework OpenGL" ) elseif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") - list(APPEND MBGL_QT_FILES + list(APPEND MBGL_QT_CORE_FILES PRIVATE platform/default/thread.cpp ) - list(APPEND MBGL_QT_LIBRARIES + list(APPEND MBGL_QT_CORE_LIBRARIES PRIVATE -lGL ) elseif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - list(APPEND MBGL_QT_FILES + list(APPEND MBGL_QT_CORE_FILES PRIVATE platform/qt/src/thread.cpp ) endif() diff --git a/platform/qt/qt4.cmake b/platform/qt/qt4.cmake index 66aed87c38..272009c541 100644 --- a/platform/qt/qt4.cmake +++ b/platform/qt/qt4.cmake @@ -1,31 +1,20 @@ find_package(Qt4 REQUIRED) -set(MBGL_QT_LIBRARIES - PRIVATE Qt4::QtCore - PRIVATE Qt4::QtGui - PRIVATE Qt4::QtNetwork - PRIVATE Qt4::QtOpenGL - PRIVATE Qt4::QtSql +set(MBGL_QT_CORE_LIBRARIES + PUBLIC Qt4::QtCore + PUBLIC Qt4::QtGui + PUBLIC Qt4::QtOpenGL ) -set(MBGL_QT_TEST_LIBRARIES - PRIVATE Qt4::QtCore - PRIVATE Qt4::QtOpenGL +set(MBGL_QT_FILESOURCE_LIBRARIES + PUBLIC Qt4::QtNetwork + PUBLIC Qt4::QtSql ) target_compile_options(qmapboxgl PRIVATE -Wno-inconsistent-missing-override ) -target_link_libraries(qmapboxgl - PRIVATE mbgl-core - PRIVATE Qt4::QtCore - PRIVATE Qt4::QtGui - PRIVATE Qt4::QtOpenGL -) - target_link_libraries(mbgl-qt - PRIVATE qmapboxgl - PRIVATE Qt4::QtGui PRIVATE Qt4::QtOpenGL ) diff --git a/platform/qt/qt5.cmake b/platform/qt/qt5.cmake index ed51051311..c4af774ba3 100644 --- a/platform/qt/qt5.cmake +++ b/platform/qt/qt5.cmake @@ -1,35 +1,21 @@ find_package(Qt5Core REQUIRED) find_package(Qt5Gui REQUIRED) -find_package(Qt5Location REQUIRED) find_package(Qt5Network REQUIRED) find_package(Qt5OpenGL REQUIRED) find_package(Qt5Widgets REQUIRED) find_package(Qt5Sql REQUIRED) -set(MBGL_QT_LIBRARIES - PRIVATE Qt5::Core - PRIVATE Qt5::Gui - PRIVATE Qt5::Network - PRIVATE Qt5::Sql +set(MBGL_QT_CORE_LIBRARIES + PUBLIC Qt5::Core + PUBLIC Qt5::Gui + PUBLIC Qt5::OpenGL ) -set(MBGL_QT_TEST_LIBRARIES - PRIVATE Qt5::Core - PRIVATE Qt5::Gui - PRIVATE Qt5::Widgets - PRIVATE Qt5::OpenGL -) - -target_link_libraries(qmapboxgl - PRIVATE mbgl-core - PRIVATE Qt5::Core - PRIVATE Qt5::Gui - PRIVATE Qt5::Location - PRIVATE Qt5::Sql +set(MBGL_QT_FILESOURCE_LIBRARIES + PUBLIC Qt5::Network + PUBLIC Qt5::Sql ) target_link_libraries(mbgl-qt - PRIVATE qmapboxgl - PRIVATE Qt5::OpenGL PRIVATE Qt5::Widgets ) diff --git a/platform/qt/test/headless_backend_qt.cpp b/platform/qt/src/headless_backend_qt.cpp index 5f95b2f96a..5f95b2f96a 100644 --- a/platform/qt/test/headless_backend_qt.cpp +++ b/platform/qt/src/headless_backend_qt.cpp diff --git a/platform/qt/test/qmapboxgl.cpp b/platform/qt/test/qmapboxgl.cpp deleted file mode 100644 index 747f8796fa..0000000000 --- a/platform/qt/test/qmapboxgl.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include <mbgl/test/util.hpp> -#include <mbgl/util/io.hpp> - -#include <QApplication> -#include <QMapbox> -#include <QMapboxGL> - -// We're using QGLFramebufferObject, which is only available in Qt 5 and up. -#if QT_VERSION >= 0x050000 - -#include <QGLWidget> -#include <QGLFramebufferObject> - -class QMapboxGLTest : public QObject, public ::testing::Test { - Q_OBJECT - -public: - QMapboxGLTest() : size(512, 512), fbo((assert(widget.context()->isValid()), widget.makeCurrent(), size)), map(nullptr, settings, size) { - connect(&map, SIGNAL(mapChanged(QMapboxGL::MapChange)), - this, SLOT(onMapChanged(QMapboxGL::MapChange))); - connect(&map, SIGNAL(needsRendering()), - this, SLOT(onNeedsRendering())); - map.resize(fbo.size(), fbo.size()); - map.setFramebufferObject(fbo.handle()); - map.setCoordinateZoom(QMapbox::Coordinate(60.170448, 24.942046), 14); - } - - void runUntil(QMapboxGL::MapChange status) { - changeCallback = [&](QMapboxGL::MapChange change) { - if (change == status) { - qApp->exit(); - changeCallback = nullptr; - } - }; - - qApp->exec(); - } - -private: - QGLWidget widget; - const QSize size; - QGLFramebufferObject fbo; - -protected: - QMapboxGLSettings settings; - QMapboxGL map; - - std::function<void(QMapboxGL::MapChange)> changeCallback; - -private slots: - void onMapChanged(QMapboxGL::MapChange change) { - if (changeCallback) { - changeCallback(change); - } - }; - - void onNeedsRendering() { - widget.makeCurrent(); - fbo.bind(); - glViewport(0, 0, fbo.width(), fbo.height()); - map.render(); - }; -}; - -TEST_F(QMapboxGLTest, TEST_DISABLED_ON_CI(styleJson)) { - QString json = QString::fromStdString( - mbgl::util::read_file("test/fixtures/resources/style_vector.json")); - - map.setStyleJson(json); - ASSERT_EQ(map.styleJson(), json); - runUntil(QMapboxGL::MapChangeDidFinishLoadingMap); - - map.setStyleJson("invalid json"); - runUntil(QMapboxGL::MapChangeDidFailLoadingMap); - - map.setStyleJson("\"\""); - runUntil(QMapboxGL::MapChangeDidFailLoadingMap); - - map.setStyleJson(QString()); - runUntil(QMapboxGL::MapChangeDidFailLoadingMap); -} - -TEST_F(QMapboxGLTest, TEST_DISABLED_ON_CI(styleUrl)) { - QString url(QMapbox::defaultStyles()[0].first); - - map.setStyleUrl(url); - ASSERT_EQ(map.styleUrl(), url); - runUntil(QMapboxGL::MapChangeDidFinishLoadingMap); - - map.setStyleUrl("invalid://url"); - runUntil(QMapboxGL::MapChangeDidFailLoadingMap); - - map.setStyleUrl(QString()); - runUntil(QMapboxGL::MapChangeDidFailLoadingMap); -} - -#include "qmapboxgl.moc" - -#endif diff --git a/platform/qt/test/qmapboxgl.test.cpp b/platform/qt/test/qmapboxgl.test.cpp new file mode 100644 index 0000000000..c6ae3ed403 --- /dev/null +++ b/platform/qt/test/qmapboxgl.test.cpp @@ -0,0 +1,77 @@ +#include "qmapboxgl.test.hpp" + +#include <mbgl/util/io.hpp> + +#include <QMapbox> + +// We're using QGLFramebufferObject, which is only available in Qt 5 and up. +#if QT_VERSION >= 0x050000 + +QMapboxGLTest::QMapboxGLTest() : size(512, 512), fbo((assert(widget.context()->isValid()), widget.makeCurrent(), size)), map(nullptr, settings, size) { + connect(&map, SIGNAL(mapChanged(QMapboxGL::MapChange)), + this, SLOT(onMapChanged(QMapboxGL::MapChange))); + connect(&map, SIGNAL(needsRendering()), + this, SLOT(onNeedsRendering())); + map.resize(fbo.size(), fbo.size()); + map.setFramebufferObject(fbo.handle()); + map.setCoordinateZoom(QMapbox::Coordinate(60.170448, 24.942046), 14); +} + +void QMapboxGLTest::runUntil(QMapboxGL::MapChange status) { + changeCallback = [&](QMapboxGL::MapChange change) { + if (change == status) { + qApp->exit(); + changeCallback = nullptr; + } + }; + + qApp->exec(); +} + +void QMapboxGLTest::onMapChanged(QMapboxGL::MapChange change) { + if (changeCallback) { + changeCallback(change); + } +} + +void QMapboxGLTest::onNeedsRendering() { + widget.makeCurrent(); + fbo.bind(); + glViewport(0, 0, fbo.width(), fbo.height()); + map.render(); +} + + +TEST_F(QMapboxGLTest, TEST_DISABLED_ON_CI(styleJson)) { + QString json = QString::fromStdString( + mbgl::util::read_file("test/fixtures/resources/style_vector.json")); + + map.setStyleJson(json); + ASSERT_EQ(map.styleJson(), json); + runUntil(QMapboxGL::MapChangeDidFinishLoadingMap); + + map.setStyleJson("invalid json"); + runUntil(QMapboxGL::MapChangeDidFailLoadingMap); + + map.setStyleJson("\"\""); + runUntil(QMapboxGL::MapChangeDidFailLoadingMap); + + map.setStyleJson(QString()); + runUntil(QMapboxGL::MapChangeDidFailLoadingMap); +} + +TEST_F(QMapboxGLTest, TEST_DISABLED_ON_CI(styleUrl)) { + QString url(QMapbox::defaultStyles()[0].first); + + map.setStyleUrl(url); + ASSERT_EQ(map.styleUrl(), url); + runUntil(QMapboxGL::MapChangeDidFinishLoadingMap); + + map.setStyleUrl("invalid://url"); + runUntil(QMapboxGL::MapChangeDidFailLoadingMap); + + map.setStyleUrl(QString()); + runUntil(QMapboxGL::MapChangeDidFailLoadingMap); +} + +#endif diff --git a/platform/qt/test/qmapboxgl.test.hpp b/platform/qt/test/qmapboxgl.test.hpp new file mode 100644 index 0000000000..04d63610ca --- /dev/null +++ b/platform/qt/test/qmapboxgl.test.hpp @@ -0,0 +1,36 @@ +#include <mbgl/test/util.hpp> + +#include <QApplication> +#include <QMapboxGL> + +// We're using QGLFramebufferObject, which is only available in Qt 5 and up. +#if QT_VERSION >= 0x050000 + +#include <QGLWidget> +#include <QGLFramebufferObject> + +class QMapboxGLTest : public QObject, public ::testing::Test { + Q_OBJECT + +public: + QMapboxGLTest(); + + void runUntil(QMapboxGL::MapChange); + +private: + QGLWidget widget; + const QSize size; + QGLFramebufferObject fbo; + +protected: + QMapboxGLSettings settings; + QMapboxGL map; + + std::function<void(QMapboxGL::MapChange)> changeCallback; + +private slots: + void onMapChanged(QMapboxGL::MapChange); + void onNeedsRendering(); +}; + +#endif diff --git a/scripts/config.xcconfig.in b/scripts/config.xcconfig.in index eb6bc71b89..357732c9ae 100644 --- a/scripts/config.xcconfig.in +++ b/scripts/config.xcconfig.in @@ -3,3 +3,7 @@ // mbgl-core mbgl_core_INCLUDE_DIRECTORIES = "@mbgl_core_INCLUDE_DIRECTORIES@" mbgl_core_LINK_LIBRARIES = "@mbgl_core_LINK_LIBRARIES@" + +// mbgl-filesource +mbgl_filesource_INCLUDE_DIRECTORIES = "@mbgl_filesource_INCLUDE_DIRECTORIES@" +mbgl_filesource_LINK_LIBRARIES = "@mbgl_filesource_LINK_LIBRARIES@" diff --git a/src/mbgl/util/http_timeout.cpp b/src/mbgl/util/http_timeout.cpp index ca9a93498f..3456369250 100644 --- a/src/mbgl/util/http_timeout.cpp +++ b/src/mbgl/util/http_timeout.cpp @@ -1,6 +1,8 @@ #include <mbgl/util/http_timeout.hpp> #include <mbgl/util/constants.hpp> +#include <cassert> + namespace mbgl { namespace http { |