diff --git a/cpp/moq/CMakeLists.txt b/cpp/moq/CMakeLists.txt index 780b3f5b562..ae9209d71dc 100644 --- a/cpp/moq/CMakeLists.txt +++ b/cpp/moq/CMakeLists.txt @@ -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 diff --git a/cpp/moq/README.md b/cpp/moq/README.md index aef1608ff87..28fb95498b9 100644 --- a/cpp/moq/README.md +++ b/cpp/moq/README.md @@ -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. diff --git a/cpp/moq/cmake/moq-cpp-config.cmake.in b/cpp/moq/cmake/moq-cpp-config.cmake.in index 1383fb754f7..d4ed0477fbf 100644 --- a/cpp/moq/cmake/moq-cpp-config.cmake.in +++ b/cpp/moq/cmake/moq-cpp-config.cmake.in @@ -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" ) @@ -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) diff --git a/cpp/moq/test/CMakeLists.txt b/cpp/moq/test/CMakeLists.txt index b76f382000f..c7c7d16e9de 100644 --- a/cpp/moq/test/CMakeLists.txt +++ b/cpp/moq/test/CMakeLists.txt @@ -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) diff --git a/doc/lib/cpp/index.md b/doc/lib/cpp/index.md index 8744eaf81af..3dea12e9c94 100644 --- a/doc/lib/cpp/index.md +++ b/doc/lib/cpp/index.md @@ -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 @@ -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 diff --git a/test/interop/clients/cpp/CMakeLists.txt b/test/interop/clients/cpp/CMakeLists.txt index b1ad0c3d348..894e8caaf95 100644 --- a/test/interop/clients/cpp/CMakeLists.txt +++ b/test/interop/clients/cpp/CMakeLists.txt @@ -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)