Skip to content

Commit

Permalink
Move C and C++ examples to examples/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jul 12, 2023
1 parent 1e19b7b commit 8a60fd1
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 92 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.16)

project(rerun_cpp_proj LANGUAGES CXX)

add_subdirectory(rerun_cpp) # The Rerun C++ SDK library
add_subdirectory(examples/cpp/minimal)
7 changes: 0 additions & 7 deletions crates/rerun_c/run_examples.sh

This file was deleted.

1 change: 1 addition & 0 deletions examples/c/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Rerun C SDK is in its infancy, and not ready for production.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CC = gcc
CFLAGS = --std=c99 -O2 -g -DNDEBUG
CFLAGS += -Wall -Wextra -Wpedantic -Wcast-align -Wcast-qual -Wformat=2 -Wmissing-include-dirs -Wnull-dereference -Woverloaded-virtual -Wpointer-arith -Wshadow -Wswitch-enum -Wvla -Wno-sign-compare -Wconversion -Wunused -Wold-style-cast -Wno-missing-braces
CFLAGS += -I ../src # Make sure rerun.h is found
CFLAGS += -I ../../../crates/rerun_c/src # Make sure rerun.h is found
LDLIBS =

OBJECTS = main.o
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions examples/cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Rerun C++ SDK is in its infancy, and not ready for production.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ else()
target_compile_options(rerun_example PRIVATE -Wall -Wextra -Wpedantic -Wcast-align -Wcast-qual -Wformat=2 -Wmissing-include-dirs -Wnull-dereference -Woverloaded-virtual -Wpointer-arith -Wshadow -Wswitch-enum -Wvla -Wno-sign-compare -Wconversion -Wunused -Wold-style-cast -Wno-missing-braces)
endif()

include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/../src) # For rerun.hpp (Rerun C++ SDK)
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/../../../rerun_cpp/src) # For rerun.hpp (Rerun C++ SDK)

target_link_libraries(rerun_example PRIVATE loguru::loguru rerun_sdk)
5 changes: 5 additions & 0 deletions examples/cpp/minimal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Example of using the Rerun C SDK

```
make run
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path"
cd "$script_path/../../.."
set -x

mkdir -p build
Expand All @@ -11,5 +11,4 @@ pushd build
make -j8 # VERBOSE=1
popd

./build/example/rerun_example

./build/examples/cpp/minimal/rerun_example
File renamed without changes.
71 changes: 68 additions & 3 deletions rerun_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,71 @@
cmake_minimum_required(VERSION 3.16)

project(rerun_cpp_proj LANGUAGES CXX)
# NOTE: CMake docs strongly discourages using GLOB, and instead suggests
# manually listing all the files, like it's 1972.
# However, that won't work for use since we auto-generate the source tree.
# See https://cmake.org/cmake/help/latest/command/file.html#glob
file(GLOB_RECURSE rerun_sdk_SRC CONFIGURE_DEPENDS
"*.hpp"
"*.cpp"
)

add_subdirectory(src) # The Rerun C++ SDK library
add_subdirectory(example)
add_library(rerun_sdk ${rerun_sdk_SRC})

# ------------------------------------------------------------------------------

# For rerun.h (Rerun C SDK):
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/../crates/rerun_c/src)

# Make sure the compiler can find include files for rerun
# when other libraries or executables link to rerun:
target_include_directories(rerun_sdk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

# ------------------------------------------------------------------------------
# Loguru logging library (https://github.com/emilk/loguru):
set(CMAKE_DL_LIBS "dl") # Required by Loguru for backtraces

# Loguru, see https://github.com/emilk/loguru/blob/master/loguru_cmake_example/CMakeLists.txt
include(FetchContent)
FetchContent_Declare(LoguruGitRepo
GIT_REPOSITORY "https://github.com/emilk/loguru" # can be a filesystem path
GIT_TAG "master"
)

# set any loguru compile-time flags before calling MakeAvailable()
set(LOGURU_STACKTRACES 1)
FetchContent_MakeAvailable(LoguruGitRepo) # defines target 'loguru::loguru'

target_link_libraries(rerun_sdk PRIVATE loguru::loguru)

# ------------------------------------------------------------------------------
execute_process(COMMAND cargo build -p re_types) # Generates most of the C++ source files
execute_process(COMMAND cargo build -p rerun_c) # We link against this, so must be up-to-date

# ------------------------------------------------------------------------------
if(APPLE)
target_link_libraries(rerun_sdk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../target/debug/librerun_c.a)
target_link_libraries(rerun_sdk PRIVATE "-framework CoreFoundation" "-framework IOKit")
endif()

if(LINUX)
target_link_libraries(rerun_sdk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../target/debug/librerun_c.a)
target_link_libraries(rerun_sdk PRIVATE "-lm")
endif()

# -----------------------------------------------------------------------------
# Arrow:
option(ARROW_LINK_SHARED "Link to the Arrow shared library" ON)

find_package(Arrow REQUIRED)

# Arrow requires a C++17 compliant compiler
set(CMAKE_CXX_STANDARD_REQUIRED ON)

message(STATUS "Arrow version: ${ARROW_VERSION}")
message(STATUS "Arrow SO version: ${ARROW_FULL_SO_VERSION}")

if(ARROW_LINK_SHARED)
target_link_libraries(rerun_sdk PRIVATE Arrow::arrow_shared)
else()
target_link_libraries(rerun_sdk PRIVATE Arrow::arrow_static)
endif()
2 changes: 1 addition & 1 deletion rerun_cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is not yet ready to be used.
Run `scripts/setup.sh`.

## Test it
rerun_cpp/example/build_and_run.sh
`examples/cpp/minimal/build_and_run.sh``

# To do:
* CI
Expand Down
5 changes: 0 additions & 5 deletions rerun_cpp/example/README.md

This file was deleted.

71 changes: 0 additions & 71 deletions rerun_cpp/src/CMakeLists.txt

This file was deleted.

0 comments on commit 8a60fd1

Please sign in to comment.