-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make build and install dirs proper CMake package, fix C++ header…
- Loading branch information
Showing
8 changed files
with
244 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,12 @@ | |
|
||
_coverage/ | ||
build/ | ||
scratch/ | ||
out/ | ||
arrow-hpp | ||
.DS_Store | ||
CMakeUserPresets.json | ||
.vscode | ||
.Rproj.user | ||
.cache | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
|
||
|
||
@PACKAGE_INIT@ | ||
|
||
cmake_minimum_required(VERSION @CMAKE_MINIMUM_REQUIRED_VERSION@) | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/nanoarrow-targets.cmake" REQUIRED) | ||
include("${CMAKE_CURRENT_LIST_DIR}/nanoarrow-config-version.cmake" REQUIRED) | ||
|
||
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}") | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(${CMAKE_FIND_PACKAGE_NAME} CONFIG_MODE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
|
||
message(STATUS "Building using CMake version: ${CMAKE_VERSION}") | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
project(NanoArrowExampleCMakeMinimal LANGUAGES C CXX) | ||
|
||
option(FIND_NANOARROW "Find an existing nanoarrow" ON) | ||
|
||
# When adding nanoarrow's CMake directory to a CMake project that contains a library | ||
# intended for use by others, set NANOARROW_NAMESPACE to rename symbols in the | ||
# nanoarrow library such that they do not collide with other libraries that may also | ||
# link to their own copy of nanoarrow. You may wish to include the namespace only | ||
# on release builds, since the namespace implementation obscures inline help | ||
# available in many text editors. | ||
set(NANOARROW_NAMESPACE "ExampleCmakeMinimal") | ||
|
||
if(FIND_NANOARROW) | ||
# Users should pin to a specific version of nanoarrow if they choose | ||
# to find nanoarrow rather than pinning to a specific version via | ||
# FetchContent. | ||
find_package(nanoarrow REQUIRED) | ||
else() | ||
include(FetchContent) | ||
fetchcontent_declare(nanoarrow_example_cmake_minimal | ||
GIT_REPOSITORY https://github.com/apache/arrow-nanoarrow.git | ||
GIT_TAG main | ||
GIT_SHALLOW TRUE) | ||
fetchcontent_makeavailable(nanoarrow_example_cmake_minimal) | ||
endif() | ||
|
||
add_executable(minimal_cpp_app src/app.cpp) | ||
target_link_libraries(minimal_cpp_app nanoarrow::nanoarrow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!--- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you 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. | ||
--> | ||
|
||
# CMake Comprehensive Examples | ||
|
||
This folder contains a CMake project that showcases the many different | ||
ways in which nanoarrow may be used by other projects. The project | ||
exposes a few options for configuring how nanoarrow is found and | ||
built. It shows how nanoarrow may be fetched from source during the | ||
build via FetchContent as well as how it may be preinstalled on the | ||
system and then found by the consumer. | ||
|
||
To demonstrate the various scenarios, this project comes with a build | ||
script that iterates through the different possibilities. To test this | ||
out, simply run | ||
|
||
```bash | ||
./build.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
|
||
set -exuo pipefail | ||
|
||
# Build nanoarrow statically. | ||
cmake -S ../.. -B scratch/nanoarrow_build_static/ -DCMAKE_INSTALL_PREFIX=scratch/nanoarrow_install_static/ | ||
cmake --build scratch/nanoarrow_build_static/ | ||
cmake --install scratch/nanoarrow_build_static/ | ||
|
||
# Build nanoarrow dynamically. | ||
cmake -S ../.. -B scratch/nanoarrow_build_shared/ -DCMAKE_INSTALL_PREFIX=scratch/nanoarrow_install_shared/ -DBUILD_SHARED_LIBS=ON | ||
cmake --build scratch/nanoarrow_build_shared/ | ||
cmake --install scratch/nanoarrow_build_shared/ | ||
|
||
for nanoarrow_build_type in static shared; do | ||
# Build the project against the built nanoarrow. | ||
cmake -S . -B scratch/build_${nanoarrow_build_type}/ -Dnanoarrow_ROOT=scratch/nanoarrow_build_${nanoarrow_build_type}/ | ||
cmake --build scratch/build_${nanoarrow_build_type}/ | ||
|
||
# Build the project against the installed nanoarrow. | ||
cmake -S . -B scratch/build_against_install_${nanoarrow_build_type}/ -Dnanoarrow_ROOT=scratch/nanoarrow_install_${nanoarrow_build_type}/ | ||
cmake --build scratch/build_against_install_${nanoarrow_build_type}/ | ||
|
||
# Now try using FetchContent to get nanoarrow from remote. | ||
cmake -S . -B scratch/build_against_fetched_${nanoarrow_build_type}/ -DFIND_NANOARROW=OFF | ||
cmake --build scratch/build_against_fetched_${nanoarrow_build_type}/ | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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. | ||
|
||
#include "nanoarrow/nanoarrow.h" | ||
#include "nanoarrow/nanoarrow.hpp" | ||
|
||
int main(int argc, char* argv[]) { | ||
nanoarrow::UniqueSchema schema; | ||
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema.get(), NANOARROW_TYPE_INT32)); | ||
printf("Schema format for int32 is '%s'", schema->format); | ||
return EXIT_SUCCESS; | ||
} |