From 81fafe237e51a1f21e6cea5288beb940cc72f5b3 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Sat, 5 Sep 2026 06:47:15 -0700 Subject: [PATCH] Fix CMake to call Verilator perl wrapper (#8269) (#8270) --- docs/CONTRIBUTORS | 1 + docs/guide/install.rst | 2 +- verilator-config.cmake.in | 15 +++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index c6fef7c1d..cd20c437b 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -74,6 +74,7 @@ Dominick Grochowina Don Williamson Dragon-Git Drew Ranck +Drew Risinger Drew Taussig Driss Hafdi Edgar E. Iglesias diff --git a/docs/guide/install.rst b/docs/guide/install.rst index 99d8f66a5..479703861 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -174,7 +174,7 @@ once, after ``configure``: # Install dependencies sudo apt install python3-pip - # Create Python virutal environment in .venv: + # Create Python virtual environment in .venv: make venv # Or alternatively, to put it somewhere else: diff --git a/verilator-config.cmake.in b/verilator-config.cmake.in index 6538b57c6..33f09a03a 100644 --- a/verilator-config.cmake.in +++ b/verilator-config.cmake.in @@ -21,6 +21,8 @@ cmake_minimum_required(VERSION 3.19) +find_package(Perl REQUIRED) + # Prefer VERILATOR_ROOT from environment if(DEFINED ENV{VERILATOR_ROOT}) set(VERILATOR_ROOT "$ENV{VERILATOR_ROOT}" CACHE PATH "VERILATOR_ROOT") @@ -30,7 +32,7 @@ set(VERILATOR_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "VERILATOR_ROOT") find_program( VERILATOR_BIN - NAMES verilator_bin verilator_bin.exe + NAMES verilator HINTS ${VERILATOR_ROOT}/bin ENV VERILATOR_ROOT NO_CMAKE_PATH @@ -38,6 +40,11 @@ find_program( NO_CMAKE_SYSTEM_PATH ) +# The installed wrapper under bin/verilator is a Perl script. Execute it via +# Perl explicitly so CMake can launch it reliably on Windows and other hosts +# where direct execution of the wrapper is not supported. +set(VERILATOR_BIN_COMMAND "${PERL_EXECUTABLE}" "${VERILATOR_BIN}") + if(NOT VERILATOR_ROOT) message( FATAL_ERROR @@ -46,7 +53,7 @@ if(NOT VERILATOR_ROOT) endif() if(NOT VERILATOR_BIN) - message(FATAL_ERROR "Cannot find verilator_bin excecutable.") + message(FATAL_ERROR "Cannot find verilator executable.") endif() set(verilator_FOUND 1) @@ -398,7 +405,7 @@ function(verilate TARGET) -E env "VERILATOR_ROOT=${VERILATOR_ROOT}" - "${VERILATOR_BIN}" + ${VERILATOR_BIN_COMMAND} --compiler ${COMPILER} --prefix @@ -860,7 +867,7 @@ endfunction() function(verilator_generate_key OUTPUT_VARIABLE) execute_process( - COMMAND ${VERILATOR_BIN} --generate-key + COMMAND ${VERILATOR_BIN_COMMAND} --generate-key OUTPUT_VARIABLE KEY_VAL RESULT_VARIABLE KEY_RET )