Skip to content

cmake: fix verilator_build() version matching and align VERILATOR_ROOT with verilator() - #248

Merged
benoitdenkinger merged 2 commits into
HEP-SoC:masterfrom
benoitdenkinger:verilator_build_update
Aug 27, 2026
Merged

benoitdenkinger merged 2 commits into
HEP-SoC:masterfrom
benoitdenkinger:verilator_build_update

Conversation

@benoitdenkinger

Copy link
Copy Markdown
Member

Summary

Fixes two independent bugs in verilator_build() that made version checking unreliable, and unifies how VERILATOR_ROOT is derived/consumed across verilator_build(), verilator(), and the internal verilator/CMakeLists.txt project, which previously used inconsistent names and derivations (VERILATOR_HOME vs VERILATOR_ROOT).

Changes

verilator_build.cmake

  • cmake_parse_arguments was called without ARGN (bug introduced in fb77394), so every keyword argument passed to verilator_build() (VERILATOR_TAG, INSTALL_DIR, EXACT_VERSION, ...) was silently discarded. Now forwards ARGN again.
  • EXACT_VERSION matching switched from VERSION_EQUAL to STREQUAL/IN_LIST: VERSION_EQUAL could wrongly treat two different commit hashes as equal, and doesn't account for verilator-config-version.cmake sometimes keeping a leading v in PACKAGE_VERSION and sometimes not, depending on the Verilator release being built. The candidate list now accepts either spelling.
  • Fixed a stale cached VERILATOR_ROOT/verilator_DIR overriding HINTS after a fresh build (via unset(verilator_DIR CACHE) + NO_DEFAULT_PATH), which caused the post-build version check to fail even though the build had succeeded.
  • VERILATOR_TAG is now optional: when omitted, it resolves to the master branch HEAD and installs under a head subdirectory instead of an empty-named one.

verilator.cmake

  • Renamed VERILATOR_HOME to VERILATOR_ROOT and fixed its derivation (it was previously derived incorrectly from verilator_DIR), aligning it with verilator_build() and with the variable name Verilator's own generated verilator-config.cmake expects.

verilator/CMakeLists.txt

  • Simplified find_package(verilator) call (HINTS no longer needed now that VERILATOR_ROOT is exported as an env var beforehand) and clarified in comments why VERILATOR_ROOT must be re-exported as an OS environment variable at this configure step specifically (older Verilator versions need it as an env var, and this file's execute_process/configure step isn't covered by the env VERILATOR_ROOT=... wrapping done around the later make build step).

Benoit Denkinger added 2 commits August 27, 2026 13:15
…with verilator()

- verilator_build(): cmake_parse_arguments was missing ARGN, so every
  keyword argument was silently discarded
- EXACT_VERSION check now uses STREQUAL/IN_LIST instead of VERSION_EQUAL,
  which could wrongly consider two different commit hashes equal
- fixed a stale cached VERILATOR_ROOT overriding HINTS after a fresh
  build, causing the version check to fail despite a successful build
- verilator(): renamed VERILATOR_HOME to VERILATOR_ROOT and fixed its
  derivation, aligning it with verilator_build() and Verilator itself
@benoitdenkinger
benoitdenkinger merged commit d5836e3 into HEP-SoC:master Aug 27, 2026
7 checks passed
@benoitdenkinger
benoitdenkinger deleted the verilator_build_update branch August 28, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants