diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2018-08-30 21:38:50 +0300 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2018-09-05 12:26:15 +0200 |
commit | 679d66f36d0034978211e7cba00392b24e8576df (patch) | |
tree | ca25c290776b655e649f1728cc0fed9bcde7fcd2 | |
parent | 0e95e8f6b241ee8b30635a986f2c503f21997dd7 (diff) | |
download | qtlocation-mapboxgl-679d66f36d0034978211e7cba00392b24e8576df.tar.gz |
[build] use vendored SQLite for LTO benefits + custom compile flags
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | cmake/mason-dependencies.cmake | 2 | ||||
-rw-r--r-- | cmake/sqlite.cmake | 36 | ||||
-rw-r--r-- | platform/android/config.cmake | 3 | ||||
-rw-r--r-- | platform/linux/config.cmake | 4 | ||||
-rwxr-xr-x | scripts/vendor/sqlite.sh | 14 | ||||
-rw-r--r-- | vendor/sqlite/files.txt | 2 | ||||
-rw-r--r-- | vendor/sqlite/version.txt | 1 |
8 files changed, 61 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 98d6676ef1..bb315916b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo Sanitize) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) @@ -89,8 +90,11 @@ if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-command-line-argument") endif() set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os -DNDEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -DNDEBUG") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_SANITIZE "${CMAKE_CXX_FLAGS_SANITIZE} -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls") +set(CMAKE_C_FLAGS_SANITIZE "${CMAKE_C_FLAGS_SANITIZE} -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls") if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unknown-warning-option") diff --git a/cmake/mason-dependencies.cmake b/cmake/mason-dependencies.cmake index f869fe2fdc..d2ea79b32b 100644 --- a/cmake/mason-dependencies.cmake +++ b/cmake/mason-dependencies.cmake @@ -20,13 +20,11 @@ mason_use(vector-tile VERSION 1.0.2 HEADER_ONLY) if(MBGL_PLATFORM STREQUAL "android") mason_use(jni.hpp VERSION 3.0.0 HEADER_ONLY) - mason_use(sqlite VERSION 3.24.0-min-size) mason_use(icu VERSION 58.1-min-size) elseif(MBGL_PLATFORM STREQUAL "ios") mason_use(icu VERSION 58.1-min-size) elseif(MBGL_PLATFORM STREQUAL "linux") mason_use(glfw VERSION 2018-06-27-0be4f3f) - mason_use(sqlite VERSION 3.24.0-min-size) mason_use(libuv VERSION 1.9.1) mason_use(libpng VERSION 1.6.25) mason_use(libjpeg-turbo VERSION 1.5.0) diff --git a/cmake/sqlite.cmake b/cmake/sqlite.cmake new file mode 100644 index 0000000000..03841ea9b9 --- /dev/null +++ b/cmake/sqlite.cmake @@ -0,0 +1,36 @@ +add_vendor_target(sqlite STATIC) + +target_compile_definitions(sqlite + PRIVATE "-DVERSION=\"3.24.0\"" + PRIVATE "-DSTDC_HEADERS=int" + PRIVATE "-DHAVE_SYS_TYPES_H=1" + PRIVATE "-DHAVE_SYS_STAT_H=1" + PRIVATE "-DHAVE_STDLIB_H=1" + PRIVATE "-DHAVE_STRING_H=1" + PRIVATE "-DHAVE_MEMORY_H=1" + PRIVATE "-DHAVE_STRINGS_H=1" + PRIVATE "-DHAVE_INTTYPES_H=1" + PRIVATE "-DHAVE_STDINT_H=1" + PRIVATE "-DHAVE_UNISTD_H=1" + PRIVATE "-DHAVE_DLFCN_H=1" + PRIVATE "-DHAVE_FDATASYNC=1" + PRIVATE "-DHAVE_USLEEP=1" + PRIVATE "-DHAVE_LOCALTIME_R=1" + PRIVATE "-DHAVE_GMTIME_R=1" + PRIVATE "-DHAVE_DECL_STRERROR_R=1" + PRIVATE "-DHAVE_STRERROR_R=1" + PRIVATE "-DHAVE_ZLIB_H=1" + PRIVATE "-D_REENTRANT=1" + PRIVATE "-DSQLITE_THREADSAFE=1" + PRIVATE "-DSQLITE_HAVE_ZLIB" + + # These are disabled on purpose, since we're not using these features. + # PRIVATE "-DSQLITE_ENABLE_FTS5" + # PRIVATE "-DSQLITE_ENABLE_JSON1" + # PRIVATE "-DSQLITE_ENABLE_FTS3" + # PRIVATE "-DSQLITE_ENABLE_RTREE" +) + +target_compile_options(sqlite + PRIVATE "-Wno-int-conversion" +) diff --git a/platform/android/config.cmake b/platform/android/config.cmake index 714d566bd8..f0c3324cc4 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -1,6 +1,7 @@ set(USE_GLES2 ON) include(cmake/nunicode.cmake) +include(cmake/sqlite.cmake) # Build thin archives. set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>") @@ -66,10 +67,10 @@ macro(mbgl_filesource) # Modify platform/android/filesource-files.txt to change the source files for this target. target_sources_from_file(mbgl-filesource PRIVATE platform/android/filesource-files.txt) - target_add_mason_package(mbgl-filesource PUBLIC sqlite) target_add_mason_package(mbgl-filesource PUBLIC jni.hpp) target_link_libraries(mbgl-filesource + PUBLIC sqlite PUBLIC -llog PUBLIC -landroid PUBLIC -lstdc++ diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake index b55cedcacb..86280b7068 100644 --- a/platform/linux/config.cmake +++ b/platform/linux/config.cmake @@ -1,4 +1,5 @@ include(cmake/nunicode.cmake) +include(cmake/sqlite.cmake) add_library(mbgl-loop-uv STATIC platform/default/async_task.cpp @@ -107,11 +108,10 @@ macro(mbgl_filesource) PRIVATE platform/default/sqlite3.cpp ) - target_add_mason_package(mbgl-filesource PUBLIC sqlite) - # We're not referencing any cURL symbols since we're dynamically loading it. However, we want to # link the library anyway since we're definitely going to load it on startup anyway. target_link_libraries(mbgl-filesource + PUBLIC sqlite PUBLIC -Wl,--no-as-needed -lcurl -Wl,--as-needed ) endmacro() diff --git a/scripts/vendor/sqlite.sh b/scripts/vendor/sqlite.sh new file mode 100755 index 0000000000..6038a5f108 --- /dev/null +++ b/scripts/vendor/sqlite.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +source "$(dirname "${BASH_SOURCE[0]}")/common.sh" + +NAME=sqlite +VERSION=3.24.0 +ROOT=sqlite-amalgamation-3240000 + +download "https://www.sqlite.org/2018/$ROOT.zip" +init +extract_zip "$ROOT/sqlite3.*" +mkdir -p include src +mv sqlite3.h include +mv sqlite3.c src +file_list include src -name "*.h" -o -name "*.c" diff --git a/vendor/sqlite/files.txt b/vendor/sqlite/files.txt new file mode 100644 index 0000000000..19db218786 --- /dev/null +++ b/vendor/sqlite/files.txt @@ -0,0 +1,2 @@ +include/sqlite3.h +src/sqlite3.c diff --git a/vendor/sqlite/version.txt b/vendor/sqlite/version.txt new file mode 100644 index 0000000000..954e228821 --- /dev/null +++ b/vendor/sqlite/version.txt @@ -0,0 +1 @@ +3.24.0 |