Basic cmake build support on Windows.

This commit is contained in:
Kuba Ober 2019-12-29 23:22:52 -05:00
parent 7bbce51f7b
commit 1b8a2e9a29
15 changed files with 1814 additions and 13 deletions

View File

@ -3,3 +3,4 @@ exclude_paths:
- '.github/**'
- 'ci/build_verilator.sh'
- 'include/vltstd/**'
- 'platform/win32/dirent.h'

View File

@ -23,14 +23,20 @@ cache:
- $VERILATOR_CACHE
before_install:
# Chocolatey packages needed for building
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install activeperl ninja winflexbison3 ; fi
# Perl modules needed for testing
- yes yes | sudo cpan -fi Unix::Processors Parallel::Forker Bit::Vector
- sudo apt-get install gdb gtkwave
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then yes yes | sudo cpan -fi Unix::Processors Parallel::Forker Bit::Vector ; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then sudo apt-get install gdb gtkwave ; fi
before_script:
- bash -x ci/build_vcddiff.sh
- bash -x ci/build_verilator.sh
- bash -x ci/build_cmake.sh
after_script:
- ccache -s
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then ccache -s ; fi
stages:
- "Build Verilator"
@ -41,22 +47,31 @@ jobs:
- if: type != cron
stage: "Build Verilator"
name: Build Verilator
os: linux
compiler: gcc
script: echo "Done building Verilator"
# Non-cron build will just run on whatever linux flavor we get
- if: type != cron
stage: "Build Verilator"
name: Build Verilator
os: windows
script: echo "Done building Verilator"
# Non-cron build will just run on whatever linux flavor we get, and on windows
- if: type != cron
stage: test
name: Dist test
os: linux
compiler: gcc
script: ci/test.sh dist
- if: type != cron
stage: test
name: Vlt test
os: linux
compiler: gcc
script: ci/test.sh vlt
- if: type != cron
stage: test
name: Vltmt test
os: linux
compiler: gcc
script: ci/test.sh vltmt
# Cron builds try different OS/compiler combinations

36
CMakeLists.txt Normal file
View File

@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW) # Use MSVC_RUNTIME_LIBRARY to select the runtime
# The unity builds are supported if you use cmake 3.16+.
# Synopsis:
# cmake ... -DCMAKE_UNITY_BUILD=TRUE ...
project(Verilator
VERSION 4.025.99
HOMEPAGE_URL https://verilator.org
LANGUAGES CXX
)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(CheckStructHasMember)
if (WIN32)
# Check for Chcocolatey winflexbison
# See https://github.com/lexxmark/winflexbison/releases
set(WIN_FLEX_BISON C:/ProgramData/chocolatey/lib/winflexbison3/tools)
if (EXISTS ${WIN_FLEX_BISON})
list(APPEND CMAKE_PREFIX_PATH ${WIN_FLEX_BISON})
endif()
endif()
find_package(Perl REQUIRED)
find_package(BISON)
find_package(FLEX)
check_struct_has_member("struct stat.st_mtim" tv_nsec sys/stat.h HAVE_STAT_NSEC LANGUAGE CXX)
set(PACKAGE_NAME ${PROJECT_NAME})
set(PACKAGE_VERSION ${PROJECT_VERSION})
add_subdirectory(src)

View File

