Skip to content

Bundle C++ to SDK to artifact that can be used with CMake's fetch_content#3875

Merged
Wumpf merged 29 commits intomainfrom
andreas/cpp/fetch-content-compat
Oct 17, 2023
Merged

Bundle C++ to SDK to artifact that can be used with CMake's fetch_content#3875
Wumpf merged 29 commits intomainfrom
andreas/cpp/fetch-content-compat

Conversation

@Wumpf
Copy link
Copy Markdown
Member

@Wumpf Wumpf commented Oct 16, 2023

What

Change CMakeLists.txt in rerun_cpp to work standalone with add_directory.
When used in this fashion it expects the RERUN_C_LIB variable to be set. The default for it points to a local lib folder with appropriately named libs.
This in turn gives rise to a very trivial bundling strategy:

  • copy src
  • copy CMakeLists.txt
  • copy libs

This is done in the new build_and_upload_rerun_cpp script which on top of the above also takes care of testing the resulting artifact by running the now also compatible minimal example outside of the repo.

Another smaller necessary change is that the rerun.h C header is now copied into the rerun_cpp sdk with a patched version number in the comment. This is primarily so to keep the above process super simple and shave of an additional include directory.

Draft until PR ci confirmed to be working.
(PR checks only the linux artifact, main ci checks the full artifact and puts it on the Development Release notes)

With this change, the minimal possible cmake script for a project using Rerun is:

project(hello_rerun)

include(FetchContent)
FetchContent_Declare(rerun_sdk URL https://build.rerun.io/commit/f4e5ad6/rerun_cpp.zip DOWNLOAD_EXTRACT_TIMESTAMP YES)
FetchContent_MakeAvailable(rerun_sdk)

add_executable(hello_rerun main.cpp)
set_property(TARGET hello_rerun PROPERTY CXX_STANDARD 20) # Rerun requires C++17, but you can of course use an ever newer version.
target_link_libraries(hello_rerun PRIVATE rerun_sdk)

⚠️ this STILL requires libarrow to be installed somewhere where cmake can find it ⚠️

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested demo.rerun.io (if applicable)
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@Wumpf Wumpf added sdk-cpp C/C++ API specific exclude from changelog PRs with this won't show up in CHANGELOG.md labels Oct 16, 2023
@Wumpf Wumpf marked this pull request as ready for review October 16, 2023 20:14
@teh-cmc teh-cmc self-requested a review October 17, 2023 06:28
Copy link
Copy Markdown
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.

This is awesome!

set(RERUN_REPOSITORY YES)

# Set version number.
# Read it from the Rust toml with a regex so we don't have another place to maintain!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Copy link
Copy Markdown
Contributor

@teh-cmc teh-cmc left a comment

Choose a reason for hiding this comment

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

Looks fantastic.

I just wish we did the same for arrow-cpp now!

@Wumpf
Copy link
Copy Markdown
Member Author

Wumpf commented Oct 17, 2023

I just wish we did the same for arrow-cpp now!

my gut feeling tells me this will be way harder, but I haven't tried!

@Wumpf Wumpf merged commit 30dc8be into main Oct 17, 2023
@Wumpf Wumpf deleted the andreas/cpp/fetch-content-compat branch October 17, 2023 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exclude from changelog PRs with this won't show up in CHANGELOG.md sdk-cpp C/C++ API specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide CMake setup for using the C++ sdk with pre-built rerun_c

3 participants