3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-19 05:35:47 +00:00
yosys/kernel/CMakeLists.txt
Gabriel Somlo 45ecf0c419 CMake: cxxopts: support building with distro-packaged dependency
Many linux distros (e.g., Fedora) strongly discourage bundling or
vendoring dependencies. Many of them also include a `cxxopts-devel`
package. This patch adds support for un-vendoring `cxxopts` by:

   1. `libs/cxxopts` vendored submodule build conditional on
      `YOSYS_WITH_PKG_DEPS == OFF`

   2. use implicit `<cxxopts.hpp>` instead of explicit hard-coded
      path to vendored header file

   3. conditionally provide additional implicit include path to
      `cxxopts.hpp` and library dependency for `kernel/CMakeLists.txt`

Note that the current existing behavior remains the default.

Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
2026-07-12 10:51:00 -04:00

191 lines
3.2 KiB
CMake

yosys_version_file(version.cc.in version.cc)
configure_file(yosys_config.h.in yosys_config.h @ONLY)
set(cellhelp_sources)
foreach (library simlib simcells)
add_custom_command(
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py ${CMAKE_SOURCE_DIR}/techlibs/common/${library}.v
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${library}_help.inc
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py
${CMAKE_SOURCE_DIR}/techlibs/common/${library}.v
> ${CMAKE_CURRENT_BINARY_DIR}/${library}_help.inc
VERBATIM
)
list(APPEND cellhelp_sources ${CMAKE_CURRENT_BINARY_DIR}/${library}_help.inc)
endforeach()
yosys_core(kernel
binding.cc
binding.h
bitpattern.h
calc.cc
cellaigs.cc
cellaigs.h
celledges.cc
celledges.h
celltypes.h
compute_graph.h
compressor_tree.cc
compressor_tree.h
consteval.h
constids.inc
cost.cc
cost.h
drivertools.cc
drivertools.h
ff.cc
ff.h
ffinit.h
ffmerge.cc
ffmerge.h
fmt.cc
fmt.h
functional.cc
functional.h
gzip.cc
gzip.h
hashlib.h
io.cc
io.h
json.cc
json.h
log.cc
log.h
$<${YOSYS_ENABLE_VERIFIC}:log_compat.cc>
log_help.cc
log_help.h
macc.h
mem.cc
mem.h
modtools.h
newcelltypes.h
pattern.h
qcsat.cc
qcsat.h
register.cc
register.h
${cellhelp_sources}
rtlil_bufnorm.cc
rtlil.cc
rtlil.h
satgen.cc
satgen.h
scopeinfo.cc
scopeinfo.h
sexpr.cc
sexpr.h
sigtools.h
tclapi.cc
threading.cc
threading.h
timinginfo.h
topo_scc.h
utils.h
version.cc
yosys.cc
yosys_common.h
yosys_config.h
yosys.h
yw.cc
yw.h
INCLUDE_DIRS
$<$<NOT:$<BOOL:${YOSYS_WITH_PKG_DEPS}>>:${CMAKE_CURRENT_SOURCE_DIR}/libs/cxxopts/include/>
${pybind11_INCLUDE_DIR}
LIBRARIES
$<$<NOT:$<BOOL:${YOSYS_WITH_PKG_DEPS}>>:cxxopts>
$<${YOSYS_ENABLE_PLUGINS}:${Dlfcn_LIBRARIES}>
$<${YOSYS_ENABLE_ZLIB}:PkgConfig::zlib>
$<${YOSYS_ENABLE_READLINE}:PkgConfig::readline>
$<${YOSYS_ENABLE_EDITLINE}:PkgConfig::editline>
$<${YOSYS_ENABLE_TCL}:PkgConfig::tcl>
$<${YOSYS_ENABLE_PYTHON}:Python3::Module>
REQUIRES
bigint
ezsat
json11
sha1
PROVIDES
help
echo
license
tcl
shell
history
script
DATA_DIR
include/kernel
DATA_FILES
binding.h
bitpattern.h
cellaigs.h
celledges.h
celltypes.h
newcelltypes.h
consteval.h
constids.inc
cost.h
drivertools.h
ff.h
ffinit.h
ffmerge.h
fmt.h
gzip.h
hashlib.h
io.h
json.h
log.h
macc.h
modtools.h
mem.h
qcsat.h
register.h
rtlil.h
satgen.h
scopeinfo.h
sexpr.h
sigtools.h
threading.h
timinginfo.h
utils.h
yosys.h
yosys_common.h
yw.h
DATA_EXPLICIT
yosys_config.h ${CMAKE_CURRENT_BINARY_DIR}/yosys_config.h
ESSENTIAL
)
set(yosys_cc_definitions
"$<$<BOOL:${YOSYS_ABC_EXECUTABLE}>:ABCEXTERNAL=\"${YOSYS_ABC_EXECUTABLE}\">"
$<$<BOOL:${MINGW}>:YOSYS_WIN32_UNIX_DIR>
)
set_source_files_properties(yosys.cc PROPERTIES
COMPILE_DEFINITIONS "${yosys_cc_definitions}"
)
yosys_core(fstdata
fstdata.cc
fstdata.h
REQUIRES
fst
DATA_DIR
include/kernel
DATA_FILES
fstdata.h
)
if (NOT YOSYS_BUILD_PYTHON_ONLY)
yosys_core(driver
driver.cc
INCLUDE_DIRS
${pybind11_INCLUDE_DIR}
LIBRARIES
$<${YOSYS_ENABLE_READLINE}:PkgConfig::readline>
$<${YOSYS_ENABLE_EDITLINE}:PkgConfig::editline>
$<${YOSYS_ENABLE_TCL}:PkgConfig::tcl>
$<${YOSYS_ENABLE_PYTHON}:Python3::Python>
REQUIRES
essentials
BOOTSTRAP
)
endif()