3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-06-06 00:50:57 +00:00
yosys/pyosys/CMakeLists.txt
Catherine afc0e78d11 Update top-level Python project for CMake compatibility.
This commit reimplements the (no longer recommended) setuptools based
build system using a standards-based in-tree PEP517 build backend.
The implementation is partially based on
  https://codeberg.org/ziglang/zig-pypi/src/branch/main/make_wheels.py
which is licensed under BSD-0-clause.

It also adds a new option `YOSYS_BUILD_PYTHON_ONLY` that is available
only if the binary or the library aren't going to be installed, which
turns off these targets entirely, as well as some dependent ones
(e.g. tests).

Co-authored-by: Mohamed Gaber <me@donn.website>
2026-06-03 09:03:23 +00:00

29 lines
744 B
CMake

add_custom_command(
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/generator.py
${CMAKE_CURRENT_SOURCE_DIR}/wrappers_tpl.cc
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/wrappers.cc
${CMAKE_CURRENT_BINARY_DIR}/wrappers.inc.cc
DEPFILE
${CMAKE_CURRENT_BINARY_DIR}/wrappers.cc.d
COMMAND
${CMAKE_COMMAND} -E env
CCACHE=${CMAKE_CXX_COMPILER_LAUNCHER}
CXX=${CMAKE_CXX_COMPILER}
CXX_STD=c++${CMAKE_CXX_STANDARD}
-- ${PyosysEnv_PYTHON}
${CMAKE_CURRENT_SOURCE_DIR}/generator.py
${CMAKE_CURRENT_BINARY_DIR}/wrappers.cc
--build-dir ${CMAKE_BINARY_DIR}
VERBATIM
COMMENT "Generating Python wrappers"
)
yosys_core(pyosys
wrappers.cc
INCLUDE_DIRS
${pybind11_INCLUDE_DIR}
LIBRARIES
$<${YOSYS_ENABLE_PYTHON}:Python3::Module>
ESSENTIAL
)