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)
# ----------------------------------------------------------------- core deps
# libbsdl — standalone BSDL parser (LGPL-2.1), dynamically linked (EUPL-1.2,
# which the LGPL permits). Override its path with -DBSDL_DIR=...
# libbsdl — standalone BSDL parser (LGPL-2.1), dynamically linked. Local sibling
# ../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_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_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(pugixml REQUIRED)

View File

@@ -19,9 +19,10 @@ cmake --build build -j
- **Core system dependencies** (via `find_package`): `libzip` (`libzip::zip`)
and `pugixml` (`pugixml::pugixml`) for the ODS importer. Arch:
`pacman -S libzip pugixml`; Debian/Ubuntu: `libzip-dev libpugixml-dev`.
- **`libbsdl`** (standalone BSDL parser, LGPL-2.1) — sibling repo at
`../libbsdl`, `add_subdirectory` (override `-DBSDL_DIR=...`), linked
dynamically **into the core** (`bsdl::bsdl`).
- **`libbsdl`** (standalone BSDL parser, LGPL-2.1) — linked dynamically **into
the core** (`bsdl::bsdl`). Local sibling `../libbsdl` via `add_subdirectory`
(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**
(`src/frontends/tui/CMakeLists.txt`), never by the 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`
- Arch — `sudo pacman -S libzip pugixml`
- Fedora — `sudo dnf install libzip-devel pugixml-devel`
- **libbsdl** — the standalone BSDL parser, a sibling repo expected at
`../libbsdl`, pulled in via `add_subdirectory` and linked dynamically.
Override its location with `-DBSDL_DIR=/path/to/libbsdl`. Powers the
`attach-bsdl` command and the pin/JTAG checks.
- **libbsdl** — the standalone BSDL parser, linked dynamically. Uses a sibling
checkout at `../libbsdl` (override `-DBSDL_DIR=/path/to/libbsdl`) if present,
else fetched from git automatically (`-DBSDL_GIT_REPOSITORY=...`,
`-DBSDL_GIT_TAG=...`, default branch `main`). Powers the `attach-bsdl` command
and the pin/JTAG checks.
- Fetched automatically via `FetchContent` (nothing to install): **FTXUI**
v6.1.9 — only when building the **tui** frontend — and **doctest** v2.4.11
for the tests.