build: fetch libbsdl from git when ../libbsdl is absent

Fall back to FetchContent (BSDL_GIT_REPOSITORY/BSDL_GIT_TAG) so a fresh
clone configures without a manual side-checkout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 19:39:03 +02:00
parent dceb61237d
commit e37309aacf
3 changed files with 25 additions and 10 deletions

View File

@@ -16,12 +16,25 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(EssimFrontend) include(EssimFrontend)
# ----------------------------------------------------------------- core deps # ----------------------------------------------------------------- core deps
# libbsdl — standalone BSDL parser (LGPL-2.1), dynamically linked (EUPL-1.2, # libbsdl — standalone BSDL parser (LGPL-2.1), dynamically linked. Local sibling
# which the LGPL permits). Override its path with -DBSDL_DIR=... # ../libbsdl (override -DBSDL_DIR=...) if present, else fetched from git.
set(BSDL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../libbsdl" CACHE PATH "libbsdl source tree") set(BSDL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../libbsdl" CACHE PATH "libbsdl source tree")
set(BSDL_GIT_REPOSITORY "https://git.beafrancois.fr/electronics/libbsdl.git" CACHE STRING "libbsdl git repo (used when BSDL_DIR is absent)")
set(BSDL_GIT_TAG "main" CACHE STRING "libbsdl git revision to fetch")
set(BSDL_BUILD_CLI OFF CACHE BOOL "" FORCE) set(BSDL_BUILD_CLI OFF CACHE BOOL "" FORCE)
set(BSDL_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(BSDL_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(${BSDL_DIR} ${CMAKE_BINARY_DIR}/libbsdl) if(EXISTS "${BSDL_DIR}/CMakeLists.txt")
message(STATUS "essim: libbsdl from local tree '${BSDL_DIR}'")
add_subdirectory(${BSDL_DIR} ${CMAKE_BINARY_DIR}/libbsdl)
else()
message(STATUS "essim: libbsdl absent — fetching ${BSDL_GIT_REPOSITORY} (${BSDL_GIT_TAG})")
FetchContent_Declare(libbsdl
GIT_REPOSITORY ${BSDL_GIT_REPOSITORY}
GIT_TAG ${BSDL_GIT_TAG}
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(libbsdl)
endif()
find_package(libzip REQUIRED) find_package(libzip REQUIRED)
find_package(pugixml REQUIRED) find_package(pugixml REQUIRED)

View File

@@ -19,9 +19,10 @@ cmake --build build -j
- **Core system dependencies** (via `find_package`): `libzip` (`libzip::zip`) - **Core system dependencies** (via `find_package`): `libzip` (`libzip::zip`)
and `pugixml` (`pugixml::pugixml`) for the ODS importer. Arch: and `pugixml` (`pugixml::pugixml`) for the ODS importer. Arch:
`pacman -S libzip pugixml`; Debian/Ubuntu: `libzip-dev libpugixml-dev`. `pacman -S libzip pugixml`; Debian/Ubuntu: `libzip-dev libpugixml-dev`.
- **`libbsdl`** (standalone BSDL parser, LGPL-2.1) — sibling repo at - **`libbsdl`** (standalone BSDL parser, LGPL-2.1) — linked dynamically **into
`../libbsdl`, `add_subdirectory` (override `-DBSDL_DIR=...`), linked the core** (`bsdl::bsdl`). Local sibling `../libbsdl` via `add_subdirectory`
dynamically **into the core** (`bsdl::bsdl`). (override `-DBSDL_DIR=...`) when `${BSDL_DIR}/CMakeLists.txt` exists, otherwise
`FetchContent` from `-DBSDL_GIT_REPOSITORY` (`-DBSDL_GIT_TAG`, default `main`).
- **FTXUI** is fetched by the **tui frontend only** - **FTXUI** is fetched by the **tui frontend only**
(`src/frontends/tui/CMakeLists.txt`), never by the core. (`src/frontends/tui/CMakeLists.txt`), never by the core.
- Sources are globbed per layer: `src/core/*.cpp``essim_core`, - Sources are globbed per layer: `src/core/*.cpp``essim_core`,

View File

@@ -44,10 +44,11 @@ Step-by-step walkthroughs for both the batch and TUI workflows are in
- Debian/Ubuntu — `sudo apt install libzip-dev libpugixml-dev` - Debian/Ubuntu — `sudo apt install libzip-dev libpugixml-dev`
- Arch — `sudo pacman -S libzip pugixml` - Arch — `sudo pacman -S libzip pugixml`
- Fedora — `sudo dnf install libzip-devel pugixml-devel` - Fedora — `sudo dnf install libzip-devel pugixml-devel`
- **libbsdl** — the standalone BSDL parser, a sibling repo expected at - **libbsdl** — the standalone BSDL parser, linked dynamically. Uses a sibling
`../libbsdl`, pulled in via `add_subdirectory` and linked dynamically. checkout at `../libbsdl` (override `-DBSDL_DIR=/path/to/libbsdl`) if present,
Override its location with `-DBSDL_DIR=/path/to/libbsdl`. Powers the else fetched from git automatically (`-DBSDL_GIT_REPOSITORY=...`,
`attach-bsdl` command and the pin/JTAG checks. `-DBSDL_GIT_TAG=...`, default branch `main`). Powers the `attach-bsdl` command
and the pin/JTAG checks.
- Fetched automatically via `FetchContent` (nothing to install): **FTXUI** - Fetched automatically via `FetchContent` (nothing to install): **FTXUI**
v6.1.9 — only when building the **tui** frontend — and **doctest** v2.4.11 v6.1.9 — only when building the **tui** frontend — and **doctest** v2.4.11
for the tests. for the tests.