From 45ecf0c419976ffb8ee5c1715ce67c6803144483 Mon Sep 17 00:00:00 2001 From: Gabriel Somlo Date: Sun, 12 Jul 2026 10:51:00 -0400 Subject: [PATCH] CMake: cxxopts: support building with distro-packaged dependency Many linux distros (e.g., Fedora) strongly discourage bundling or vendoring dependencies. Many of them also include a `cxxopts-devel` package. This patch adds support for un-vendoring `cxxopts` by: 1. `libs/cxxopts` vendored submodule build conditional on `YOSYS_WITH_PKG_DEPS == OFF` 2. use implicit `` instead of explicit hard-coded path to vendored header file 3. conditionally provide additional implicit include path to `cxxopts.hpp` and library dependency for `kernel/CMakeLists.txt` Note that the current existing behavior remains the default. Signed-off-by: Gabriel Somlo --- kernel/CMakeLists.txt | 3 ++- kernel/driver.cc | 2 +- libs/CMakeLists.txt | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 4cd76b4ff..13b3d7e43 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -89,9 +89,10 @@ yosys_core(kernel yw.cc yw.h INCLUDE_DIRS + $<$>:${CMAKE_CURRENT_SOURCE_DIR}/libs/cxxopts/include/> ${pybind11_INCLUDE_DIR} LIBRARIES - cxxopts + $<$>:cxxopts> $<${YOSYS_ENABLE_PLUGINS}:${Dlfcn_LIBRARIES}> $<${YOSYS_ENABLE_ZLIB}:PkgConfig::zlib> $<${YOSYS_ENABLE_READLINE}:PkgConfig::readline> diff --git a/kernel/driver.cc b/kernel/driver.cc index 2a4ad1295..7bb67ffea 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -21,7 +21,7 @@ #include "kernel/hashlib.h" #include "libs/sha1/sha1.h" #define CXXOPTS_VECTOR_DELIMITER '\0' -#include "libs/cxxopts/include/cxxopts.hpp" +#include #include #include diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index fd82239ec..4dc97df3d 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -1,5 +1,7 @@ add_subdirectory(bigint) -add_subdirectory(cxxopts) +if (NOT YOSYS_WITH_PKG_DEPS) + add_subdirectory(cxxopts) +endif() add_subdirectory(dlfcn-win32) add_subdirectory(ezsat) add_subdirectory(fst)