Skip to content
Open
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
6 changes: 0 additions & 6 deletions CMLibStorage.cmake

This file was deleted.

23 changes: 6 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.21)
CMAKE_MINIMUM_REQUIRED(VERSION 3.24)
PROJECT(io_module CXX)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
FIND_PACKAGE(CMLIB COMPONENTS CMDEF CMUTIL STORAGE REQUIRED)
INCLUDE(GNUInstallDirs)


SET(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
SET(CMAKE_INSTALL_RPATH "$ORIGIN")
Expand All @@ -12,8 +16,6 @@ SET(IO_MODULE_VERSION 1.3.5)

OPTION(BRINGAUTO_INSTALL "Configure install" OFF)
OPTION(BRINGAUTO_PACKAGE "Configure package creation" OFF)
OPTION(BRINGAUTO_SYSTEM_DEP "System dependencies are used if switched to ON, packager used if OFF" OFF)
OPTION(BRINGAUTO_GET_PACKAGES_ONLY "Only download packages for this project" OFF)
OPTION(FLEET_PROTOCOL_BUILD_MODULE_GATEWAY "Build shared library for module gateway " ON)
OPTION(FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER "Build shared library for external server " ON)

Expand Down Expand Up @@ -41,20 +43,7 @@ IF (BRINGAUTO_PACKAGE)
ENDIF ()
ENDIF ()

FIND_PACKAGE(CMLIB COMPONENTS CMCONF REQUIRED)
CMCONF_INIT_SYSTEM(FLEET_PROTOCOL)

FIND_PACKAGE(CMLIB
COMPONENTS CMDEF CMUTIL STORAGE
REQUIRED
)

IF (NOT BRINGAUTO_SYSTEM_DEP)
INCLUDE(cmake/Dependencies.cmake)
IF (BRINGAUTO_GET_PACKAGES_ONLY)
RETURN()
ENDIF ()
ENDIF ()
INCLUDE("cmake/Dependencies.cmake")

FIND_PACKAGE(nlohmann_json 3.10.5 REQUIRED)
FIND_PACKAGE(aeron 1.48.6 REQUIRED)
Expand Down
29 changes: 16 additions & 13 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
SET(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE)
find_package(BANlohmannJson REQUIRED)
# fleet-protocol-interface's internal protobuf fetch is a no-op under our
# FindCMLIB.cmake shim (BA_PACKAGE_LIBRARY does nothing) — resolve protobuf::libprotobuf
# ourselves first so FindBAFleetProtocolInterface.cmake's link-libraries fixup has
# a real target to attach to. Same fix BAF-1706 needed in external-server-cpp.
find_package(BAProtobuf REQUIRED)
find_package(BAFleetProtocolInterface REQUIRED)
find_package(BAAeron REQUIRED)
find_package(BAAsyncFunctionExecution REQUIRED)
find_package(BAFleetProtocolCpp REQUIRED)

BA_PACKAGE_LIBRARY(nlohmann-json v3.12.0 NO_DEBUG ON)
BA_PACKAGE_LIBRARY(zlib v1.3.2)
BA_PACKAGE_LIBRARY(fleet-protocol-cpp v1.2.0)
BA_PACKAGE_LIBRARY(async-function-execution v1.0.0)
BA_PACKAGE_LIBRARY(aeron v1.48.6)
BA_PACKAGE_LIBRARY(fleet-protocol-interface v2.1.0 NO_DEBUG ON)

IF (FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER)
BA_PACKAGE_LIBRARY(fleet-http-client-shared v2.0.2)
BA_PACKAGE_LIBRARY(boost v1.86.0)
BA_PACKAGE_LIBRARY(cpprestsdk v2.10.20)
ENDIF ()
if (FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER)
find_package(BABoost REQUIRED)
find_package(BAZlib REQUIRED)
find_package(BACppRestSdk REQUIRED)
find_package(BAFleetHttpClient REQUIRED)
endif ()
70 changes: 70 additions & 0 deletions cmake/FindBAAeron.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
include_guard(GLOBAL)

# Provides: aeron (imported target from aeron cmake package)
# Resolution order: in-scope target → system config package → FetchContent source build.

if(TARGET aeron)
set(BAAeron_FOUND TRUE)
return()
endif()
Comment on lines +1 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

workdir="$(mktemp -d)"
cd "$workdir"

cat > CMakeLists.txt <<'CMAKE'
cmake_minimum_required(VERSION 3.20)
project(test NONE)

# Simulate the package file content.
file(WRITE "${CMAKE_BINARY_DIR}/FindBAAeron.cmake" [=[
include_guard(GLOBAL)

if(TARGET aeron)
  set(BAAeron_FOUND TRUE)
  return()
endif()

set(BAAeron_FOUND FALSE)
]=])

# First call from top scope, no target.
find_package(BAAeron REQUIRED)

# Create target, then call again from a nested scope.
add_library(aeron INTERFACE)
function(call_again)
  find_package(BAAeron REQUIRED)
  message(STATUS "BAAeron_FOUND in function: '${BAAeron_FOUND}'")
endfunction()
call_again()

message(STATUS "BAAeron_FOUND in top scope after second call: '${BAAeron_FOUND}'")
CMAKE

cmake -S . -B build

Repository: bringauto/io-module

Length of output: 201


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the package module and any forwarding shims / call sites.
git ls-files | rg '(^|/)FindBAAeron\.cmake$|(^|/)CMakeLists\.txt$|(^|/)cmake/.*BAAeron|(^|/)aeron'

# Show the package file with line numbers if present.
if git ls-files | rg -q '^cmake/FindBAAeron\.cmake$'; then
  echo "----- cmake/FindBAAeron.cmake -----"
  cat -n cmake/FindBAAeron.cmake
fi

# Search for related variables / find_package calls.
rg -n --hidden --glob '!**/.git/**' 'find_package\s*\(\s*(BAAeron|aeron)\b|BAAeron_FOUND|include_guard\s*\(' .

Repository: bringauto/io-module

Length of output: 4507


Remove the global include guard here

include_guard(GLOBAL) can break repeated find_package(BAAeron) calls from a different directory scope that doesn’t already inherit BAAeron_FOUND. The if(TARGET aeron) fast path already makes this file idempotent, so the guard is unnecessary and risky.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmake/FindBAAeron.cmake` around lines 1 - 9, Remove the global include guard
from FindBAAeron.cmake so repeated find_package(BAAeron) calls can re-evaluate
in different directory scopes. Keep the existing if(TARGET aeron) fast path and
the rest of the BAAeron discovery logic intact, since that already makes the
module idempotent without relying on include_guard(GLOBAL).


if(aeron_DIR MATCHES "${CMAKE_BINARY_DIR}")
unset(aeron_DIR CACHE)
endif()
find_package(aeron QUIET CONFIG)
if(aeron_FOUND)
message(STATUS "[BA] aeron: found via system package")
set(BAAeron_FOUND TRUE)
return()
endif()

message(STATUS "[BA] aeron: system package not found, fetching via FetchContent")
include(FetchContent)
set(AERON_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
set(AERON_TESTS OFF CACHE BOOL "" FORCE)
set(AERON_UNIT_TESTS OFF CACHE BOOL "" FORCE)
set(AERON_SYSTEM_TESTS OFF CACHE BOOL "" FORCE)
set(AERON_INSTALL_TARGETS OFF CACHE BOOL "" FORCE)
# Archive API requires Java for code generation; disable it.
# Driver (C media driver) IS needed — async-function-execution links aeron::aeron_driver.
set(BUILD_AERON_ARCHIVE_API OFF CACHE BOOL "" FORCE)
# OVERRIDE_FIND_PACKAGE: intercepts direct find_package(aeron ...) calls in
# subdirectories so they resolve to this FetchContent copy (name matches case-insensitively).
FetchContent_Declare(aeron
GIT_REPOSITORY https://github.com/aeron-io/aeron.git
GIT_TAG 1.48.6
GIT_SHALLOW TRUE
OVERRIDE_FIND_PACKAGE)
FetchContent_MakeAvailable(aeron)

# async-function-execution includes <aeronmd/aeron_driver.h> which expects the installed
# header layout (install(DIRECTORY ./ DESTINATION include/aeronmd ...)).
# In a FetchContent build, headers live in aeron-driver/src/main/c/ with no aeronmd/
# subdirectory. Create a shim include dir containing an aeronmd/ symlink so the header
# resolves without running cmake --install.
set(_aeron_driver_c "${aeron_SOURCE_DIR}/aeron-driver/src/main/c")
set(_aeron_inc_shim "${aeron_BINARY_DIR}/include-shim")
file(MAKE_DIRECTORY "${_aeron_inc_shim}")
if(NOT EXISTS "${_aeron_inc_shim}/aeronmd")
file(CREATE_LINK "${_aeron_driver_c}" "${_aeron_inc_shim}/aeronmd" SYMBOLIC)
endif()
target_include_directories(aeron_driver PUBLIC
"$<BUILD_INTERFACE:${_aeron_inc_shim}>")
target_include_directories(aeron_driver_static PUBLIC
"$<BUILD_INTERFACE:${_aeron_inc_shim}>")
Comment on lines +51 to +54

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Missing TARGET guard before wiring includes into aeron_driver/aeron_driver_static.

Unlike the install loop below (lines 59-66) which checks if(TARGET ${_aeron_tgt}) before acting, these two target_include_directories() calls assume the targets unconditionally exist after FetchContent_MakeAvailable(aeron). If either target is absent (e.g. due to platform-specific Aeron build configuration), this fails the configure with a hard CMake error rather than degrading gracefully.

🛡️ Proposed fix
-target_include_directories(aeron_driver PUBLIC
-    "$<BUILD_INTERFACE:${_aeron_inc_shim}>")
-target_include_directories(aeron_driver_static PUBLIC
-    "$<BUILD_INTERFACE:${_aeron_inc_shim}>")
+if(TARGET aeron_driver)
+    target_include_directories(aeron_driver PUBLIC
+        "$<BUILD_INTERFACE:${_aeron_inc_shim}>")
+endif()
+if(TARGET aeron_driver_static)
+    target_include_directories(aeron_driver_static PUBLIC
+        "$<BUILD_INTERFACE:${_aeron_inc_shim}>")
+endif()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
target_include_directories(aeron_driver PUBLIC
"$<BUILD_INTERFACE:${_aeron_inc_shim}>")
target_include_directories(aeron_driver_static PUBLIC
"$<BUILD_INTERFACE:${_aeron_inc_shim}>")
if(TARGET aeron_driver)
target_include_directories(aeron_driver PUBLIC
"$<BUILD_INTERFACE:${_aeron_inc_shim}>")
endif()
if(TARGET aeron_driver_static)
target_include_directories(aeron_driver_static PUBLIC
"$<BUILD_INTERFACE:${_aeron_inc_shim}>")
endif()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmake/FindBAAeron.cmake` around lines 51 - 54, The include wiring for
aeron_driver and aeron_driver_static is unguarded, so the CMake configure can
fail if either target is not created by FetchContent_MakeAvailable(aeron). Add a
TARGET existence check around the target_include_directories() calls, using the
same pattern already used in the install loop with _aeron_tgt, so include paths
are only applied when each target is actually present.


# Install shared aeron libraries so the external-server-cpp binary can find them
# at runtime via its RPATH ($ORIGIN/../lib). AERON_INSTALL_TARGETS=OFF skips
# aeron's own install targets, so we register them explicitly here.
foreach(_aeron_tgt aeron aeron_client_shared aeron_driver)
if(TARGET ${_aeron_tgt})
get_target_property(_aeron_ttype ${_aeron_tgt} TYPE)
if(_aeron_ttype STREQUAL "SHARED_LIBRARY")
install(TARGETS ${_aeron_tgt} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
endforeach()
unset(_aeron_tgt)
unset(_aeron_ttype)

set(BAAeron_FOUND TRUE)
52 changes: 52 additions & 0 deletions cmake/FindBAAsyncFunctionExecution.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
include_guard(GLOBAL)

# Provides: async-function-execution-shared::async-function-execution-shared
# Resolution order: in-scope target → system config package → FetchContent source build.
# Note: async-function-execution uses cmlib internally; FindCMLIB.cmake shim handles it.

if(TARGET async-function-execution-shared::async-function-execution-shared)
set(BAAsyncFunctionExecution_FOUND TRUE)
return()
endif()

if(async-function-execution-shared_DIR MATCHES "${CMAKE_BINARY_DIR}")
unset(async-function-execution-shared_DIR CACHE)
endif()
find_package(async-function-execution-shared QUIET CONFIG)
if(async-function-execution-shared_FOUND)
message(STATUS "[BA] async-function-execution: found via config package")
set(BAAsyncFunctionExecution_FOUND TRUE)
return()
endif()

message(STATUS "[BA] async-function-execution: not found locally, fetching via FetchContent")
include(FetchContent)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../async-function-execution/CMakeLists.txt")
set(FETCHCONTENT_SOURCE_DIR_ASYNC_FUNCTION_EXECUTION
"${CMAKE_CURRENT_SOURCE_DIR}/../async-function-execution" CACHE PATH "" FORCE)
endif()
FetchContent_Declare(async_function_execution
GIT_REPOSITORY https://github.com/bringauto/async-function-execution.git
GIT_TAG v1.0.0
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(async_function_execution)
# CMDEF_ADD_LIBRARY creates async-function-execution-shared; create the namespaced alias.
if(TARGET async-function-execution-shared
AND NOT TARGET async-function-execution-shared::async-function-execution-shared)
add_library(async-function-execution-shared::async-function-execution-shared
ALIAS async-function-execution-shared)
endif()

# Install the shared library so the binary can find it via RPATH at runtime.
# CMDEF_INSTALL() is a no-op in our shim, so we register the install rule here.
if(TARGET async-function-execution-shared)
get_target_property(_afe_ttype async-function-execution-shared TYPE)
if(_afe_ttype STREQUAL "SHARED_LIBRARY")
install(TARGETS async-function-execution-shared
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
unset(_afe_ttype)
Comment on lines +24 to +49

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Avoid forcing BUILD_SHARED_LIBS from inside a find module.

CACHE FORCE rewrites the parent cache, so every later dependency fetched in this configure inherits OFF. That can flip unrelated targets between static/shared builds and make the install rule below disappear if the fetched project obeys the override. Please scope this to the FetchContent subproject and restore the previous value instead of mutating global state here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmake/FindBAAsyncFunctionExecution.cmake` around lines 24 - 49, The
FindBAAsyncFunctionExecution module is mutating global build state by forcing
BUILD_SHARED_LIBS OFF in the parent cache. Update the logic around
FetchContent_Declare/FetchContent_MakeAvailable so the shared/static choice is
scoped only to the async_function_execution subproject, and restore any previous
BUILD_SHARED_LIBS value after fetching. Keep the alias/install handling for
async-function-execution-shared, but avoid leaving global cache changes behind.

endif()

set(BAAsyncFunctionExecution_FOUND TRUE)
52 changes: 52 additions & 0 deletions cmake/FindBABoost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# CMake 4.x removed FindBoost.cmake (CMP0167) — always use CONFIG mode.
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()

# Provides: Boost::<component> targets matching requested components.
# No include_guard — callers may request different components.
find_package(Boost 1.86 CONFIG QUIET COMPONENTS ${BABoost_FIND_COMPONENTS})
if(Boost_FOUND)
set(BABoost_FOUND TRUE)
return()
endif()
Comment on lines +8 to +12

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

System-Boost check doesn't validate required components.

BABoost_FIND_COMPONENTS is empty in the actual call sites (find_package(BABoost REQUIRED) in Dependencies.cmake, FIND_PACKAGE(Boost CONFIG REQUIRED) in CMakeLists.txt never pass COMPONENTS), so line 8 effectively becomes find_package(Boost 1.86 CONFIG QUIET COMPONENTS) — it only checks that a BoostConfig.cmake exists, not that regex/date_time/filesystem/thread/etc. are actually built. A system Boost package that's missing some of these compiled libraries would still satisfy Boost_FOUND here, and downstream target_link_libraries(... Boost::filesystem ...) calls would fail later with a much more confusing "target not found" error instead of falling through to the FetchContent build that guarantees the full set.

🐛 Proposed fix: require the same component set used for the fallback build
+set(_BABoost_REQUIRED_COMPONENTS
+    regex date_time atomic random chrono system filesystem thread asio uuid)
 find_package(Boost 1.86 CONFIG QUIET COMPONENTS ${BABoost_FIND_COMPONENTS})
+find_package(Boost 1.86 CONFIG QUIET COMPONENTS ${_BABoost_REQUIRED_COMPONENTS})
 if(Boost_FOUND)
     set(BABoost_FOUND TRUE)
     return()
 endif()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
find_package(Boost 1.86 CONFIG QUIET COMPONENTS ${BABoost_FIND_COMPONENTS})
if(Boost_FOUND)
set(BABoost_FOUND TRUE)
return()
endif()
set(_BABoost_REQUIRED_COMPONENTS
regex date_time atomic random chrono system filesystem thread asio uuid)
find_package(Boost 1.86 CONFIG QUIET COMPONENTS ${BABoost_FIND_COMPONENTS})
find_package(Boost 1.86 CONFIG QUIET COMPONENTS ${_BABoost_REQUIRED_COMPONENTS})
if(Boost_FOUND)
set(BABoost_FOUND TRUE)
return()
endif()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmake/FindBABoost.cmake` around lines 8 - 12, The Boost config probe in
FindBABoost.cmake only checks for a BoostConfig.cmake file and can incorrectly
mark Boost as found even when required libraries are missing. Update the
find_package(Boost 1.86 CONFIG QUIET ...) logic in the FindBABoost module to
require the same component set used by the fallback build, so it verifies the
needed libraries before setting BABoost_FOUND and returning. Use the existing
BABoost_FIND_COMPONENTS handling and the module’s find_package(Boost) flow to
ensure missing compiled components correctly fall back to FetchContent.


message(STATUS "[BA] Boost 1.86 config package not found, fetching via FetchContent")
include(FetchContent)

# BOOST_INCLUDE_LIBRARIES controls which Boost libraries are built.
# List all components used by the external-server variant's HTTP client stack
# (fleet-http-client-shared -> cpprestsdk) here so that the first
# FetchContent_MakeAvailable call (whichever component triggers it) builds all
# of them — subsequent calls are no-ops and cannot extend the component list.
# OVERRIDE_FIND_PACKAGE (CMake 3.24+) makes the direct FIND_PACKAGE(Boost CONFIG ...)
# call in CMakeLists.txt resolve to this FetchContent version automatically.
set(BOOST_INCLUDE_LIBRARIES
regex date_time atomic random chrono system filesystem thread asio uuid)
set(BOOST_ENABLE_PYTHON OFF)
set(BOOST_ENABLE_MPI OFF)
set(BUILD_SHARED_LIBS OFF)

FetchContent_Declare(Boost
URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
OVERRIDE_FIND_PACKAGE)
FetchContent_MakeAvailable(Boost)
Comment on lines +26 to +34

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Unscoped BUILD_SHARED_LIBS override leaks past this module.

set(BUILD_SHARED_LIBS OFF) is a plain directory-scope variable (this file has no include_guard/function wrapper), so it stays OFF for every target configured afterward in the same scope — including the project's own libraries/executables if they rely on the default rather than an explicit STATIC/SHARED keyword — with no restore of the prior value once the Boost fetch is done.

♻️ Proposed fix: save/restore the previous value
+set(_BABoost_prev_build_shared_libs ${BUILD_SHARED_LIBS})
 set(BOOST_INCLUDE_LIBRARIES
     regex date_time atomic random chrono system filesystem thread asio uuid)
 set(BOOST_ENABLE_PYTHON OFF)
 set(BOOST_ENABLE_MPI    OFF)
 set(BUILD_SHARED_LIBS   OFF)

 FetchContent_Declare(Boost
     URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.gz
     DOWNLOAD_EXTRACT_TIMESTAMP TRUE
     OVERRIDE_FIND_PACKAGE)
 FetchContent_MakeAvailable(Boost)
+set(BUILD_SHARED_LIBS ${_BABoost_prev_build_shared_libs})
+unset(_BABoost_prev_build_shared_libs)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
set(BOOST_ENABLE_PYTHON OFF)
set(BOOST_ENABLE_MPI OFF)
set(BUILD_SHARED_LIBS OFF)
FetchContent_Declare(Boost
URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
OVERRIDE_FIND_PACKAGE)
FetchContent_MakeAvailable(Boost)
set(_BABoost_prev_build_shared_libs ${BUILD_SHARED_LIBS})
set(BOOST_ENABLE_PYTHON OFF)
set(BOOST_ENABLE_MPI OFF)
set(BUILD_SHARED_LIBS OFF)
FetchContent_Declare(Boost
URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
OVERRIDE_FIND_PACKAGE)
FetchContent_MakeAvailable(Boost)
set(BUILD_SHARED_LIBS ${_BABoost_prev_build_shared_libs})
unset(_BABoost_prev_build_shared_libs)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmake/FindBABoost.cmake` around lines 26 - 34, The `BUILD_SHARED_LIBS`
setting in `FindBABoost.cmake` is leaking into the caller scope because it is
set globally before `FetchContent_MakeAvailable(Boost)` and never restored. Save
the existing value of `BUILD_SHARED_LIBS` before forcing it OFF for Boost, then
restore that saved value immediately after the Boost fetch/setup completes. Use
the `FetchContent_Declare(Boost)` / `FetchContent_MakeAvailable(Boost)` block as
the place to bracket the temporary override.


# Boost's cmake config does NOT set Boost_LIBRARIES or Boost_INCLUDE_DIR —
# those are FindBoost.cmake (module-mode) variables. The modules' CMakeLists.txt
# explicitly link against Boost::<component> targets, but set these too in case
# any consumer still expects the module-mode variables.
set(Boost_LIBRARIES
Boost::regex
Boost::date_time
Boost::atomic
Boost::random
Boost::chrono
Boost::system
Boost::filesystem
Boost::thread
Boost::asio
Boost::uuid)
set(Boost_INCLUDE_DIR "")
set(BABoost_FOUND TRUE)
47 changes: 47 additions & 0 deletions cmake/FindBACppRestSdk.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
include_guard(GLOBAL)

# Provides: cpprestsdk::cpprest
# Resolution order: in-scope target → system config package → FetchContent source build.
# Uses the BringAuto fork (github.com/bringauto/cpprestsdk) — vanilla cpprestsdk only
# goes up to v2.10.19, so the v2.10.20 tag pinned by the old cmlib Dependencies.cmake
# confirms this is the fork, not upstream Microsoft/cpprestsdk.

if(TARGET cpprestsdk::cpprest)
set(BACppRestSdk_FOUND TRUE)
return()
endif()

if(cpprestsdk_DIR MATCHES "${CMAKE_BINARY_DIR}")
unset(cpprestsdk_DIR CACHE)
endif()
find_package(cpprestsdk QUIET CONFIG)
if(cpprestsdk_FOUND)
message(STATUS "[BA] cpprestsdk: found via system package")
set(BACppRestSdk_FOUND TRUE)
return()
endif()

message(STATUS "[BA] cpprestsdk: not found locally, fetching via FetchContent")
include(FetchContent)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
# The bundled websocketpp fails to compile against GCC 13's stricter parsing of
# template-id destructors; the module only needs plain HTTP polling, not websockets.
set(CPPREST_EXCLUDE_WEBSOCKETS ON CACHE BOOL "" FORCE)
set(WERROR OFF CACHE BOOL "" FORCE)
set(BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
Comment on lines +26 to +32

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

CACHE ... FORCE here has project-wide, persistent side effects.

These five variables are force-written to the cache, which (a) permanently overrides any value the consuming project or its user explicitly set (e.g. -DBUILD_SHARED_LIBS=ON), surviving across re-configures, and (b) risks colliding with generically-named options (BUILD_TESTS, BUILD_SAMPLES, WERROR) from other FetchContent'd dependencies that share the same option names. Prefer setting these without FORCE (a plain CACHE set only takes effect if the variable isn't already defined, which is the idiomatic way to provide defaults for a fetched sub-project) or scope/restore them around the FetchContent_MakeAvailable call.

♻️ Proposed fix: drop FORCE so pre-existing user values win
-set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
-set(CPPREST_EXCLUDE_WEBSOCKETS ON CACHE BOOL "" FORCE)
-set(WERROR OFF CACHE BOOL "" FORCE)
-set(BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
-set(BUILD_TESTS   OFF CACHE BOOL "" FORCE)
+set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
+set(CPPREST_EXCLUDE_WEBSOCKETS ON CACHE BOOL "")
+set(WERROR OFF CACHE BOOL "")
+set(BUILD_SAMPLES OFF CACHE BOOL "")
+set(BUILD_TESTS   OFF CACHE BOOL "")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
# The bundled websocketpp fails to compile against GCC 13's stricter parsing of
# template-id destructors; the module only needs plain HTTP polling, not websockets.
set(CPPREST_EXCLUDE_WEBSOCKETS ON CACHE BOOL "" FORCE)
set(WERROR OFF CACHE BOOL "" FORCE)
set(BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
# The bundled websocketpp fails to compile against GCC 13's stricter parsing of
# template-id destructors; the module only needs plain HTTP polling, not websockets.
set(CPPREST_EXCLUDE_WEBSOCKETS ON CACHE BOOL "")
set(WERROR OFF CACHE BOOL "")
set(BUILD_SAMPLES OFF CACHE BOOL "")
set(BUILD_TESTS OFF CACHE BOOL "")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmake/FindBACppRestSdk.cmake` around lines 26 - 32, The cache writes in
FindBACppRestSdk.cmake are using FORCE, which overrides user- or
project-provided values and can leak across re-configures. Update the option
setup around BUILD_SHARED_LIBS, CPPREST_EXCLUDE_WEBSOCKETS, WERROR,
BUILD_SAMPLES, and BUILD_TESTS so they are only provided as defaults without
FORCE, preserving any pre-set values and avoiding collisions with other fetched
dependencies.

# OVERRIDE_FIND_PACKAGE: FetchContent_Declare's name matches the plain
# FIND_PACKAGE(cpprestsdk ...) call in CMakeLists.txt, so it intercepts it directly.
FetchContent_Declare(cpprestsdk
GIT_REPOSITORY https://github.com/bringauto/cpprestsdk.git
GIT_TAG v2.10.20
GIT_SHALLOW TRUE
OVERRIDE_FIND_PACKAGE)
FetchContent_MakeAvailable(cpprestsdk)
# cpprestsdk's build tree only defines the raw "cpprest" target — the
# namespaced "cpprestsdk::cpprest" alias normally comes from its install-export,
# which FetchContent bypasses. Create it manually.
if(TARGET cpprest AND NOT TARGET cpprestsdk::cpprest)
add_library(cpprestsdk::cpprest ALIAS cpprest)
endif()
set(BACppRestSdk_FOUND TRUE)
61 changes: 61 additions & 0 deletions cmake/FindBAFleetHttpClient.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
include_guard(GLOBAL)

# Provides: fleet-http-client-shared::fleet-http-client-shared
# Resolution order: in-scope target → system config package → FetchContent source build.
# Repo is named "fleet-http-client" but (like the other BringAuto cmlib packages)
# exports a CMake target "fleet-http-client-shared" via CMDEF_ADD_LIBRARY
# (LIBRARY_GROUP "fleet-http-client" + TYPE SHARED). It uses cmlib internally,
# so FindCMLIB.cmake must be on CMAKE_MODULE_PATH before this fetch, and it needs
# cpprestsdk/Boost/ZLIB findable already — declare those first in Dependencies.cmake.

if(TARGET fleet-http-client-shared::fleet-http-client-shared)
set(BAFleetHttpClient_FOUND TRUE)
return()
endif()

if(fleet-http-client-shared_DIR MATCHES "${CMAKE_BINARY_DIR}")
unset(fleet-http-client-shared_DIR CACHE)
endif()
find_package(fleet-http-client-shared QUIET CONFIG)
if(fleet-http-client-shared_FOUND)
message(STATUS "[BA] fleet-http-client: found via config package")
set(BAFleetHttpClient_FOUND TRUE)
return()
endif()

message(STATUS "[BA] fleet-http-client: not found locally, fetching via FetchContent")
include(FetchContent)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../fleet-http-client/CMakeLists.txt")
set(FETCHCONTENT_SOURCE_DIR_FLEET_HTTP_CLIENT_SHARED
"${CMAKE_CURRENT_SOURCE_DIR}/../fleet-http-client" CACHE PATH "" FORCE)
endif()
FetchContent_Declare(fleet_http_client_shared
GIT_REPOSITORY https://github.com/bringauto/fleet-http-client.git
GIT_TAG v2.0.2
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(fleet_http_client_shared)
# CMDEF_ADD_LIBRARY creates the unnamespaced fleet-http-client-shared target.
# The module's own CMakeLists.txt later calls TARGET_LINK_LIBRARIES a second
# time on the *namespaced* target to bolt on Boost/ZLIB (its "obsolete
# cpprestsdk cmake export package" workaround) — an ALIAS can't receive that
# (CMake forbids target_link_libraries on ALIAS targets), so forward via an
# IMPORTED INTERFACE library instead, which can.
if(TARGET fleet-http-client-shared
AND NOT TARGET fleet-http-client-shared::fleet-http-client-shared)
add_library(fleet-http-client-shared::fleet-http-client-shared INTERFACE IMPORTED)
target_link_libraries(fleet-http-client-shared::fleet-http-client-shared
INTERFACE fleet-http-client-shared)
endif()

# Install the shared library so consumers can find it via RPATH at runtime.
# CMDEF_INSTALL() is a no-op in our shim, so register the install rule here.
if(TARGET fleet-http-client-shared)
get_target_property(_fhc_ttype fleet-http-client-shared TYPE)
if(_fhc_ttype STREQUAL "SHARED_LIBRARY")
install(TARGETS fleet-http-client-shared
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
unset(_fhc_ttype)
endif()

set(BAFleetHttpClient_FOUND TRUE)
Loading