mirror of
https://github.com/YosysHQ/yosys
synced 2026-08-15 10:25:29 +00:00
The current version of UseHomebrew defaults to /opt/homebrew/Cellar and prioritizes it over anything currently existing in PATH. This has two issues: - On x86_64 installations of Homebrew (including when emulating on ARM), the path is /usr/local/Cellar - When building in a `nix develop` environment, the homebrew versions take priority, complicating testing This addresses this issue by using the output of `brew --prefix`, doing nothing if brew is not in `PATH`. Additionally, CMakeLists.txt was updated such that if YOSYS_ENABLE_HOMEBREW is defined as OFF, using Homebrew is skipped entirely.
37 lines
950 B
CMake
37 lines
950 B
CMake
# Syntax:
|
|
#
|
|
# use_homebrew([ROOT <root>])
|
|
#
|
|
# Includes all packages installed in `<root>` (output of brew --prefix if not
|
|
# specified) in `CMAKE_FIND_ROOT_PATH`.
|
|
#
|
|
function(use_homebrew)
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg "" "ROOT" "")
|
|
if (NOT arg_ROOT)
|
|
execute_process(
|
|
COMMAND brew --prefix
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
RESULT_VARIABLE brew_prefix_result
|
|
OUTPUT_VARIABLE brew_prefix_out
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
ERROR_QUIET
|
|
)
|
|
if (${brew_prefix_result} EQUAL 0)
|
|
set (arg_ROOT "${brew_prefix_out}/Cellar")
|
|
endif()
|
|
endif()
|
|
|
|
if (NOT arg_ROOT)
|
|
# unset and no brew binary available
|
|
return()
|
|
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()
|