Skip to content

Set RERUN_ARROW_LINK_SHARED_DEFAULT based on found Arrow build #9550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2025

Conversation

BillyONeal
Copy link
Contributor

@BillyONeal BillyONeal commented Apr 8, 2025

Arrow provides an ArrowOptions.cmake in its package includes, with the following:

### Build static libraries
set(ARROW_BUILD_STATIC "0")
### Build shared libraries
set(ARROW_BUILD_SHARED "1")

(It is generated by https://github.com/apache/arrow/blob/d8d7e79b60092f643f16b045eaff0b4359e32bae/cpp/cmake_modules/DefineOptions.cmake#L745 )

This is why vcpkg suggests handling Arrow by listening to that value:

The package arrow provides CMake targets:

    find_package(Arrow CONFIG REQUIRED)
    target_link_libraries(main PRIVATE "$<IF:$<BOOL:${ARROW_BUILD_STATIC}>,Arrow::arrow_static,Arrow::arrow_shared>")

This PR tests ARROW_BUILD_SHARED just in case older versions of Arrow I can't test with didn't define these variables. In that case, ARROW_BUILD_SHARED is undefined, so if (ARROW_BUILD_SHARED) will choose the else branch, and give the same behavior as before the edit (OFF).

…ly built with.

Arrow provides a ArrowOptions.cmake its package includes, with the following:

```cmake
### Build static libraries
set(ARROW_BUILD_STATIC "0")
### Build shared libraries
set(ARROW_BUILD_SHARED "1")
```

(It is generated by https://github.com/apache/arrow/blob/d8d7e79b60092f643f16b045eaff0b4359e32bae/cpp/cmake_modules/DefineOptions.cmake#L745 )

This is why vcpkg suggests handling Arrow by listening to that value:

```console
The package arrow provides CMake targets:

    find_package(Arrow CONFIG REQUIRED)
    target_link_libraries(main PRIVATE "$<IF:$<BOOL:${ARROW_BUILD_STATIC}>,Arrow::arrow_static,Arrow::arrow_shared>")
```

This PR tests ARROW_BUILD_SHARED just in case older versions of Arrow I can't test with didn't define these variables; in that case `if (ARROW_BUILD_SHARED)` will choose the else branch and give the same behavior as before the edit (OFF).
BillyONeal added a commit to BillyONeal/vcpkg that referenced this pull request Apr 8, 2025
Incorporates rerun-io/rerun#9548 and rerun-io/rerun#9550

After these changes I tested that it built OK with https://github.com/rerun-io/rerun/blob/main/examples/cpp/minimal/main.cpp :

```
C:\Dev\test>dir
 Volume in drive C is OS
 Volume Serial Number is 9288-8F79

 Directory of C:\Dev\test

04/08/2025  10:42 AM    <DIR>          .
04/08/2025  10:40 AM    <DIR>          ..
04/08/2025  10:38 AM               180 CMakeLists.txt
04/08/2025  10:37 AM               756 main.cpp
               2 File(s)            936 bytes
               2 Dir(s)  4,813,367,603,200 bytes free

C:\Dev\test>type CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(HelloWorld)

add_executable(main main.cpp)

find_package(rerun_sdk CONFIG REQUIRED)
target_link_libraries(main PRIVATE rerun_sdk)

C:\Dev\test>type main.cpp
#include <rerun.hpp>
#include <rerun/demo_utils.hpp>

using rerun::demo::grid3d;

int main() {
    // Create a new `RecordingStream` which sends data over gRPC to the viewer process.
    const auto rec = rerun::RecordingStream("rerun_example_cpp");
    // Try to spawn a new viewer instance.
    rec.spawn().exit_on_failure();

    // Create some data using the `grid` utility function.
    std::vector<rerun::Position3D> points = grid3d<rerun::Position3D, float>(-10.f, 10.f, 10);
    std::vector<rerun::Color> colors = grid3d<rerun::Color, uint8_t>(0, 255, 10);

    // Log the "my_points" entity with our data, using the `Points3D` archetype.
    rec.log("my_points", rerun::Points3D(points).with_colors(colors).with_radii({0.5f}));
}

```
Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Thanks for the PR

@BillyONeal BillyONeal changed the title Set RERUN_ARROW_LINK_SHARED_DEFAULT according to what Arrow as actually built with. Set RERUN_ARROW_LINK_SHARED_DEFAULT according to what Arrow was actually built with. Apr 9, 2025
@emilk emilk changed the title Set RERUN_ARROW_LINK_SHARED_DEFAULT according to what Arrow was actually built with. Set RERUN_ARROW_LINK_SHARED_DEFAULT based on found Arrow build Apr 10, 2025
@emilk
Copy link
Member

emilk commented Apr 10, 2025

@emilk emilk merged commit 81625d9 into rerun-io:main Apr 10, 2025
32 of 36 checks passed
@BillyONeal BillyONeal deleted the use-arrow-linkage branch April 10, 2025 16:45
@emilk emilk mentioned this pull request Apr 11, 2025
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants