Files
yosys/cmake/FindPyosysEnv.cmake
tangxifan 02dc5a82d7 [core] add a cmake option to disable unit test during compilation; Use cmake_current_source for submodule integration
[core] debug yosys version extraction

[core] debug

[core] now cache the cmake source dir

[core] debug

[core] debug kernel dependencies

[core] debug common include directories

[core] debug

[core] debug simlib_help.inc

[core] debug pmgen py path in cmake

[core] syntax

[core] debug flex source

[core] restore

[core] debug executable output as it now shows linking to .

[core] debug yosys-abc directory

[core] debug cmake share directory

[core] debug yosys abc

[core] restore shared directory location as yosys requires fixed location

[core] rework link target to yosys sub dir under build

[core] fixed the bug on yosys-config.install location for install

[core] cmake syntax

[core] correct the location for share directory

[core] debug

[core] debug

[core] debug

[core] enforce internal attributes; rename the YOSYS_ENABLE_UNIT_TESTS; use YOSYS_CMAKE_BINARY_DIR for all

[core] apply review comments

[core] rename

[core] change all the CMAKE_BINARY_DIR to YOSYS_CMAKE_BINARY_DIR

[core] replace CMAKE_SOURCE_DIR to YOSYS_CMAKE_SOURCE_DIR
2026-08-21 12:09:04 -07:00

45 lines
1.4 KiB
CMake

# We need a *third* `FindPython`-style call in this codebase because the host
# `Python3_EXECUTABLE` may not have pybind11 and cxxheaderparser installed,
# and installing it can be onerous. To work around this problem we try to detect
# whether the host interpreter has the necessary dependencies first, and if it
# does not, fall back to using `uv`.
foreach (strategy virtualenv host uv fail)
if (strategy STREQUAL "virtualenv")
set(PyosysEnv_PYTHON $ENV{VIRTUAL_ENV}/bin/python)
elseif (strategy STREQUAL "host")
set(PyosysEnv_PYTHON ${Python3_EXECUTABLE})
elseif (strategy STREQUAL "uv")
set(PyosysEnv_PYTHON uv run --no-project --with pybind11>3,<4 --with cxxheaderparser python)
else()
set(PyosysEnv_PYTHON)
break()
endif()
execute_process(
COMMAND ${PyosysEnv_PYTHON} -m pybind11 --includes
RESULT_VARIABLE result
OUTPUT_VARIABLE output
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if (result EQUAL 0)
string(REGEX REPLACE " ?-I" ";" pybind11_INCLUDE_DIR "${output}")
list(FILTER pybind11_INCLUDE_DIR INCLUDE REGEX "/pybind11/")
execute_process(
COMMAND ${PyosysEnv_PYTHON} ${YOSYS_CMAKE_SOURCE_DIR}/pyosys/generator.py --help
RESULT_VARIABLE result
OUTPUT_QUIET
ERROR_QUIET
)
if (result EQUAL 0)
break()
endif()
endif()
endforeach()
find_package_handle_standard_args(PyosysEnv
REQUIRED_VARS PyosysEnv_PYTHON pybind11_INCLUDE_DIR
)