mirror of https://github.com/YosysHQ/yosys.git
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:
parent
c9e3ae8c9a
commit
d50dc9a461
|
|
@ -29,6 +29,7 @@ include(YosysLinkTarget)
|
|||
include(YosysAbc)
|
||||
include(YosysAbcSubmodule)
|
||||
include(YosysVerific)
|
||||
include(UseHomebrew)
|
||||
|
||||
# Build options.
|
||||
set(YOSYS_COMPILER_LAUNCHER "" CACHE STRING "Compiler launcher (ccache, sccache)")
|
||||
|
|
@ -162,6 +163,11 @@ if (MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSIO
|
|||
endif()
|
||||
|
||||
# Required dependencies.
|
||||
if (APPLE)
|
||||
# In practice, we can't expect paths to Homebrew packages to be configured.
|
||||
use_homebrew()
|
||||
endif()
|
||||
|
||||
find_package(FLEX)
|
||||
set_package_properties(FLEX PROPERTIES
|
||||
URL "https://github.com/westes/flex"
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
Loading…
Reference in New Issue