File: install-cmake.rst

package info (click to toggle)
verilator 5.044-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 69,096 kB
  • sloc: cpp: 152,937; python: 22,624; ansic: 11,002; yacc: 6,111; lex: 2,011; makefile: 1,428; sh: 603; perl: 302
file content (78 lines) | stat: -rw-r--r-- 2,365 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
.. Copyright 2003-2026 by Wilson Snyder.
.. SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0

.. _cmakeinstallation:

******************
CMake Installation
******************

This section discusses how to build and install Verilator using cmake.
Currently cmake is only officially supported for Windows builds (not
Linux).

.. _tools install:

Quick Install
=============

1. Install Python for your platform from https://www.python.org/downloads/.
2. Install CMake for your platform from https://cmake.org/download/ or
   build it from source.
3. If the compiler of your choice is MSVC, then install
   https://visualstudio.microsoft.com/downloads/. If the compiler of your
   choice is Clang, then install https://releases.llvm.org/download.html or
   build it from source.
4. For flex and bison use https://github.com/lexxmark/winflexbison to build
   and install.
5. For build on Windows using MSVC set environment variable WIN_FLEX_BISON
   to install directory. For build on Windows/Linux/OS-X using ninja set
   the environment variable FLEX_INCLUDE to the directory containing
   FlexLexer.h and ensure that flex/bison is available within the PATH.

To obtain Verilator sources download
https://github.com/verilator/verilator/archive/refs/heads/master.zip or
clone https://github.com/verilator/verilator using git :ref:`Obtain
Sources`.

To build using MSVC:

.. code-block:: bash

   cd verilator  # directory containing source files of verilator
   mkdir build
   cmake .. -DCMAKE_BUILD_TYPE=Release --install-prefix $PWD/../install
   cmake --build . --config Release
   cmake --install . --prefix $PWD/../install

To build using ninja:

.. code-block:: bash

   cd verilator
   mkdir build
   cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release --install-prefix $PWD/../install -DCMAKE_MAKE_PROGRAM=<path to ninja binary> -DBISON_EXECUTABLE=<path to bison> -DFLEX_EXECUTABLE=<path to flex>
   <path to ninja binary> #execute ninja
   cmake --install . --prefix $PWD/../install


.. _cmake usage:

Usage
=====

To use Verilator set the environment variable ``VERILATOR_ROOT`` to the
install directory specified in the above build.

Example
=======

.. code-block:: bash

   cd verilator/examples
   cd cmake_hello_c
   mkdir build
   cd build
   cmake ..  # cmake -G Ninja ..
   cmake --build . --config Release # ninja
   # execute the generated binary