Skip to content
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
2 changes: 1 addition & 1 deletion cpp/moq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ endforeach()
# The bindings compile here with the including project's standard and flags; see src/moq.cpp.
# Named moq-cpp so an in-tree build can sit beside libmoq's `moq` target.
add_library(moq-cpp STATIC src/moq.cpp)
add_library(moq-cpp::moq ALIAS moq-cpp)
add_library(moq::cpp ALIAS moq-cpp)
add_dependencies(moq-cpp moq_ffi)
target_compile_features(moq-cpp PUBLIC cxx_std_17)
target_include_directories(moq-cpp PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion cpp/moq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ C++17 bindings for [rs/moq-ffi](../../rs/moq-ffi): the sources `uniffi-bindgen-c

## Layout

- `CMakeLists.txt` builds moq-ffi as a staticlib with cargo, renders the bindings into the build tree, and compiles them as the `moq-cpp::moq` target. Use it with `add_subdirectory`, or install it for `find_package(moq-cpp)` and `moq-cpp.pc`.
- `CMakeLists.txt` builds moq-ffi as a staticlib with cargo, renders the bindings into the build tree, and compiles them as the `moq::cpp` target. Use it with `add_subdirectory`, or install it for `find_package(moq-cpp)` and `moq-cpp.pc`.
- `src/moq.cpp` compiles the generated `moq/ffi/moq.cpp`. It ships as source so it builds with the consumer's standard and flags.
- `cmake/` holds the installed CMake package and pkg-config templates.
- `build.sh` builds the release archive `release-cpp.yml` publishes.
Expand Down
14 changes: 7 additions & 7 deletions cpp/moq/cmake/moq-cpp-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# find_package(moq-cpp): the C++ bindings for moq-ffi as the moq-cpp::moq target. The
# namespace is the package name, so it never collides with libmoq's moq::moq.
# find_package(moq-cpp): the C++ bindings for moq-ffi as the moq::cpp target. Every moq
# package exports into the one moq:: namespace, and the package names keep installs apart.

@PACKAGE_INIT@

if(NOT TARGET moq-cpp::moq)
if(NOT TARGET moq::cpp)
find_package(Threads REQUIRED)

# The prebuilt Rust staticlib, and the system libraries an external linker must add for
# it, baked in for the platform this package was built for.
add_library(moq-cpp::ffi STATIC IMPORTED)
set_target_properties(moq-cpp::ffi PROPERTIES
add_library(moq::ffi STATIC IMPORTED)
set_target_properties(moq::ffi PROPERTIES
IMPORTED_LOCATION "@PACKAGE_CMAKE_INSTALL_LIBDIR@/@MOQ_FFI_LIB_NAME@"
INTERFACE_LINK_LIBRARIES "@MOQ_NATIVE_LIBS@;Threads::Threads"
)
Expand All @@ -19,8 +19,8 @@ if(NOT TARGET moq-cpp::moq)
add_library(moq-cpp STATIC "@PACKAGE_CMAKE_INSTALL_DATADIR@/moq-cpp/moq.cpp")
target_compile_features(moq-cpp PUBLIC cxx_std_17)
target_include_directories(moq-cpp PUBLIC "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
target_link_libraries(moq-cpp PUBLIC moq-cpp::ffi)
add_library(moq-cpp::moq ALIAS moq-cpp)
target_link_libraries(moq-cpp PUBLIC moq::ffi)
add_library(moq::cpp ALIAS moq-cpp)
endif()

check_required_components(moq-cpp)
2 changes: 1 addition & 1 deletion cpp/moq/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ endif()
find_package(moq-cpp REQUIRED)

add_executable(probe probe.cpp)
target_link_libraries(probe PRIVATE moq-cpp::moq)
target_link_libraries(probe PRIVATE moq::cpp)
4 changes: 2 additions & 2 deletions doc/lib/cpp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ No Rust toolchain is needed to consume it.

```cmake ignore
find_package(moq-cpp REQUIRED) # with CMAKE_PREFIX_PATH at the unpacked archive
target_link_libraries(app PRIVATE moq-cpp::moq)
target_link_libraries(app PRIVATE moq::cpp)
```

```bash
Expand All @@ -44,7 +44,7 @@ release runtime (`/MD`), which the Rust library uses in every configuration.
From source, `add_subdirectory(cpp/moq)` in a checkout builds `moq-ffi` with
cargo and renders the bindings with the pinned `uniffi-bindgen-cpp` (see
[`cpp/moq`](https://github.com/moq-dev/moq/tree/main/cpp/moq)), then exposes
the same `moq-cpp::moq` target. The package is `moq-cpp`, so it installs beside
the same `moq::cpp` target. The package is `moq-cpp`, so it installs beside
libmoq's `moq` package without colliding.

## Example
Expand Down
2 changes: 1 addition & 1 deletion test/interop/clients/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ set(CMAKE_CXX_EXTENSIONS OFF)
find_package(moq-cpp REQUIRED)

add_executable(cpp-interop main.cpp)
target_link_libraries(cpp-interop PRIVATE moq-cpp::moq)
target_link_libraries(cpp-interop PRIVATE moq::cpp)
Loading