3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-06-07 01:20:57 +00:00

CMake: add all Homebrew packages to root search path.

Homebrew doesn't provide a merged (FHS) prefix and tools installed from
it cannot be expected to appear on PATH. Furthermore, XCode provides
some tools and headers (Flex, Bison) which must not be used if
a Homebrew alternative is installed.
This commit is contained in:
Catherine 2026-06-05 15:54:14 +00:00
parent c9e3ae8c9a
commit d50dc9a461
2 changed files with 28 additions and 0 deletions

22
cmake/UseHomebrew.cmake Normal file
View file

@ -0,0 +1,22 @@
# Syntax:
#
# use_homebrew([ROOT <root>])
#
# Includes all packages installed in `<root>` (`/opt/homebrew/Cellar` if not specified)
# in `CMAKE_FIND_ROOT_PATH`.
#
function(use_homebrew)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "ROOT" "")
if (NOT arg_ROOT)
set(arg_ROOT /opt/homebrew/Cellar)
endif()
file(GLOB package_roots ${arg_ROOT}/*/*) # e.g. `/opt/homebrew/Cellar/bison/3.8.2/`
foreach (package_root ${package_roots})
if (IS_DIRECTORY ${package_root})
list(APPEND CMAKE_FIND_ROOT_PATH ${package_root})
endif()
endforeach()
return(PROPAGATE CMAKE_FIND_ROOT_PATH)
endfunction()