Files
essim/CMakeLists.txt
François 279be513a4 BSDL: ingest libbsdl into essim and populate PinSpec from a device model
Link libbsdl dynamically (add_subdirectory ../libbsdl, overridable via
-DBSDL_DIR). New BsdlModel wraps the C ABI and reduces a parsed .bsd to
essim's pin vocabulary; apply_bsdl() binds each port to a Pin (by name, then
by physical pad) and sets its spec: direction, function (TAP role / power /
ground / signal), pad, and source = Bsdl.

This feeds the PinSpec fields from P1, so verify's existing power/ground
placement pass now lights up for BSDL-modelled parts. Covered by
test_bsdl_apply (name + pad binding, TAP roles, linkage classification).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 15:01:00 +02:00

114 lines
3.9 KiB
CMake

cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(essim
LANGUAGES CXX
VERSION 0.1
DESCRIPTION "System digital twin."
)
include(FetchContent)
set(FTXUI_BUILD_DOCS OFF CACHE INTERNAL "")
set(FTXUI_BUILD_EXAMPLES OFF CACHE INTERNAL "")
set(FTXUI_BUILD_TESTS OFF CACHE INTERNAL "")
set(FTXUI_ENABLE_INSTALL OFF CACHE INTERNAL "")
FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/FTXUI.git
GIT_TAG v6.1.9
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(ftxui)
find_package(libzip REQUIRED)
find_package(pugixml REQUIRED)
# libbsdl — standalone BSDL parser (LGPL-2.1), dynamically linked from essim
# (EUPL-1.2, which the LGPL permits). Path overridable via -DBSDL_DIR=...;
# its CLI and tests are not needed inside essim's build.
set(BSDL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../libbsdl" CACHE PATH "libbsdl source tree")
set(BSDL_BUILD_CLI OFF CACHE BOOL "" FORCE)
set(BSDL_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(${BSDL_DIR} ${CMAKE_BINARY_DIR}/libbsdl)
# Library target = everything except main.cpp; reused by `essim` and `essim_tests`.
file(GLOB_RECURSE LIB_SOURCES "src/*.cpp")
list(REMOVE_ITEM LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp")
add_library(essim_lib STATIC ${LIB_SOURCES})
target_include_directories(essim_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_link_libraries(essim_lib
PUBLIC
ftxui::screen
ftxui::dom
ftxui::component
libzip::zip
pugixml::pugixml
bsdl::bsdl
)
add_executable(essim src/main.cpp)
target_link_libraries(essim PRIVATE essim_lib)
# Tests
include(CTest)
if(BUILD_TESTING)
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
FetchContent_Declare(doctest
GIT_REPOSITORY https://github.com/doctest/doctest.git
GIT_TAG v2.4.11
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(doctest)
unset(CMAKE_POLICY_VERSION_MINIMUM)
file(GLOB TEST_SOURCES "tests/*.cpp")
if(TEST_SOURCES)
add_executable(essim_tests ${TEST_SOURCES})
target_link_libraries(essim_tests PRIVATE essim_lib doctest::doctest)
add_test(NAME essim_tests COMMAND essim_tests)
endif()
endif()
# Documentation: Doxygen → XML → custom Python script → doc/api/ (Markdown rendered by gitea).
# Optional — `doc` target is only created if Doxygen and Python 3 are present.
find_package(Doxygen COMPONENTS doxygen)
find_package(Python3 COMPONENTS Interpreter)
if(DOXYGEN_FOUND AND Python3_Interpreter_FOUND)
set(DOXYGEN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/doc")
file(MAKE_DIRECTORY "${DOXYGEN_OUTPUT_DIR}")
configure_file(
"${CMAKE_SOURCE_DIR}/doc/Doxyfile.in"
"${DOXYGEN_OUTPUT_DIR}/Doxyfile"
@ONLY)
set(DOC_API_DIR "${CMAKE_SOURCE_DIR}/doc/api")
set(DOC_USER_DIR "${CMAKE_SOURCE_DIR}/doc/user")
add_custom_target(doc
DEPENDS essim
COMMAND ${CMAKE_COMMAND} -E rm -rf "${DOC_API_DIR}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${DOC_API_DIR}/classes"
COMMAND ${CMAKE_COMMAND} -E make_directory "${DOC_API_DIR}/files"
COMMAND ${CMAKE_COMMAND} -E make_directory "${DOC_USER_DIR}"
COMMAND ${DOXYGEN_EXECUTABLE} "${DOXYGEN_OUTPUT_DIR}/Doxyfile"
COMMAND ${Python3_EXECUTABLE}
"${CMAKE_SOURCE_DIR}/doc/gen_api_md.py"
"${DOXYGEN_OUTPUT_DIR}/xml"
"${DOC_API_DIR}"
COMMAND $<TARGET_FILE:essim> --commands-md "${DOC_USER_DIR}/commands.md"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Generating documentation (doxygen → gen_api_md.py → doc/api/, essim --commands-md → doc/user/commands.md)"
VERBATIM)
elseif(NOT DOXYGEN_FOUND AND NOT Python3_Interpreter_FOUND)
message(STATUS "doc: Doxygen and Python 3 not found — `doc` target disabled.")
elseif(NOT DOXYGEN_FOUND)
message(STATUS "doc: Doxygen not found — `doc` target disabled "
"(install via `pacman -S doxygen`).")
else()
message(STATUS "doc: Python 3 interpreter not found — `doc` target disabled.")
endif()