aboutsummaryrefslogtreecommitdiff
path: root/cmake/SystemC-external.cmake
blob: 8346c3435e556464c8c93cde34d19968946e60fe (plain) (blame)
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
# Integrate SYSTEMC as external project.
# 
# External projects are not available during cmake configuration step, but only
# during the build step. Therefore we must maintain some targets manually,
# representing the parts of the external project we want to use (eg library).

include(ExternalProject)

set(SYSTEMC_HOME ${CMAKE_BINARY_DIR}/deps/systemc)

ExternalProject_Add(
    systemc_external
    GIT_REPOSITORY https://github.com/accellera-official/systemc
    GIT_TAG        master
    GIT_SHALLOW    ON
    GIT_PROGRESS   ON
    CMAKE_ARGS
        # Fwd cmake outer cmake args.
        -DCMAKE_INSTALL_PREFIX=${SYSTEMC_HOME}
        -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
        -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
        # SystemC specific args.
        -DBUILD_SHARED_LIBS=OFF
        -DENABLE_ASSERTIONS=ON
    INSTALL_BYPRODUCTS
        ${CMAKE_BINARY_DIR}/deps/systemc/lib/libsystemc.a
)

# Define pseudo target (import lib) for usage in cmake.
add_library(SystemC::systemc STATIC IMPORTED GLOBAL)
add_dependencies(SystemC::systemc systemc_external)

# Create include dir such that we can set include dir property below.
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/deps/systemc/include)

# Set library properties.
set_target_properties(SystemC::systemc PROPERTIES
    IMPORTED_LOCATION             ${SYSTEMC_HOME}/lib/libsystemc.a
    INTERFACE_INCLUDE_DIRECTORIES ${SYSTEMC_HOME}/include
)