Files
logos-cpp-sdk/cpp/CMakeLists.txt
T
Dario LipicarandClaude Opus 5 f3369faca4 feat(generator): async callers can see the error, sync callers can set a deadline (#132)
The two consumer surfaces had complementary holes:

  sync :  T    foo(params…, logos::CallError* err = nullptr)   error yes, timeout NO
  async:  void fooAsync(params…, cb, Timeout = Timeout())      timeout yes, error NO

so an async caller could not tell a failed remote call from a provider that
legitimately returned 0 / "" / false — the exact ambiguity the sync path's
CallError* was added to resolve — and a sync caller could not say how long it
was willing to wait, even though the transport overload the generator already
calls takes both.

Both fixes are additive:

  T    foo(params…, logos::CallError* err = nullptr, Timeout timeout = Timeout());
  void fooAsync(params…, std::function<void(T)> cb, Timeout timeout = Timeout());   // unchanged
  void fooAsyncResult(params…, std::function<void(logos::AsyncResult<T>)> cb,
                      Timeout timeout = Timeout());                                  // new

logos::AsyncResult<T> (new, Qt-free, cpp/logos_async_result.h) is {value, error}
plus ok(); AsyncResult<void> carries only the error so every fooAsyncResult has
the same callback shape. The name is distinct rather than an overload because
std::function<void(AsyncResult<T>)> next to std::function<void(T)> is ambiguous
for a generic lambda.

Applied to both emitters that produce this surface — legacy/generator_lib.cpp
(the module-builder path) and experimental/lidl_gen_client.cpp (`--lidl
--module-only`, from a published contract) — since a consumer can reach either
for the same contract.

The Qt-free (ApiStyle::Lp) surface gets the sync timeout (spelled `int
timeout_ms`; `Timeout` lives behind a Qt header) but NOT fooAsyncResult:
logos-protocol's lp_invoke_async hard-codes `cb(1, …)`, so an AsyncResult there
would report ok() on a failed call. Measured, not assumed. See the note in
makeHeaderLp.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 10:19:08 -03:00

71 lines
2.3 KiB
CMake

cmake_minimum_required(VERSION 3.14)
project(LogosSDK)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ---------------------------------------------------------------------------
# logos-cpp-sdk — the Qt-FREE base C++ SDK.
#
# After the protocol extraction (logos-protocol) and the Qt split
# (logos-qt-sdk), what lives here is the standard-C++ developer surface for
# universal module implementations plus the code generator (built from
# ../cpp-generator as a separate tool):
#
# logos_module_context.h - LogosModuleContext (module identity/context,
# typed modules() accessor, onContextReady)
# logos_result.h - StdLogosResult (std/nlohmann result type)
# logos_json.h - LogosMap/LogosList aliases for impl classes
#
# Everything is header-only; the exported target is an INTERFACE library.
# Qt-typed wrappers, the legacy QObject provider path and the Qt plugin
# glue live in logos-qt-sdk. Transports, the consumer core and the lp_* C
# ABI live in logos-protocol.
# ---------------------------------------------------------------------------
find_package(nlohmann_json REQUIRED)
add_library(logos_headers INTERFACE)
target_link_libraries(logos_headers INTERFACE nlohmann_json::nlohmann_json)
target_include_directories(logos_headers INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
install(TARGETS logos_headers
EXPORT logos-cpp-sdkTargets
INCLUDES DESTINATION include
)
install(EXPORT logos-cpp-sdkTargets
FILE logos-cpp-sdkTargets.cmake
NAMESPACE logos-cpp-sdk::
DESTINATION lib/cmake/logos-cpp-sdk
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/logos-cpp-sdkConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/logos-cpp-sdkConfig.cmake"
INSTALL_DESTINATION lib/cmake/logos-cpp-sdk
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/logos-cpp-sdkConfigVersion.cmake"
VERSION 0.2.0
COMPATIBILITY SameMajorVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/logos-cpp-sdkConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/logos-cpp-sdkConfigVersion.cmake"
DESTINATION lib/cmake/logos-cpp-sdk
)
install(FILES
logos_module_context.h
logos_json.h
logos_result.h
logos_lp_client.h
logos_async_result.h
DESTINATION include
)