Skip to content
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

Expose Rerun source/include dir in CMakeLists.txt (RERUN_CPP_SOURCE_DIR) #4313

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/content/reference/cpp-sdk-cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ It provides a minimalistic C interface that encapsulates the shared building blo
By default points to where a pre-built library for the currently active platform
is expected to be found in the Rerun C++ SDK distribution zip.

### `RERUN_CPP_SOURCE_DIR`
Path to the Rerun include and source directory, i.e. the directory that contains `rerun.hpp`.

Note that rerun does not have separate folders for header (\*.hpp) and source (\*.cpp) files,
both are found inside `RERUN_CPP_SOURCE_DIR`.

By default is set to an absolute path that is determined by the location of Rerun's `CMakeLists.txt` itself.
Setting this is rarely needed, but reading it may be useful for build setups that can not rely on
the `rerun_cpp` target or for some reason aren't able to inherit the public target include path
set on `rerun_cpp`.


## Tested compilers

Expand Down
12 changes: 5 additions & 7 deletions rerun_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ cmake_minimum_required(VERSION 3.16...3.27)

message("Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} (${CMAKE_CXX_COMPILER})")

# ------------------------------------------------------------------------------
# Base setup for rerun_sdk C++ library.
set(RERUN_CPP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src" CACHE PATH "Rerun include & source directory")

file(GLOB_RECURSE rerun_sdk_SRC CONFIGURE_DEPENDS
"src/*.hpp"
"src/*.cpp"
"${RERUN_CPP_SOURCE_DIR}/*.hpp"
"${RERUN_CPP_SOURCE_DIR}/*.cpp"
)

add_library(rerun_sdk ${rerun_sdk_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}/src)
target_include_directories(rerun_sdk PUBLIC ${RERUN_CPP_SOURCE_DIR})

# Rerun needs at least C++17.
set_target_properties(rerun_sdk PROPERTIES CXX_STANDARD 17)
Expand All @@ -30,7 +29,7 @@ if(MSVC)
endif()

# Set default warning settings if defined.
if (COMMAND rerun_strict_warning_settings)
if(COMMAND rerun_strict_warning_settings)
message("Building Rerun C++ SDK with strict compilation warnings.")
rerun_strict_warning_settings(rerun_sdk)
endif()
Expand Down Expand Up @@ -106,7 +105,6 @@ endif()

target_link_libraries(rerun_sdk PRIVATE rerun_arrow_target)


# -----------------------------------------------------------------------------
# Add tests if they exist (they are not part of the distribution zip).
# Has direct dpeendency to arrow, so needs to happen last.
Expand Down
Loading