Modify the selection logic for `CMD_VERILATOR_ROOT` in `verilator.cmake`.
When using a Verilator distribution that is not installed from a package manager or compiled from source, such as the one provided by [oss-cad-suite](https://github.com/YosysHQ/oss-cad-suite-build), the output of `verilator -V` can be as follows:
```bash
Summary of configuration:
Compiled in defaults if not in environment:
SYSTEMC =
SYSTEMC_ARCH =
SYSTEMC_INCLUDE =
SYSTEMC_LIBDIR =
VERILATOR_ROOT = /yosyshq/share/verilator
SystemC system-wide = 0
Environment:
MAKE =
PERL =
PYTHON3 =
SYSTEMC =
SYSTEMC_ARCH =
SYSTEMC_INCLUDE =
SYSTEMC_LIBDIR =
VERILATOR_BIN =
VERILATOR_ROOT = /opt/oss-cad-suite/share/verilator
```
This output provides two `VERILATOR_ROOT` paths. The one under the `Environment` section is the intended path for this setup.
The previous selection logic would incorrectly choose the first `VERILATOR_ROOT` it found, which was the incorrect one from the `Compiled in defaults` section.
This patch updates the logic to prioritize the `VERILATOR_ROOT` from the `Environment` section. It will only fall back to the `Compiled in defaults` path if the environment one is not available.
picker will find VERILATOR_ROOT by using Verilator 5.026 2024-06-15 rev v5.026
Copyright 2003-2024 by Wilson Snyder. Verilator is free software; you can
redistribute it and/or modify the Verilator internals under the terms of
either the GNU Lesser General Public License Version 3 or the Perl Artistic
License Version 2.0.
See https://verilator.org for documentation
Summary of configuration:
Compiled in defaults if not in environment:
SYSTEMC =
SYSTEMC_ARCH =
SYSTEMC_INCLUDE =
SYSTEMC_LIBDIR =
VERILATOR_ROOT = /opt/verilator5/share/verilator
SystemC system-wide = 0
Environment:
MAKE =
PERL =
SYSTEMC =
SYSTEMC_ARCH =
SYSTEMC_INCLUDE =
SYSTEMC_LIBDIR =
VERILATOR_BIN =
VERILATOR_ROOT = /opt/verilator5/share/verilator
Supported features (compiled-in or forced by environment):
COROUTINES = 1
SYSTEMC = command