7 Limitations 9 Building Required Libraries
SystemC* Library  / 

8 Building with CMake

The static libraries needed at link time and the shared modules loaded by Simics can all be built using CMake. This is the preferred way to build SystemC.

This chapter will outline how to do that and how to migrate from the previous GNU Make driven build system.

In order to build with CMake you need to create a CMake Simics project. In Simics 6 this is an opt-in feature enabled by passing --with-cmake to project-setup. In Simics 7 it’s opt-out, always enabled. In Simics 8 it will be the only supported way to build Simics modules.

8.1 Basic structure

A Simics SystemC module consists of two parts:

The set of static libraries built by CMake varies upon features required by the module. CMake will figure out what to build and in what order before building the module. The libraries can also be built on their own through the systemc-deps-cache target. Optionally, these libraries can then be deployed to a common repository or cache, enabling re-use in other build environments.

8.2 Boost dependency

The Simics SystemC Checkpointing feature depends on a fixed version of Boost 1.65.1. If this version cannot be provided, or if the user does not need the Checkpointing feature, the Checkpointing feature will not be built.

The feature is currently opt-in; it’s not built by default.

The Simics.cmake module will try to locate Boost in the default paths or SYSTEMC_BOOST_INCLUDE_DIR if provided by the user. The standard Boost_INCLUDE_DIR is not honored, making it possible for the user to leverage a more modern version of Boost for other parts of the CMake project.

See ‘Configuration’ below for more details and other options.

8.3 Backwards compatibility / hybrid GNU Make/CMake setup

To retain backwards compatibility the libraries can still be built using the build script. See next chapter for details on invocation.

The build script requires that CMake and Ninja is found in PATH now. It sets up a build tree and produces the static libraries in the same location as before, e.g. linux64/lib/systemc/2.3.3. The linux64/lib/systemc root directory (including the version subdirs) can be copied to a shared location and be re-used between builds by setting the SYSTEMC_DEPS_CACHE variable.

8.4 Building the static libraries as part of the project build

The preferred way to build a SystemC module is to build everything, including the static libraries, in the same project. This does not take very long, and CMake will track all dependencies so a rebuild where only the module has been changed will not rebuild the static libs. The CMake dependencies will make sure the correct libraries are built in the correct order, so there is no need for the dedicated build script anymore.

The added benefit is also that CMake will make sure to only build what is needed, so the modules you build does not require the checkpointing those static libs will never be built. This obviously saves time compared to building them and not using them.

Please note that Simics modules in general and SystemC modules in particular is designed to be free from run-time dependencies. The static libraries built locally are not meaningful elsewhere, only the Simics module should be distributed and shared with other Simics configurations elsewhere.

8.5 Re-using the static libraries from cache

If the user needs to link with pre-built static libraries, this is still possible with CMake using the same SYSTEMC_DEPS_CACHE variable exposed to the deprecated GNU Make build system. Simply set the SYSTEMC_DEPS_CACHE cache variable during CMake configuration. By setting this variable the CMake build rules/dependencies will not build any of the required static libraries.

8.6 Configuration

8.6.1 Options

Options / cache variableDefault valueUsage
SYSTEMC_KERNEL_VERSIONundefinedSelects the SystemC kernel version used in the project
SYSTEMC_INTC_EXTONIntel Extensions enabled
SYSTEMC_INTC_EXT_VALGRINDONValgrind support enabled
USE_SIMICS_CHECKPOINTINGNOSimics SystemC Checkpointing enabled (opt-in feature)
SYSTEMC_BOOST_INCLUDE_DIRundefinedLook for Boost 1.65.1 headers in this directory
USE_SIMICS_CCIYESSimics CCI enabled (opt-out feature)

8.6.2 Variables

The SIMICS_1013_ADDON_DIR and SIMICS_7213_ADDON_DIR can be used to locate the root of the corresponding add-on package.

8.7 CMakeLists.txt for SystemC modules

Simics has added a dedicated helper function, simics_add_systemc_module, for SystemC modules. It works exactly like the standard simics_add_module for normal modules but adds the capability of building SystemC modules. It is not strictly necessary to use this helper function, but it is strongly recommended. See the Simics CMake Reference Manual for more details. These are the added options and a brief description:

8.8 Things to note about the modules distributed with Simics 1013 add-on package

8.8.1 They are conditional on the SYSTEMC_INTC_EXT cache variable

Some modules require that the kernel has been built with the Simics extensions, and if that is not the case then these modules are skipped.

8.8.2 They are conditional on the SYSTEMC_KERNEL_VERSION cache variable

This variable controls what version of the kernel to build. See 2 for more details on supported versions.

8.9 Selecting the C++ standard is important

As noted in 2 the selected C++ standard is very important as kernel 3.0.0 only builds with C++ 17. The older versions should work with C++ 14. The SystemC Library itself requires C++ 14 and does not work with C++ 11.

The standard must be setup in the top-level CMakeLists.txt file of the Simics project.

These settings belong to the end-user’s project, thus they are not set by default by Simics.

This is an example of what it could look like:

if(NOT CMAKE_CXX_STANDARD)
  if("${SYSTEMC_KERNEL_VERSION}" STREQUAL "3.0.0")
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
  else()
    set(CMAKE_CXX_STANDARD 14)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)  # make sure -std=c++14 flag is used
  endif()
endif()
7 Limitations 9 Building Required Libraries