@ -131,6 +131,8 @@ DISTFILES_INC = $(INFOS) .gitignore \
README.adoc \
verilator-config.cmake.in \
verilator-config-version.cmake.in \
CMakeLists.txt \
src/CMakeLists.txt \
bin/verilator \
bin/verilator_coverage \
bin/verilator_difftree \
@ -153,6 +155,8 @@ DISTFILES_INC = $(INFOS) .gitignore \
include/.*ignore \
include/gtkwave/*.[chv]* \
include/vltstd/*.[chv]* \
platform/win32/dirent.h \
platform/win32/LICENSE.dirent.txt \
.*attributes */.*attributes */*/.*attributes \
src/.*ignore src/*.in src/*.cpp src/*.[chly] \
src/astgen src/bisonpre src/*fix src/cppcheck_filtered \

37
ci/build_cmake.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
# DESCRIPTION: Verilator: Travis CI cmake build script
#
# Copyright 2019 by Todd Strader. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
set -e
if [ "$TRAVIS_OS_NAME" != "windows" ]; then
# This script is currently only used on Windows
exit 0
fi
if [ -z "${VERILATOR_ROOT}" ]; then
echo "VERILATOR_ROOT not set"
exit -1
fi
echo "Building Verilator"
# Unsure why Travis monkies with the capitalization of the stage name, but it does
if [[ -n ${TRAVIS_BUILD_STAGE_NAME} && \
${TRAVIS_BUILD_STAGE_NAME} != "Build verilator" ]]; then
echo "WARNING: Building Verilator in Travis build stage other than \"Build verilator\": ${TRAVIS_BUILD_STAGE_NAME}"
fi
VERILATOR_BUILD="${VERILATOR_ROOT}/../build-verilator"
cmake \
-G Ninja \
-S "${VERILATOR_ROOT}" \
-B "${VERILATOR_BUILD}" \
-DCMAKE_PROGRAM_PATH="C:/Perl64/bin"
cmake --build "${VERILATOR_BUILD}"

View File

@ -14,5 +14,13 @@ TMP_DIR=$(mktemp -d)
git -C ${TMP_DIR} clone https://github.com/veripool/vcddiff
VCDDIFF_DIR=${TMP_DIR}/vcddiff
git -C ${VCDDIFF_DIR} checkout 5112f88b7ba8818dce9dfb72619e64a1fc19542c
make -C ${VCDDIFF_DIR}
sudo cp ${VCDDIFF_DIR}/vcddiff /usr/local/bin
case $TRAVIS_OS_NAME in
linux | osx)
make -C ${VCDDIFF_DIR}
sudo cp ${VCDDIFF_DIR}/vcddiff /usr/local/bin
;;
windows)
;;
esac

View File

@ -1,5 +1,5 @@
#!/bin/bash
# DESCRIPTION: Verilator: Travis CI build script
# DESCRIPTION: Verilator: Travis CI autotools build script
#
# Copyright 2019 by Todd Strader. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
@ -16,6 +16,11 @@
# not be used as the script relies on Git revisions for caching.
set -e
if [ "$TRAVIS_OS_NAME" = "windows" ]; then
# This script is currently only used on unices
exit 0
fi
if [ -z "${VERILATOR_NUM_JOBS}" ]; then
VERILATOR_NUM_JOBS=$(nproc)
fi

View File

@ -24,8 +24,11 @@ If this works, skip down to <<Running Verilator>>.
=== Git
Alternatively, installing Verilator with Git provides the most flexibility.
For additional options and details see the additional sections below. In
brief:
For additional options and details see the additional sections below.
==== Unix Quick-start
In brief:
// Also update README
....
@ -56,6 +59,30 @@ sudo make install
If this works, skip down to <<Running Verilator>>.
==== Windows Quick-start
Cygwin builds should work similar to Unix builds. Cmake-based building is
the long-term goal, and while the `verilator` binary can be currently built,
the **cmake-based Windows builds are experimental and currently exempt
from test suite coverage**. Cmake-based installation hasn't been implemented
yet and has to be done manually. Assuming you have the
https://chocolatey.org[Chocolatey] package manager installed, as well as a
build environment (MinGW or MSVS):
....
:: Prerequisites
choco install activeperl ninja winflexbison3 git
:: Build
git clone https://git.veripool.org/git/verilator verilator
cmake -G Ninja -S verilator -B verilator-build
cmake --build verilator-build --config Release
....
Verilator is built, statically linked, under `./verilator-build/bin`. The
binary itself has no other runtime dependencies, but it's expected to be
invoked via the `bin/verilator` Perl wrapper.
== Detailed Build Instructions
This section describes details of the build process, and assumes you are
@ -65,14 +92,16 @@ Linux distribution, see instead <<Install From a Package Manager>>.
=== OS Requirements
Verilator is developed and has primary testing on Ubuntu. Versions have
also built on Redhat Linux, Apple OS-X, HPUX and Solaris. It should run
also built on Redhat Linux, Apple macOS, HPUX and Solaris. It should run
with minor porting on any GNU/Linux-ish platform. Verilator also works on
Windows under Cygwin, and Windows under MinGW (gcc -mno-cygwin). Verilated
output (not Verilator itself) compiles under all the options above, plus
MSVC++.
Windows - natively using either MinGW (`gcc -mno-cygwin`) or MS Visual
C++ as the compiler, and under Cygwin. Verilated output also compiles under
all the options above.
=== Install Prerequisites
==== Linux
To build Verilator you will need to install some standard packages:
sudo apt-get install git
@ -93,6 +122,29 @@ Those developing Verilator may also want these (see internals.adoc):
cpan install Pod::Perldoc
cpan install Unix::Processors
==== Windows
It's most convenient to install all the prerequisites using the
https://chocolatey.org[Chocolatey] package manager. You can install it
from an administrative powershell window as follows:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Verilator can be built natively, i.e. without using Cygwin nor MSYS,
using either MS Visual Studio 2017 or later, or MinGW 7.3 or later. Those
are easily installed using Chocolatey:
....
:: Only one needed
choco install visualstudio2019buildtools
:: or
choco install mingw
....
Other prerequisites are Git, Perl, CMake, and Ninja:
choco install activeperl git cmake ninja
==== Install SystemC
If you will be using SystemC (vs straight C++ output), download
@ -129,6 +181,21 @@ Enter the checkout and determine what version/branch to use:
#git checkout stable # Use most recent release
#git checkout v{version} # Switch to specified release version
=== Build Introduction
There are currently two ways to build Verilator:
. The autoconf-based build is the primary supported build.
. The CMake-based build is available on Windows. Neither installation
nor tests are implemented in the cmake files yet, thus manual installation
and testing is necessary if desired.
+
The cmake build is currently only tested on Windows, and is fairly simple once
the prerequisites are in place. See <<Windows Quick-start>> for details.
The remaining build steps below apply to the autoconf-based build.
=== Auto Configure
Create the configuration script:
@ -280,6 +347,7 @@ Some relevant files and directories in this package are as follows:
include/verilated*.cpp => Global routines to link into your simulator
include/verilated*.h => Global headers
include/verilated.mk => Common Makefile
platform/win32 => Windows-specific implementations of missing Posix functionality
src/ => Translator source code
test_regress => Internal tests

View File

@ -971,6 +971,18 @@ function in `src/verilator.cpp`.
To get your pass to build you'll need to add its binary filename to the
list in `src/Makefile_obj.in` and reconfigure.
== IDE-based Development
Any IDE supporting autoconf or cmake projects can be used for development.
It's worth noting that https://www.qt.io/development-tools[Qt Creator] has
excellent cmake support and can be used to directly open the root directory
`CMakeLists.txt` for development and debugging. It also provides clang-format
support for the `.clang-format` bundled with verilator's source code.
Qt Creator will pick up clang-format from an installed LLVM package on all
platforms it supports. E.g. on Windows, `choco install llvm` is all it takes to
get clang-format.
== Distribution
Copyright 2008-2019 by Wilson Snyder. Verilator is free software; you can

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 1998-2019 Toni Ronkko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1160
platform/win32/dirent.h Normal file

File diff suppressed because it is too large Load Diff

1
src/.gitignore vendored
View File

@ -6,3 +6,4 @@ Makefile_obj
.objcache*
obj_*
config_rev.h
CMakeLists.txt.user

431
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,431 @@
#
# Utilities
macro (addBuildType sourceConfig newConfig)
get_cmake_property(variableNames VARIABLES)
foreach (variableName ${variableNames})
if (variableName MATCHES "^CMAKE_.*_${sourceConfig}(|_.*)$")
string(REPLACE _${sourceConfig} _${newConfig} newVariableName ${variableName})
set(${newVariableName} ${${variableName}})
mark_as_advanced(${newVariableName})
message(DEBUG " Propagating ${variableName} to ${newVariableName} = ${${newVariableName}}")
endif()
endforeach()
endmacro()
#
# Sources and headers for the verilator binary
set(HEADERS
V3Active.h
V3ActiveTop.h
V3Assert.h
V3AssertPre.h
V3Ast.h
V3AstConstOnly.h
V3AstNodes.h
V3Begin.h
V3Branch.h
V3Broken.h
V3Case.h
V3Cast.h
V3CCtors.h
V3Cdc.h
V3Changed.h
V3Clean.h
V3Clock.h
V3Combine.h
V3Config.h
V3Const.h
V3Coverage.h
V3CoverageJoin.h
V3Dead.h
V3Delayed.h
V3Depth.h
V3DepthBlock.h
V3Descope.h
V3EmitC.h
V3EmitCBase.h
V3EmitCMake.h
V3EmitMk.h
V3EmitV.h
V3EmitXml.h
V3Error.h
V3Expand.h
V3File.h
V3FileLine.h
V3Gate.h
V3GenClk.h
V3Global.h
V3Graph.h
V3GraphAlg.h
V3GraphDfa.h
V3GraphPathChecker.h
V3GraphStream.h
V3Hashed.h
V3Inline.h
V3Inst.h
V3InstrCount.h
V3LangCode.h
V3LanguageWords.h
V3Life.h
V3LifePost.h
V3LinkCells.h
V3LinkDot.h
V3LinkJump.h
V3LinkLevel.h
V3LinkLValue.h
V3LinkParse.h
V3LinkResolve.h
V3List.h
V3Localize.h
V3Name.h
V3Number.h
V3Options.h
V3Order.h
V3OrderGraph.h
V3Os.h
V3Param.h
V3Parse.h
V3ParseImp.h
V3ParseSym.h
V3Partition.h
V3PartitionGraph.h
V3PreLex.h
V3Premit.h
V3PreProc.h
V3PreShell.h
V3ProtectLib.h
V3Reloop.h
V3Scope.h
V3Scoreboard.h
V3SenTree.h
V3Simulate.h
V3Slice.h
V3Split.h
V3SplitAs.h
V3Stats.h
V3String.h
V3Subst.h
V3SymTable.h
V3Table.h
V3Task.h
V3Trace.h
V3TraceDecl.h
V3Tristate.h
V3TSP.h
V3Undriven.h
V3Unknown.h
V3Unroll.h
V3Width.h
V3WidthCommit.h
VlcBucket.h
VlcOptions.h
VlcPoint.h
VlcSource.h
VlcTest.h
VlcTop.h
)
set(COMMON_SOURCES
Verilator.cpp
V3Active.cpp
V3ActiveTop.cpp
V3Assert.cpp
V3AssertPre.cpp
V3Ast.cpp
V3AstNodes.cpp
V3Begin.cpp
V3Branch.cpp
V3Broken.cpp
V3Case.cpp
V3Cast.cpp
V3CCtors.cpp
V3Cdc.cpp
V3Changed.cpp
V3Clean.cpp
V3Clock.cpp
V3Combine.cpp
V3Config.cpp
V3Coverage.cpp
V3CoverageJoin.cpp
V3Dead.cpp
V3Delayed.cpp
V3Depth.cpp
V3DepthBlock.cpp
V3Descope.cpp
V3EmitC.cpp
V3EmitCInlines.cpp
V3EmitCMake.cpp
V3EmitCSyms.cpp
V3EmitMk.cpp
V3EmitV.cpp
V3EmitXml.cpp
V3Error.cpp
V3Expand.cpp
V3File.cpp
V3FileLine.cpp
V3Gate.cpp
V3GenClk.cpp
V3Graph.cpp
V3GraphAcyc.cpp
V3GraphAlg.cpp
V3GraphDfa.cpp
V3GraphPathChecker.cpp
V3GraphTest.cpp
V3Hashed.cpp
V3Inline.cpp
V3Inst.cpp
V3InstrCount.cpp
V3Life.cpp
V3LifePost.cpp
V3LinkCells.cpp
V3LinkDot.cpp
V3LinkJump.cpp
V3LinkLevel.cpp
V3LinkLValue.cpp
V3LinkParse.cpp
V3LinkResolve.cpp
V3Localize.cpp
V3Name.cpp
V3Number.cpp
V3Options.cpp
V3Order.cpp
V3Os.cpp
V3Param.cpp
V3ParseGrammar.cpp
V3ParseImp.cpp
V3ParseLex.cpp
V3Partition.cpp
V3Premit.cpp
V3PreProc.cpp
V3PreShell.cpp
V3ProtectLib.cpp
V3Reloop.cpp
V3Scope.cpp
V3Scoreboard.cpp
V3Slice.cpp
V3Split.cpp
V3SplitAs.cpp
V3SplitAs.h
V3Stats.cpp
V3StatsReport.cpp
V3String.cpp
V3Subst.cpp
V3Table.cpp
V3Task.cpp
V3Trace.cpp
V3TraceDecl.cpp
V3Tristate.cpp
V3TSP.cpp
V3Undriven.cpp
V3Unknown.cpp
V3Unroll.cpp
V3Width.cpp
V3WidthSel.cpp
)
SET(COVERAGE_SOURCES
VlcMain.cpp
)
set_source_files_properties(
V3Broken.cpp
V3ParseGrammar.cpp
V3ParseLex.cpp
V3Stats.cpp
PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE
)
if (MINGW)
# Mingw hits file size limits
set_source_files_properties(
V3Order.cpp
V3Partition.cpp
PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE
)
endif()
# Note about tests:
# VlcMain.cpp #includes the following files:
# V3Error.cpp, V3String.cpp, V3Os.cpp and VlcTop.cpp
# V3Number_test.cpp #includes the following files:
# V3FileLine.cpp
#
# Generated sources and headers for the verilator binary
set(srcdir ${CMAKE_CURRENT_SOURCE_DIR})
file(TO_NATIVE_PATH ${srcdir}/astgen ASTGEN)
file(TO_NATIVE_PATH ${srcdir}/bisonpre BISONPRE)
file(TO_NATIVE_PATH ${srcdir}/flexfix FLEXFIX)
file(TO_NATIVE_PATH ${srcdir}/../bin/verilator_includer VERILATOR_INCLUDER)
file(TO_NATIVE_PATH ${srcdir}/vlcovgen VLCOVGEN)
file(TO_NATIVE_PATH ${srcdir}/config_rev.pl CONFIG_REV)
configure_file(config_build.h.in config_build.h @ONLY)
add_custom_command(
OUTPUT V3Ast__gen_classes.h
DEPENDS ./V3Ast.h ./V3AstNodes.h ${ASTGEN}
COMMAND ${PERL_EXECUTABLE} ARGS
${ASTGEN} -I"${srcdir}" --classes
)
list(APPEND GENERATED_FILES V3Ast__gen_classes.h)
# Output used directly by the `verilator` target
set(verilog_y "${srcdir}/verilog.y" )
set(BISON_V3ParseBison_OUTPUT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/V3ParseBison.h")
set(BISON_V3ParseBison_OUTPUT_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/V3ParseBison.c")
add_custom_command(
OUTPUT V3ParseBison.c V3ParseBison.h
MAIN_DEPENDENCY ./verilog.y
DEPENDS ${BISONPRE}
COMMAND ${PERL_EXECUTABLE} ARGS
${BISONPRE} --yacc "${BISON_EXECUTABLE}" -d -v
-o "${BISON_V3ParseBison_OUTPUT_SOURCE}" "${verilog_y}"
)
list(APPEND GENERATED_FILES V3ParseBison.c V3ParseBison.h)
# Output used directly by the `verilator` target
set(verilog_l "${srcdir}/verilog.l")
set(FLEX_V3Lexer_pregen_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/V3Lexer_pregen.yy.cpp")
add_custom_command(
OUTPUT V3Lexer_pregen.yy.cpp
MAIN_DEPENDENCY ./verilog.l
DEPENDS ${BISON_V3ParseBison_OUTPUT_HEADER} ${HEADERS}
COMMAND ${FLEX_EXECUTABLE} ARGS
${LFLAGS} -o "${FLEX_V3Lexer_pregen_OUTPUTS}" "${verilog_l}"
)
# Output used by another command
set(FLEX_V3Lexer_OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/V3Lexer.yy.cpp)
add_custom_command(
OUTPUT V3Lexer.yy.cpp
MAIN_DEPENDENCY ${FLEX_V3Lexer_pregen_OUTPUTS}
DEPENDS ${FLEXFIX}
COMMAND ${PERL_EXECUTABLE} ARGS
${FLEXFIX} V3Lexer < "$<SHELL_PATH:${FLEX_V3Lexer_pregen_OUTPUTS}>" > "$<SHELL_PATH:${FLEX_V3Lexer_OUTPUTS}>"
)
add_custom_target(V3Lexer_yy_cpp DEPENDS ${FLEX_V3Lexer_OUTPUTS})
# Output included by another source file
set(FLEX_V3PreLex_pregen_OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/V3PreLex_pregen.yy.cpp)
add_custom_command(
OUTPUT V3PreLex_pregen.yy.cpp
MAIN_DEPENDENCY ./V3PreLex.l
DEPENDS ${HEADERS}
COMMAND ${FLEX_EXECUTABLE} ARGS
${LFLAGS} -o "${FLEX_V3PreLex_pregen_OUTPUTS}" "${srcdir}/V3Prelex.l"
)
# Output used by another command
set(FLEX_V3PreLex_OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/V3PreLex.yy.cpp)
add_custom_command(
OUTPUT V3PreLex.yy.cpp
MAIN_DEPENDENCY ${FLEX_V3PreLex_pregen_OUTPUTS}
DEPENDS ${FLEXFIX}
COMMAND ${PERL_EXECUTABLE} ARGS
${FLEXFIX} V3PreLex < "$<SHELL_PATH:${FLEX_V3PreLex_pregen_OUTPUTS}>" > "$<SHELL_PATH:${FLEX_V3PreLex_OUTPUTS}>"
)
add_custom_target(V3PreLex_yy_cpp DEPENDS ${FLEX_V3PreLex_OUTPUTS})
# Output included by another source file
set(gitHead ${srcdir}/../.git/logs/HEAD)
if (NOT EXISTS ${githead})
set(gitHead "")
endif()
add_custom_command(
OUTPUT config_rev.h
MAIN_DEPENDENCY ${gitHead}
DEPENDS ${CONFIG_REV}
COMMAND ${PERL_EXECUTABLE} ARGS
${CONFIG_REV} "${srcdir}" > "$<SHELL_PATH:${CMAKE_CURRENT_BINARY_DIR}/config_rev.h>"
)
list(APPEND GENERATED_FILES config_rev.h)
# Output used directly by the `verilator` target
set(ASTGENERATED_NAMES
V3Const
)
foreach(astgen_name ${ASTGENERATED_NAMES})
add_custom_command(
OUTPUT ${astgen_name}__gen.cpp
MAIN_DEPENDENCY ${astgen_name}.cpp
DEPENDS ${ASTGEN} V3Ast.h V3AstNodes.h
COMMAND ${PERL_EXECUTABLE} ARGS
${ASTGEN} -I"${srcdir}" ${astgen_name}.cpp
)
list(APPEND GENERATED_FILES ${astgen_name}__gen.cpp)
endforeach()
#
# Set up the Coverage build type
addBuildType(DEBUG COVERAGE)
# This regenerates include/verilated_cov_key.h in the source tree.
# It is a custom_target, not custom_command, because vlcovgen.d is
# not a phony target (it doesn't exist as a file).
add_custom_target(
vlcovgen.d
DEPENDS ../include/verilated_cov_key.h ${VLCOVGEN}
COMMENT "Updating include/verilated_cov_key.h"
COMMAND ${PERL_EXECUTABLE}
${VLCOVGEN} --srcdir ${srcdir}
)
#
# Set up the verilator binary target
add_executable(verilator
$<$<NOT:$<CONFIG:COVERAGE>>:${COMMON_SOURCES}>
$<$<NOT:$<CONFIG:COVERAGE>>:${GENERATED_FILES}>
$<$<CONFIG:COVERAGE>:${COVERAGE_SOURCES}>
)
set_target_properties(verilator PROPERTIES
OUTPUT_NAME_RELEASE verilator_bin
OUTPUT_NAME_DEBUG verilator_bin_dbg
OUTPUT_NAME_COVERAGE verilator_coverage_bin_dbg
#UNITY_BUILD $<IF:$<CONFIG:DEBUG>,FALSE,${CMAKE_UNITY_BUILD}>
MSVC_RUNTIME_LIBRARY MultiThreaded$<IF:$<CONFIG:Release>,,DebugDLL>
INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
)
add_dependencies(verilator
V3Lexer_yy_cpp
V3PreLex_yy_cpp
)
# verilated_cov_key.h is only regenerated in a single-configuration environment.
# This limitation can be lifted when `add_dependencies` will support generator
# expressions. See https://gitlab.kitware.com/cmake/cmake/issues/19467
if (CMAKE_BUILD_TYPE STREQUAL Coverage)
add_dependencies(verilator vlcovgen.d)
endif()
target_compile_features(verilator PRIVATE cxx_std_11)
target_compile_definitions(verilator PRIVATE
YYDEBUG # Required to get nice error messages
$<$<CONFIG:DEBUG>:VL_DEBUG>
$<$<CONFIG:DEBUG>:_GLIBCXX_DEBUG>
)
target_include_directories(verilator
PRIVATE
../include
${FLEX_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
if (WIN32)
target_compile_definitions(verilator PRIVATE
YY_NO_UNISTD_H
)
target_include_directories(verilator PRIVATE ../platform/win32)
target_link_libraries(verilator PRIVATE bcrypt psapi)
endif()

View File

@ -21,6 +21,7 @@ if (!-r "$root/.git") {
my $files = `cd $root && git ls-files --exclude-standard`;
print "ST $files\n" if $Debug;
$files =~ s/\s+/ /g;
$files =~ s-platform/win32/dirent.h--;
my $cmd = "cd $root && fgrep -n include $files | sort";
my $grep = `$cmd`;
foreach my $line (split /\n/, $grep) {

View File

@ -21,6 +21,7 @@ if (!-r "$root/.git") {
my $files = `cd $root && git ls-files --exclude-standard`;
print "ST $files\n" if $Debug;
$files =~ s/\s+/ /g;
$files =~ s-platform/win32/dirent.h--;
my $cmd = "cd $root && grep -n -P '(FIX"."ME|BO"."ZO)' $files | sort";
my $grep = `$cmd`;
print "$grep\n";