@@ -6,32 +6,28 @@ set(TARGET_NAME spatial)
66set (EXTENSION_NAME ${TARGET_NAME} _extension)
77set (CMAKE_CXX_STANDARD 11)
88
9+ if (EMSCRIPTEN)
10+ # _LINKED_LIBS influences only Wasm compilation
11+ # it's unclear why this is needed, but somehow the global symbol pj_release from PROJ is not properly exported otherwise
12+ # this solves by basically re-linking (at the moment the Wasm binary is actually produced)
13+ set (DUCKDB_EXTENSION_SPATIAL_LINKED_LIBS "../../vcpkg_installed/wasm32-emscripten/lib/lib*.a" )
14+ endif ()
15+
916project (${TARGET_NAME} )
1017
1118add_definitions (-DDUCKDB_MAJOR_VERSION=${DUCKDB_MAJOR_VERSION} )
1219add_definitions (-DDUCKDB_MINOR_VERSION=${DUCKDB_MINOR_VERSION} )
1320add_definitions (-DDUCKDB_PATCH_VERSION=${DUCKDB_PATCH_VERSION} )
21+ add_definitions (-DDUCKDB_SPATIAL_EXTENSION=1 )
1422
1523# Options
1624
1725# Enable network functionality (OpenSSL and GDAL's CURL based fs/drivers)
1826option (SPATIAL_USE_NETWORK "Enable network functionality" ON )
1927
20- if (VCPKG_TARGET_IS_EMSCRIPTEN)
21- set (CMAKE_POSITION_INDEPENDENT_CODE ON )
22- set (EMSCRIPTEN ON )
23- endif ()
24-
25-
2628# Enable GEOS support
2729option (SPATIAL_USE_GEOS "Enable GEOS support" ON )
2830
29- if (EMSCRIPTEN
30- OR IOS
31- OR ANDROID )
32- set (SPATIAL_USE_NETWORK OFF )
33- endif ()
34-
3531add_subdirectory (src/spatial )
3632add_subdirectory (src/sgl )
3733include_directories (src )
@@ -46,70 +42,19 @@ add_subdirectory(src/third_party/shapelib)
4642
4743add_library (${EXTENSION_NAME} STATIC ${EXTENSION_SOURCES} )
4844
49- # Build dependencies TODO: in the future we should allow users to dynamically
50- # link to their own dependencies if they are building locally. If they have a
51- # local (compatible) GDAL installation, we should use that instead of building
52- # our own. (unless a static build is requested)
53-
54- if (NOT EXISTS ${CMAKE_BINARY_DIR} /deps)
55- execute_process (
56- # Generate project
57- COMMAND
58- ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
59- -DENABLE_SANITIZER=${ENABLE_SANITIZER}
60- -DCMAKE_CXX_COMPILER='${CMAKE_CXX_COMPILER}'
61- -DCMAKE_C_COMPILER='${CMAKE_C_COMPILER}' -DDUCKDB_ENABLE_DEPRECATED_API=1
62- -DWASM_LOADABLE_EXTENSIONS=1 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
63- -DOSX_BUILD_ARCH=${OSX_BUILD_ARCH}
64- -DSPATIAL_USE_NETWORK=${SPATIAL_USE_NETWORK}
65- -DSPATIAL_USE_GEOS=${SPATIAL_USE_GEOS}
66- -DOPENSSL_ROOT_DIR=$ENV{OPENSSL_ROOT_DIR}
67- -DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}'
68- -DVCPKG_INSTALLED_DIR='${CMAKE_BINARY_DIR}/vcpkg_installed'
69- -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'
70- -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}'
71- -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE='${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}' -S
72- ${CMAKE_CURRENT_SOURCE_DIR} /deps -B ${CMAKE_BINARY_DIR} /deps
73- RESULT_VARIABLE DEPENDENCIES_GENERATE_RESULT )
74- if (NOT DEPENDENCIES_GENERATE_RESULT EQUAL 0)
75- message (FATAL_ERROR "Could not generate dependencies project" )
76- endif ()
77-
78- execute_process (
79- # Build project
80- COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} /deps --config
81- ${CMAKE_BUILD_TYPE} RESULT_VARIABLE DEPENDENCIES_BUILD_RESULT )
82- if (NOT DEPENDENCIES_BUILD_RESULT EQUAL 0)
83- message (FATAL_ERROR "Could not build dependencies project" )
84- endif ()
85- endif ()
86-
8745# annoyingly for expat on windows
8846set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} MD.lib)
89-
90- # Add dependencies
91- list (APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_BINARY_DIR} /deps/local/" )
92- list (APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR} /deps/local/" )
93-
94- message (STATUS "Find libraries path: '${CMAKE_PREFIX_PATH} '" )
95-
9647set (ZLIB_USE_STATIC_LIBS ON )
9748set (OPENSSL_USE_STATIC_LIBS ON )
98-
99- if (EMSCRIPTEN)
100- set (OPENSSL_USE_STATIC_LIBS OFF )
101- endif ()
102-
103- find_library (SQLITE3_MEMVFS memvfs )
10449find_package (ZLIB REQUIRED )
105- find_package (PROJ REQUIRED )
106- find_package (SQLite3 REQUIRED )
107- find_package (GDAL REQUIRED )
50+ find_package (PROJ CONFIG REQUIRED )
51+ find_package (GDAL CONFIG REQUIRED )
10852find_package (EXPAT REQUIRED )
53+ find_package (unofficial-sqlite3 CONFIG REQUIRED )
10954
11055# Important: The link order matters, its the reverse order of dependency
111- set (EXTENSION_DEPENDENCIES GDAL::GDAL PROJ::proj EXPAT::EXPAT SQLite::SQLite3
112- ZLIB::ZLIB ${SQLITE3_MEMVFS} )
56+ set (EXTENSION_DEPENDENCIES GDAL::GDAL PROJ::proj EXPAT::EXPAT unofficial::sqlite3::sqlite3
57+ ZLIB::ZLIB)
11358
11459if (SPATIAL_USE_GEOS)
11560 message (STATUS "Building with GEOS functionality" )
@@ -118,6 +63,11 @@ if(SPATIAL_USE_GEOS)
11863 add_definitions (-DSPATIAL_USE_GEOS=1 )
11964endif ()
12065
66+ if (EMSCRIPTEN)
67+ message (STATUS "Building for Emscripten, disabling network functionality" )
68+ set (SPATIAL_USE_NETWORK OFF )
69+ endif ()
70+
12171if (SPATIAL_USE_NETWORK)
12272 message (STATUS "Building with network functionality" )
12373 message (STATUS "OpenSSL root dir hint: '$ENV{OPENSSL_ROOT_DIR} '" )
@@ -140,7 +90,7 @@ if((NOT EMSCRIPTEN) AND (NOT IOS))
14090endif ()
14191
14292# Add dependencies to extension
143- target_link_libraries (${EXTENSION_NAME} PUBLIC ${EXTENSION_DEPENDENCIES} )
93+ target_link_libraries (${EXTENSION_NAME} ${EXTENSION_DEPENDENCIES} )
14494
14595# Build extensions
14696set (PARAMETERS "-warnings" )
0 commit comments