diff --git a/CMakeLists.txt b/CMakeLists.txt index 68e92e2bf0..464727e533 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ project(tangram) # Options option(TANGRAM_USE_SYSTEM_FONT_LIBS "Use system libraries Freetype, ICU and Harfbuzz via pkgconfig" OFF) option(TANGRAM_USE_SYSTEM_GLFW_LIBS "Use system libraries for GLFW3 via pkgconfig" OFF) +option(TANGRAM_USE_SYSTEM_SQLITE_LIBS "Use system libraries for SQLite via pkgconfig" OFF) +option(TANGRAM_MBTILES_DATASOURCE "Build MBTiles Datasource" ON) option(TANGRAM_BUILD_TESTS "Build unit tests" OFF) option(TANGRAM_BUNDLE_TESTS "Compile all tests into a single binary" ON) diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt index 0c66950eb5..2252541179 100644 --- a/bench/CMakeLists.txt +++ b/bench/CMakeLists.txt @@ -32,6 +32,7 @@ foreach(_src_file_path ${BENCH_SOURCES}) ) target_link_libraries(${EXECUTABLE_NAME} + PRIVATE tangram-core benchmark platform_mock diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 109c129b8a..e658e48f3b 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -3,11 +3,15 @@ project(tangram-core) # Build core library dependencies. add_subdirectory(deps) +if (TANGRAM_MBTILES_DATASOURCE) + set(MBTILES_SOURCES src/data/mbtilesDataSource.cpp) + set(MBTILES_LIBS SQLiteCpp sqlite3) +endif() + add_library(tangram-core src/map.cpp src/platform.cpp src/data/clientGeoJsonSource.cpp - src/data/mbtilesDataSource.cpp src/data/memoryCacheDataSource.cpp src/data/networkDataSource.cpp src/data/properties.cpp @@ -95,6 +99,7 @@ add_library(tangram-core src/view/flyTo.cpp src/view/view.cpp src/view/viewConstraint.cpp + ${MBTILES_SOURCES} ) # Include headers from core library and dependencies. @@ -128,12 +133,11 @@ target_include_directories(tangram-core # Link core library dependencies. target_link_libraries(tangram-core PRIVATE + ${MBTILES_LIBS} duktape css-color-parser-cpp yaml-cpp alfons - SQLiteCpp - sqlite3 double-conversion miniz z @@ -145,7 +149,15 @@ if(UNIX AND NOT APPLE) endif() if(TANGRAM_WARN_ON_RULE_CONFLICT) - add_definitions(-DTANGRAM_WARN_ON_RULE_CONFLICT) + target_compile_definitions(tangram-core + PRIVATE + TANGRAM_WARN_ON_RULE_CONFLICT) +endif() + +if (TANGRAM_MBTILES_DATASOURCE) + target_compile_definitions(tangram-core + PRIVATE + TANGRAM_MBTILES_DATASOURCE) endif() if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/core/deps/CMakeLists.txt b/core/deps/CMakeLists.txt index 3ef73a9e5e..f738aea18e 100644 --- a/core/deps/CMakeLists.txt +++ b/core/deps/CMakeLists.txt @@ -69,23 +69,29 @@ endif() set(GLM_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glm) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/alfons) -## SQLiteCpp ## -############### -set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "") -set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "") -set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "") - -add_subdirectory(SQLiteCpp) - -# Extensions aren't needed for MBTiles and aren't available in older versions of sqlite3. -target_compile_definitions(SQLiteCpp PRIVATE SQLITE_OMIT_LOAD_EXTENSION) - -# needed for sqlite3 to work for ndk15c+ and android api level < 21 -# refer: -# https://github.com/android-ndk/ndk/issues/477 and -# https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md -if (ANDROID) +if (TANGRAM_MBTILES_DATASOURCE) + ## SQLiteCpp ## + ############### + set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "") + set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "") + set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "") + + if (TANGRAM_USE_SYSTEM_SQLITE_LIBS) + set(SQLITECPP_INTERNAL_SQLITE OFF CACHE BOOL "") + endif() + + add_subdirectory(SQLiteCpp) + + # Extensions aren't needed for MBTiles and aren't available in older versions of sqlite3. + target_compile_definitions(SQLiteCpp PRIVATE SQLITE_OMIT_LOAD_EXTENSION) + + # needed for sqlite3 to work for ndk15c+ and android api level < 21 + # refer: + # https://github.com/android-ndk/ndk/issues/477 and + # https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md + if (ANDROID) target_compile_definitions(sqlite3 PRIVATE _FILE_OFFSET_BITS=32) + endif() endif() ## double-conversion ## diff --git a/core/src/map.cpp b/core/src/map.cpp index 7d81acd9e6..5ec42d05cf 100644 --- a/core/src/map.cpp +++ b/core/src/map.cpp @@ -365,8 +365,12 @@ SceneID Map::updateSceneAsync(const std::vector& _sceneUpdates) { } void Map::setMBTiles(const char* _dataSourceName, const char* _mbtilesFilePath) { +#ifdef TANGRAM_MBTILES_DATASOURCE std::string scenePath = std::string("sources.") + _dataSourceName + ".mbtiles"; updateSceneAsync({SceneUpdate{scenePath.c_str(), _mbtilesFilePath}}); +#else + LOGE("MBTiles support is disabled. This source will be ignored: %s", _dataSourceName); +#endif } void Map::resize(int _newWidth, int _newHeight) { diff --git a/core/src/scene/sceneLoader.cpp b/core/src/scene/sceneLoader.cpp index 207f9cc113..bcf51baa4f 100644 --- a/core/src/scene/sceneLoader.cpp +++ b/core/src/scene/sceneLoader.cpp @@ -1038,10 +1038,15 @@ void SceneLoader::loadSource(const std::shared_ptr& platform, const st rawSources->setCacheSize(CACHE_SIZE); if (isMBTilesFile) { +#ifdef TANGRAM_MBTILES_DATASOURCE // If we have MBTiles, we know the source is tiled. tiled = true; // Create an MBTiles data source from the file at the url and add it to the source chain. rawSources->setNext(std::make_unique(platform, name, url, "")); +#else + LOGE("MBTiles support is disabled. This source will be ignored: %s", name.c_str()); + return; +#endif } else if (tiled) { rawSources->setNext(std::make_unique(platform, url, std::move(subdomains), isTms)); } diff --git a/platforms/android/tangram/build.gradle b/platforms/android/tangram/build.gradle index d06a55a76c..2bbcd3ccdc 100644 --- a/platforms/android/tangram/build.gradle +++ b/platforms/android/tangram/build.gradle @@ -39,7 +39,10 @@ android { '-Wignored-qualifiers', '-Wtype-limits', '-Wmissing-field-initializers', - '-Wno-format-pedantic' + '-Wno-format-pedantic', + '-Wno-gnu-statement-expression', + '-Wgnu-anonymous-struct', + '-Wno-nested-anon-types' if (abi == 'all') { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' diff --git a/platforms/linux/config.cmake b/platforms/linux/config.cmake index b3e68267f3..d374f4470a 100644 --- a/platforms/linux/config.cmake +++ b/platforms/linux/config.cmake @@ -19,8 +19,6 @@ check_unsupported_compiler_version() add_definitions(-DTANGRAM_LINUX) -get_nextzen_api_key(NEXTZEN_API_KEY) -add_definitions(-DNEXTZEN_API_KEY="${NEXTZEN_API_KEY}") find_package(OpenGL REQUIRED) @@ -75,4 +73,10 @@ target_compile_options(tangram -Wmissing-field-initializers ) +get_nextzen_api_key(NEXTZEN_API_KEY) +target_compile_definitions(tangram + PRIVATE + NEXTZEN_API_KEY="${NEXTZEN_API_KEY}") + + add_resources(tangram "${PROJECT_SOURCE_DIR}/scenes" "res")