From cf773aaa13364edc53a14aed1fee9a22112e9fec Mon Sep 17 00:00:00 2001 From: Daeho Ro <40587651+daeho-ro@users.noreply.github.com> Date: Sun, 12 Jul 2026 19:48:47 +0900 Subject: [PATCH] cmake: allow system fmt/tomlplusplus/boost for bundled deps FetchContent now tries find_package() first for fmt, tomlplusplus and Boost.Regex, only falling back to the vendored copies when no system package is found. This lets distribution and package-manager builds (e.g. Homebrew) link against system libraries instead of the bundles, without changing the default behaviour for a plain source build. --- libs/CMakeLists.txt | 50 +++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 5ea08ef9d..c3aa97d40 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -9,33 +9,43 @@ add_subdirectory(sha1) add_subdirectory(subcircuit) block() set(BUILD_SHARED_LIBS OFF) + set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) include(FetchContent) set(FETCHCONTENT_FULLY_DISCONNECTED ON) option(FMT_INSTALL OFF) - FetchContent_Declare( - fmt - EXCLUDE_FROM_ALL - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt - ) - FetchContent_MakeAvailable(fmt) + find_package(fmt QUIET) + if(NOT fmt_FOUND) + FetchContent_Declare( + fmt + EXCLUDE_FROM_ALL + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt + ) + FetchContent_MakeAvailable(fmt) + endif() - FetchContent_Declare( - tomlplusplus - EXCLUDE_FROM_ALL - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tomlplusplus - ) - FetchContent_MakeAvailable(tomlplusplus) - - FetchContent_Declare( - boost_regex - EXCLUDE_FROM_ALL - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/boost_regex - SOURCE_SUBDIR _no_build_ - ) - FetchContent_MakeAvailable(boost_regex) + find_package(tomlplusplus QUIET) + if(NOT tomlplusplus_FOUND) + FetchContent_Declare( + tomlplusplus + EXCLUDE_FROM_ALL + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tomlplusplus + ) + FetchContent_MakeAvailable(tomlplusplus) + endif() if (NOT YOSYS_WITHOUT_SLANG) + find_package(Boost QUIET COMPONENTS regex) + if(NOT Boost_FOUND) + FetchContent_Declare( + boost_regex + EXCLUDE_FROM_ALL + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/boost_regex + SOURCE_SUBDIR _no_build_ + ) + FetchContent_MakeAvailable(boost_regex) + endif() + set(SLANG_USE_MIMALLOC OFF) add_subdirectory(slang) # Headers autodetect based on but when version