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.

20 changes: 5 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.25 FATAL_ERROR)
PROJECT(transparent_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")
SET(CMAKE_CXX_STANDARD 20)
Expand All @@ -14,8 +18,6 @@ SET(TRANSPARENT_MODULE_VERSION 1.0.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 @@ -43,19 +45,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(fleet-protocol-interface 2.1.0 REQUIRED)
Expand Down
30 changes: 16 additions & 14 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +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(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)
BA_PACKAGE_LIBRARY(zlib v1.3.2)

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()

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}>")

# 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)
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()

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)

# 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)
# 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