forked from dacort/duckdb-athena-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
83 lines (66 loc) · 2.68 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright 2023 Lance Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Still need to use cmake to link to duckdb via `build_loadable_extension` macro.
#
cmake_minimum_required(VERSION 3.21)
if (POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif ()
project(athena_duckdb VERSION 0.3)
set(EXTENSION_NAME athena)
if (APPLE)
# POLICY CMP0042
set(CMAKE_MACOSX_RPATH 1)
# I think this is automatically handled by the duckdb Makefile/CMakefiles
# SET(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for Mac OS X" FORCE)
endif()
option(OSX_BUILD_AARCH64 "Build aarch64/arm64 binary on OSX." FALSE)
if (OSX_BUILD_AARCH64)
if (NOT APPLE)
error("This only makes sense on OSX")
endif()
set(Rust_CARGO_TARGET "aarch64-apple-darwin")
SET(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build architecture for Mac OS X" FORCE)
else()
SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for Mac OS X" FORCE)
endif()
include(FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.3.2 # Optionally specify a commit hash, version tag or branch here
)
set(BUILD_UNITTESTS FALSE) # Disable unit test build in duckdb
FetchContent_MakeAvailable(Corrosion)
#set(EXTERNAL_EXTENSION_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/duckdb/src/include)
# Now again for aarch64/arm64
# set(Rust_CARGO_TARGET "aarch64-apple-darwin")
# corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml)
set(ALL_SOURCES src/extension.c src/extension.h)
SET(EXTENSION_STATIC_BUILD 1)
set(PARAMETERS "-warnings")
build_loadable_extension(${EXTENSION_NAME} ${PARAMETERS} ${ALL_SOURCES})
set(LIB_NAME ${EXTENSION_NAME}_loadable_extension)
set_target_properties(${LIB_NAME} PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(${LIB_NAME}
"${CMAKE_CURRENT_BINARY_DIR}/libduckdb_athena.a"
duckdb_static
)
if (APPLE)
target_link_libraries(${LIB_NAME}
"-framework CoreFoundation"
"-framework Security")
endif()