3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-06-06 09:00:54 +00:00
yosys/cmake/UseHomebrew.cmake
Catherine d50dc9a461 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.
2026-06-05 17:58:29 +00:00

22 lines
601 B
CMake

# 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()