Skip to content
Closed
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: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ project(libmoq
)

# -- Build options --------------------------------------------------
option(MOQ_BUILD_PACKAGE_EXPORTS "Generate and install the LibMoQ CMake package" ON)
# An embedding project owns its install and the export sets of the source
# dependencies it supplies, so the package defaults to OFF there. Derived here
# because PROJECT_IS_TOP_LEVEL needs CMake 3.21.
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(_MOQ_IS_TOP_LEVEL ON)
else()
set(_MOQ_IS_TOP_LEVEL OFF)
endif()
option(MOQ_BUILD_PACKAGE_EXPORTS "Generate and install the LibMoQ CMake package"
${_MOQ_IS_TOP_LEVEL})
option(MOQ_BUILD_TESTS "Build test suite" ON)
option(MOQ_BUILD_SIM "Build moq-sim" ${MOQ_BUILD_TESTS})
option(MOQ_BUILD_ADAPTER_PICOQUIC "Build picoquic adapter" OFF)
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,12 @@ facade the service still builds, but that transport returns

### CMake component imports

`MOQ_BUILD_PACKAGE_EXPORTS` defaults to ON. An embedding project may explicitly
set `-DMOQ_BUILD_PACKAGE_EXPORTS=OFF` to use source dependencies without native
exports. In-tree targets and ordinary artifact/header installation remain usable;
LibMoQ CMake package config/version/target modules are omitted. Existing pkg-config
`MOQ_BUILD_PACKAGE_EXPORTS` defaults to ON when LibMoQ is the top-level project
and to OFF when it is added as a subdirectory, so an embedding project can supply
source dependencies without native exports. An embedding project that wants the
package sets `-DMOQ_BUILD_PACKAGE_EXPORTS=ON`. In-tree targets and ordinary
artifact/header installation remain usable; LibMoQ CMake package
config/version/target modules are omitted. Existing pkg-config
availability follows its existing dependency rules. With exports ON, injected
source providers own their unique native exports and ordinary consumer setup.

Expand Down
7 changes: 4 additions & 3 deletions docs/cmake-component-exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ export set; foreign dependencies stay in their provider's namespace and sets.
`export(EXPORT ...)` and `install(EXPORT ...)`. It does not reconstruct imported
artifact properties or library identity. CMake 3.20 remains the minimum version.

`MOQ_BUILD_PACKAGE_EXPORTS` is a BOOL option, **ON by default**, including when
LibMoQ is added as a subdirectory. Set it to OFF explicitly for an embedded
project that supplies source dependencies without package exports. OFF retains
`MOQ_BUILD_PACKAGE_EXPORTS` is a BOOL option, **ON by default** when LibMoQ is
the top-level project and OFF when it is added as a subdirectory, where the
embedding project owns the install and the exports of the source dependencies it
supplies. An embedding project that wants the package sets it to ON. OFF retains
the actual in-tree targets, artifact/header installation and existing pkg-config
rules. It generates or installs no LibMoQ CMake config/version/target modules and
registers no private foreign build export. Reusing an ON build tree with OFF also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ project(moq_package_embedding LANGUAGES C CXX)
include(GNUInstallDirs)
# A real source library owned by the embedding project. This is an export-graph
# fixture, not a stand-in for a transport SDK or a backend runtime qualification.
option(MOQ_BUILD_PACKAGE_EXPORTS "Generate LibMoQ package exports" ON)
# MOQ_BUILD_PACKAGE_EXPORTS stays unset unless the driver passes it, so the
# LibMoQ subdirectory default is exercised too.
option(FIXTURE_PROVIDER_EXPORTS "Register the fixture provider's own exports" ON)
option(FIXTURE_SERVICE "Build the embedding service component" ON)
add_library(fixture_provider_runtime runtime.c)
Expand Down
8 changes: 8 additions & 0 deletions tests/cmake/manual_component_exports/embedding/check.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ command(packaging-off-again-build PASS "${CMAKE_COMMAND}" --build "${build}" --p
embedding_run("${build}" embedding.cmake packaging-off-again)
embedding_install("${build}" packaging-off-again OFF)

# Left unset, an embedded LibMoQ defaults to no package exports, so a parent
# with an unexported source provider still configures.
command(unexported-provider-default PASS "${CMAKE_COMMAND}" ${context}
-S "${fixture}/embedding" -B "${WORK}/unexported-provider-default" -G Ninja
-DCMAKE_BUILD_TYPE=Debug "-DMOQ_SOURCE=${MOQ_SOURCE}" "-DBUILD_SHARED_LIBS=${MOQ_SHARED}"
-DFIXTURE_PROVIDER_EXPORTS=OFF)
embedding_no_package("${WORK}/unexported-provider-default")

# The explicit ON contract must not silently hide an unexported source edge.
command(unexported-provider "not in any export set" "${CMAKE_COMMAND}" ${context}
-S "${fixture}/embedding" -B "${WORK}/unexported-provider" -G Ninja -DCMAKE_BUILD_TYPE=Debug
Expand Down
5 changes: 5 additions & 0 deletions tests/cmake/manual_component_exports/producer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ if(MOQ_MODE STREQUAL "pico-wt")
set(MOQ_BUILD_ADAPTER_PICO_WT ON CACHE BOOL "Real WT adapter" FORCE)
set(MOQ_BUILD_PICO_WT_MANAGED ON CACHE BOOL "Real WT managed facade" FORCE)
endif()
# These rows qualify the package, which an embedded LibMoQ leaves OFF by
# default; the embedding row passes its own choice through instead.
if(NOT MOQ_MODE STREQUAL "embedding")
set(MOQ_BUILD_PACKAGE_EXPORTS ON CACHE BOOL "Qualify native packages" FORCE)
endif()
add_subdirectory("${MOQ_SOURCE}" libmoq)
set(components "")
set(targets moq::core moq::msf)
Expand Down
Loading