diff --git a/Makefile b/Makefile index 830e5a45..b7b8d959 100644 --- a/Makefile +++ b/Makefile @@ -84,6 +84,11 @@ debug: cmake $(GENERATOR) $(BUILD_FLAGS) $(CLIENT_FLAGS) -DCMAKE_BUILD_TYPE=Debug -S ./duckdb/ -B build/debug && \ cmake --build build/debug --config Debug +android_release: + mkdir -p build/release/android && \ + cmake $(GENERATOR) $(BUILD_FLAGS) $(CLIENT_FLAGS) -DCMAKE_BUILD_TYPE=Release -S ./duckdb/ -DCMAKE_TOOLCHAIN_FILE=$(ANDROID_NDK_HOME)/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -B build/release/android && \ + cmake --build build/release/android --config Release + release: mkdir -p build/release && \ cmake $(GENERATOR) $(BUILD_FLAGS) $(CLIENT_FLAGS) -DCMAKE_BUILD_TYPE=Release -S ./duckdb/ -B build/release && \ diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index f26869ff..4f60aa3e 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -11,62 +11,100 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) endif() -if (NOT EMSCRIPTEN) - if (OSX_BUILD_ARCH) - message(STATUS "building for OSX architecture: ${OSX_BUILD_ARCH}") - if (NOT APPLE) - error("This only makes sense on OSX") +if(NOT EMSCRIPTEN) + if(OSX_BUILD_ARCH) + message(STATUS "building for OSX architecture: ${OSX_BUILD_ARCH}") + + if(NOT APPLE) + error("This only makes sense on OSX") + endif() + + set(CMAKE_OSX_ARCHITECTURES ${OSX_BUILD_ARCH}) + + # Escape semicolons in CMAKE_OSX_ARCHITECTURES before passing to ExternalProject_Add + string(REPLACE ";" "$" CMAKE_OSX_ARCHITECTURES_PACKED "${CMAKE_OSX_ARCHITECTURES}") endif() - set(CMAKE_OSX_ARCHITECTURES ${OSX_BUILD_ARCH}) - # Escape semicolons in CMAKE_OSX_ARCHITECTURES before passing to ExternalProject_Add - string(REPLACE ";" "$" CMAKE_OSX_ARCHITECTURES_PACKED "${CMAKE_OSX_ARCHITECTURES}") - endif() endif() -set(CMAKE_FLAGS_POINTER_SIZE ) -set(CMAKE_PROJ_FLAGS ) +set(CMAKE_FLAGS_POINTER_SIZE) +set(CMAKE_PROJ_FLAGS) set(OGR_ENABLE_DRIVER_OPENFILEGDB ON) -set(CMAKE_GDAL_FLAGS ) -set(PATCH_NAME_ENDING ) -if (EMSCRIPTEN) - set(CMAKE_FLAGS_POINTER_SIZE -DCMAKE_SIZEOF_VOID_P=4 -DCMAKE_SIZEOF_VOIDP=4) - set(CMAKE_PROJ_FLAGS -DCMAKE_MODULE_PATH=${LOCAL_INSTALL_DIR}/lib/cmake -DSQLITE3_INCLUDE_DIR=${LOCAL_INSTALL_DIR}/include -DSQLITE3_LIBRARY=${LOCAL_INSTALL_DIR}/lib/libsqlite3.a) - set(CMAKE_GDAL_FLAGS -DACCEPT_MISSING_LINUX_FS_HEADER=ON -DSIZEOF_INT=4 -DSIZEOF_UNSIGNED_LONG=4 -DSIZEOF_OFF_T=4 -DGEOS_DIR=${LOCAL_INSTALL_DIR}/lib/cmake/geos -DGeographicLib_DIR=${LOCAL_INSTALL_DIR}/lib/cmake/GeographicLib -DSQLITE3_LIBRARY=${LOCAL_INSTALL_DIR}/lib/libsqlite3.a) - set(PATCH_NAME_ENDING _wasm) - set(OGR_ENABLE_DRIVER_OPENFILEGDB OFF) +set(CMAKE_GDAL_FLAGS) +set(PATCH_NAME_ENDING) + +if(EMSCRIPTEN) + set(CMAKE_FLAGS_POINTER_SIZE -DCMAKE_SIZEOF_VOID_P=4 -DCMAKE_SIZEOF_VOIDP=4) + set(CMAKE_PROJ_FLAGS -DCMAKE_MODULE_PATH=${LOCAL_INSTALL_DIR}/lib/cmake -DSQLITE3_INCLUDE_DIR=${LOCAL_INSTALL_DIR}/include -DSQLITE3_LIBRARY=${LOCAL_INSTALL_DIR}/lib/libsqlite3.a) + set(CMAKE_GDAL_FLAGS -DACCEPT_MISSING_LINUX_FS_HEADER=ON -DSIZEOF_INT=4 -DSIZEOF_UNSIGNED_LONG=4 -DSIZEOF_OFF_T=4 -DGEOS_DIR=${LOCAL_INSTALL_DIR}/lib/cmake/geos -DGeographicLib_DIR=${LOCAL_INSTALL_DIR}/lib/cmake/GeographicLib -DSQLITE3_LIBRARY=${LOCAL_INSTALL_DIR}/lib/libsqlite3.a) + set(PATCH_NAME_ENDING _wasm) + set(OGR_ENABLE_DRIVER_OPENFILEGDB OFF) +endif() + +if(ANDROID) + set(CMAKE_PROJ_FLAGS -DCMAKE_MODULE_PATH=${LOCAL_INSTALL_DIR}/lib/cmake -DSQLITE3_INCLUDE_DIR=${LOCAL_INSTALL_DIR}/include -DSQLITE3_LIBRARY=${LOCAL_INSTALL_DIR}/lib/libsqlite3.a) endif() # ZLIB -ExternalProject_Add( - ZLIB - URL ${CMAKE_CURRENT_SOURCE_DIR}/vendor/zlib1213.zip - CONFIGURE_HANDLED_BY_BUILD TRUE - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX:PATH=${LOCAL_INSTALL_DIR} - -DCMAKE_PREFIX_PATH=${LOCAL_INSTALL_DIR} - -DCMAKE_MODULE_PATH=${LOCAL_INSTALL_DIR}/lib/cmake - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_PACKED} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DBUILD_SHARED_LIBS=OFF - ${CMAKE_FLAGS_POINTER_SIZE} - # vcpkg options - -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' - -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' - -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' - -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' -) +if(ANDROID) + # Explicitly set the zlib library path + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") + set(NDK_HOST_TAG "linux") + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(NDK_HOST_TAG "darwin") + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(NDK_HOST_TAG "windows") + else() + message(FATAL_ERROR "Unsupported host system: ${CMAKE_HOST_SYSTEM_NAME}") + endif() + + # Determine processor architecture + if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64") + set(NDK_HOST_ARCH "x86_64") + else() + message(FATAL_ERROR "Unsupported host architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}") + endif() + + set(ZLIB_LIBRARY ${ANDROID_NDK}/toolchains/llvm/prebuilt/${NDK_HOST_TAG}-${NDK_HOST_ARCH}/sysroot/usr/lib/${CMAKE_ANDROID_ARCH_ABI}/libz.a) + set(ZLIB_INCLUDE_DIR ${ANDROID_NDK}/toolchains/llvm/prebuilt/${NDK_HOST_TAG}-${NDK_HOST_ARCH}/sysroot/usr/include) + + # Find the library + find_library(ZLIB_LIBRARIES z PATHS ${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android NO_DEFAULT_PATH) +else() + ExternalProject_Add( + ZLIB + URL ${CMAKE_CURRENT_SOURCE_DIR}/vendor/zlib1213.zip + CONFIGURE_HANDLED_BY_BUILD TRUE + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX:PATH=${LOCAL_INSTALL_DIR} + -DCMAKE_PREFIX_PATH=${LOCAL_INSTALL_DIR} + -DCMAKE_MODULE_PATH=${LOCAL_INSTALL_DIR}/lib/cmake + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_PACKED} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DBUILD_SHARED_LIBS=OFF + ${CMAKE_FLAGS_POINTER_SIZE} + + # vcpkg options + -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' + -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' + -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' + -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' + ) +endif() # Use the system sqlite binary on Emscripten, iOS and Android -if (EMSCRIPTEN OR IOS OR ANDROID) - find_program(EXE_SQLITE3 sqlite3) +if(EMSCRIPTEN OR IOS OR ANDROID) + find_program(EXE_SQLITE3 sqlite3) +endif() + +if(NOT ANDROID) + set(GDAL_DEPENDENCIES ${GDAL_DEPENDENCIES} ZLIB) endif() -set(GDAL_DEPENDENCIES ${GDAL_DEPENDENCIES} ZLIB) # SQLite3 ExternalProject_Add( SQLITE3 - DEPENDS ZLIB + $<$>:DEPENDS ZLIB> URL ${CMAKE_CURRENT_SOURCE_DIR}/vendor/sqlite3 CONFIGURE_HANDLED_BY_BUILD TRUE CMAKE_ARGS @@ -75,6 +113,7 @@ ExternalProject_Add( -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_PACKED} -DCMAKE_POSITION_INDEPENDENT_CODE=ON ${CMAKE_FLAGS_POINTER_SIZE} + # vcpkg options -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' @@ -84,45 +123,48 @@ ExternalProject_Add( set(GDAL_DEPENDENCIES ${GDAL_DEPENDENCIES} SQLITE3) if(SPATIAL_USE_NETWORK) -# CURL -ExternalProject_Add( - CURL - DEPENDS ZLIB - URL ${CMAKE_CURRENT_SOURCE_DIR}/vendor/curl-7.87.0.zip - CONFIGURE_HANDLED_BY_BUILD TRUE - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX:PATH=${LOCAL_INSTALL_DIR} - -DCMAKE_PREFIX_PATH=${LOCAL_INSTALL_DIR} - -DCMAKE_DEBUG_POSTFIX=${} # Do not append "d" to the library name when building in debug mode - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_PACKED} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - # vcpkg options - -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' - -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' - -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' - -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' - -DBUILD_SHARED_LIBS=OFF - -DHTTP_ONLY=ON - # Disable some defaults for now - -DCURL_USE_LIBSSH2=OFF - -DCURL_USE_LIBPSL=OFF - -DCURL_USE_LIBSSH=OFF - -DOPENSSL_USE_STATIC_LIBS=ON # Propagate to FindOpenSSL.cmake - -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -) -set(GDAL_DEPENDENCIES ${GDAL_DEPENDENCIES} CURL) -endif() + # CURL + ExternalProject_Add( + CURL + DEPENDS ZLIB + URL ${CMAKE_CURRENT_SOURCE_DIR}/vendor/curl-7.87.0.zip + CONFIGURE_HANDLED_BY_BUILD TRUE + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX:PATH=${LOCAL_INSTALL_DIR} + -DCMAKE_PREFIX_PATH=${LOCAL_INSTALL_DIR} + -DCMAKE_DEBUG_POSTFIX=${} # Do not append "d" to the library name when building in debug mode + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_PACKED} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + # vcpkg options + -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' + -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' + -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' + -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' + -DBUILD_SHARED_LIBS=OFF + -DHTTP_ONLY=ON + + # Disable some defaults for now + -DCURL_USE_LIBSSH2=OFF + -DCURL_USE_LIBPSL=OFF + -DCURL_USE_LIBSSH=OFF + -DOPENSSL_USE_STATIC_LIBS=ON # Propagate to FindOpenSSL.cmake + -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} + ) + set(GDAL_DEPENDENCIES ${GDAL_DEPENDENCIES} CURL) +endif() # PROJ ExternalProject_Add( PROJ - DEPENDS SQLITE3 ZLIB + $<$>:DEPENDS ZLIB> + DEPENDS SQLITE3 URL ${CMAKE_CURRENT_SOURCE_DIR}/vendor/proj-9.1.1.zip CONFIGURE_HANDLED_BY_BUILD TRUE PATCH_COMMAND patch -p1 < "${CMAKE_CURRENT_LIST_DIR}/patches/proj${PATCH_NAME_ENDING}.patch" CMAKE_ARGS + # CMake options -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_PACKED} -DCMAKE_POSITION_INDEPENDENT_CODE=ON @@ -131,11 +173,13 @@ ExternalProject_Add( -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_PROJ_FLAGS} ${CMAKE_FLAGS_POINTER_SIZE} + # vcpkg options -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' + # PROJ options -DBUILD_SHARED_LIBS=OFF -DBUILD_APPS=OFF @@ -151,7 +195,8 @@ ExternalProject_Add( URL ${CMAKE_CURRENT_SOURCE_DIR}/vendor/expat-2.5.0.tar.bz2 CONFIGURE_HANDLED_BY_BUILD TRUE PATCH_COMMAND patch -p1 < "${CMAKE_CURRENT_LIST_DIR}/patches/expat${PATCH_NAME_ENDING}.patch" - CMAKE_ARGS + CMAKE_ARGS + # CMake options -DCMAKE_INSTALL_PREFIX:PATH=${LOCAL_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${LOCAL_INSTALL_DIR} @@ -159,11 +204,13 @@ ExternalProject_Add( -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_PACKED} -DCMAKE_POSITION_INDEPENDENT_CODE=ON ${CMAKE_FLAGS_POINTER_SIZE} + # vcpkg options -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' + # EXPAT options -DEXPAT_SHARED_LIBS=OFF -DEXPAT_BUILD_TESTS=OFF @@ -173,13 +220,13 @@ ExternalProject_Add( ) set(GDAL_DEPENDENCIES ${GDAL_DEPENDENCIES} EXPAT) - # GEOS ExternalProject_Add( GEOS URL ${CMAKE_CURRENT_SOURCE_DIR}/vendor/geos-3.13.0.tar.bz2 CONFIGURE_HANDLED_BY_BUILD TRUE - CMAKE_ARGS + CMAKE_ARGS + # CMake options -DCMAKE_INSTALL_PREFIX:PATH=${LOCAL_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${LOCAL_INSTALL_DIR} @@ -187,11 +234,13 @@ ExternalProject_Add( -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_PACKED} -DCMAKE_POSITION_INDEPENDENT_CODE=ON ${CMAKE_FLAGS_POINTER_SIZE} + # vcpkg options -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' + # GEOS options -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF @@ -214,11 +263,13 @@ ExternalProject_Add( -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_PACKED} -DCMAKE_POSITION_INDEPENDENT_CODE=ON ${CMAKE_FLAGS_POINTER_SIZE} + # vcpkg options -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' + # GeographicLib options -DBUILD_SHARED_LIBS=OFF -DGEOGRAPHICLIB_DATA=${LOCAL_INSTALL_DIR}/share/GeographicLib @@ -233,6 +284,7 @@ ExternalProject_Add( CONFIGURE_HANDLED_BY_BUILD TRUE PATCH_COMMAND patch -p1 -i "${CMAKE_CURRENT_LIST_DIR}/patches/remove_filehandler${PATCH_NAME_ENDING}.patch" && patch -p1 -i "${CMAKE_CURRENT_LIST_DIR}/patches/msyspatch${PATCH_NAME_ENDING}.patch" CMAKE_ARGS + # CMake options -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${LOCAL_INSTALL_DIR} @@ -242,19 +294,22 @@ ExternalProject_Add( -DCMAKE_MODULE_PATH=${LOCAL_INSTALL_DIR}/lib/cmake -DCMAKE_FIND_ROOT_PATH=${LOCAL_INSTALL_DIR} ${CMAKE_FLAGS_POINTER_SIZE} + # vcpkg options -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}' -DVCPKG_INSTALLED_DIR='${VCPKG_INSTALLED_DIR}' -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' + # GDAL Options -DGDAL_OBJECT_LIBRARIES_POSITION_INDEPENDENT_CODE=ON # this is needed for GDAL to build with -fPIC -DBUILD_TESTING=OFF -DBUILD_APPS=OFF + # Build static library -DBUILD_SHARED_LIBS=OFF ${CMAKE_GDAL_FLAGS} - + # Arrow -DGDAL_USE_ARROW=OFF -DARROW_USE_STATIC_LIBRARIES=OFF @@ -271,7 +326,7 @@ ExternalProject_Add( -DGDAL_USE_OPENSSL=${SPATIAL_USE_NETWORK} -DOPENSSL_USE_STATIC_LIBS=ON # Propagate to FindOpenSSL.cmake -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} - + # This is not true, but a bug in gdal's cmake files -DACCEPT_MISSING_SQLITE3_RTREE:BOOL=ON -DACCEPT_MISSING_SQLITE3_MUTEX_ALLOC:BOOL=ON @@ -280,6 +335,9 @@ ExternalProject_Add( -DGDAL_BUILD_OPTIONAL_DRIVERS=OFF -DOGR_BUILD_OPTIONAL_DRIVERS=OFF + # Needed to build on Android + $<$:-DBUILD_WITHOUT_64BIT_OFFSET=ON> + # Special issues -DCMAKE_DISABLE_FIND_PACKAGE_Arrow=ON -DCMAKE_DISABLE_FIND_PACKAGE_HDF5=ON @@ -344,6 +402,5 @@ ExternalProject_Add( -DBUILD_PYTHON_BINDINGS=OFF ) - # Ouch! Remember that the order of these libraries is important! (reverse order of dependencies) -#target_link_libraries(dependencies INTERFACE gdal geos_c geos proj expat memvfs sqlite3 zlib) +# target_link_libraries(dependencies INTERFACE gdal geos_c geos proj expat memvfs sqlite3 zlib)