Browse Source

Added SNPS SLS SystemC find package and clean up of cmake config

pull/2/head
Eyck Jentzsch 1 year ago
parent
commit
c4eb197bd8
5 changed files with 153 additions and 62 deletions
  1. 4
    28
      CMakeLists.txt
  2. 1
    1
      cmake/CPackConfig.cmake
  3. 121
    0
      cmake/FindSLSSystemC.cmake
  4. 3
    24
      cmake/FindSystemC.cmake
  5. 24
    9
      src/CMakeLists.txt

+ 4
- 28
CMakeLists.txt View File

@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) # main (top) cmake dir
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir

project (sc-components)
@@ -12,35 +11,12 @@ set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})

include(Common)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT SystemCPackage)
set(SystemCPackage SystemC)
endif()

find_package(Threads)
find_package(SystemC REQUIRED)
find_package(ZLIB)
if(SystemC_FOUND)
include_directories(${SystemC_INCLUDE_DIRS})
link_directories(${SystemC_LIBRARY_DIRS})
else()
message( FATAL_ERROR "SystemC library not found." )
endif()

if(CCI_FOUND)
include_directories(${CCI_INCLUDE_DIRS})
link_directories(${CCI_LIBRARY_DIRS})
#else()
# message( FATAL_ERROR "SystemC CCI library not found." )
endif()

if(ZLIB_FOUND)
include_directories( ${ZLIB_INCLUDE_DIRS} )
#link_directories(${ZLIB_LIBRARY_DIRS})
message( STATUS "ZLib found at ${ZLIB_INCLUDE_DIRS}." )
endif(ZLIB_FOUND)

if(SCV_FOUND)
add_definitions(-DWITH_SCV)
include_directories(${SCV_INCLUDE_DIRS})
link_directories(${SCV_LIBRARY_DIRS})
endif(SCV_FOUND)
find_package(${SystemCPackage} REQUIRED)

add_subdirectory (src)

+ 1
- 1
cmake/CPackConfig.cmake View File

@@ -13,7 +13,7 @@ else()
endif()

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SystemC components and extensions")
set(CPACK_PACKAGE_CONTACT "Eyck Jentzsch <eyck@eminres.com>")
set(CPACK_PACKAGE_CONTACT "MINRES Technolgies GmbH <info@minres.com>")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})

+ 121
- 0
cmake/FindSLSSystemC.cmake View File

@@ -0,0 +1,121 @@
SET(_COMMON_HINTS
$ENV{SNPS_VP_HOME}/common/include
$ENV{SNPS_VP_HOME}/common/libso-$ENV{COWARE_CXX_COMPILER}
)

SET(_SYSTEMC_HINTS
${_COMMON_HINTS}
)

SET(_TLM_HINTS
$ENV{SNPS_VP_HOME}/common/include/tlm
${_COMMON_HINTS}
)

SET(_SCV_HINTS
${_COMMON_HINTS}
)

SET(_CCI_HINTS
${_COMMON_HINTS}
)

SET(_COMMON_PATHS
/usr/include/systemc
/usr/lib
/usr/lib-linux
/usr/lib-linux64
/usr/lib-macos
/usr/local/include/sysc
/usr/local/lib
/usr/local/lib-linux
/usr/local/lib-linux64
/usr/local/lib-macos
)
FIND_FILE(_SYSTEMC_HEADER_FILE
NAMES systemc
HINTS ${_SYSTEMC_HINTS}
PATHS ${_COMMON_PATHS}
)

FIND_FILE(_SCV_HEADER_FILE
NAMES scv.h
HINTS ${_SCV_HINTS}
PATHS ${_COMMON_PATHS}
)

FIND_FILE(_CCI_HEADER_FILE
NAMES cci_configuration
HINTS ${_CCI_HINTS}
PATHS ${_COMMON_PATHS}
)

if(NOT _SYSTEMC_HEADER_FILE STREQUAL _SYSTEMC_HEADER_FILE-NOTFOUND)
set(SystemC_FOUND TRUE)
endif()

if(ENABLE_SCV)
if(NOT _SCV_HEADER_FILE STREQUAL _SCV_HEADER_FILE-NOTFOUND)
set(SCV_FOUND TRUE)
endif()
endif()

if(NOT _CCI_HEADER_FILE STREQUAL _CCI_HEADER_FILE-NOTFOUND)
set(CCI_FOUND TRUE)
endif()

FIND_PATH(SystemC_INCLUDE_DIRS
NAMES systemc
HINTS ${_SYSTEMC_HINTS}
PATHS ${_COMMON_PATHS}
)

FIND_PATH(TLM_INCLUDE_DIRS
NAMES tlm
HINTS ${_TLM_HINTS}
PATHS ${_COMMON_PATHS}
)

FIND_PATH(SystemC_LIBRARY_DIRS
NAMES libSnpsVP.so
HINTS ${_SYSTEMC_HINTS}
PATHS ${_COMMON_PATHS}
)

FIND_PATH(SCV_INCLUDE_DIRS
NAMES scv.h
HINTS ${_SCV_HINTS}
PATHS ${_COMMON_PATHS}
)

FIND_PATH(SCV_LIBRARY_DIRS
NAMES libSnpsVP.so
HINTS ${_SCV_HINTS}
PATHS ${_COMMON_PATHS}
)

FIND_PATH(CCI_INCLUDE_DIRS
NAMES cci_configuration
HINTS ${_CCI_HINTS}
PATHS ${_COMMON_PATHS}
)

FIND_PATH(CCI_LIBRARY_DIRS
NAMES libcciapi.a libcciapi.so
HINTS ${_CCI_HINTS}
PATHS ${_COMMON_PATHS}
)

if(SystemC_FOUND)
#see https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler
#set(CMAKE_CXX_COMPILER $ENV{SNPS_VP_HOME}/common/bin/g++)
set(SystemC_INCLUDE_DIRS ${TLM_INCLUDE_DIRS} ${SystemC_INCLUDE_DIRS})
set(SystemC_LIBRARIES SnpsVPExt SnpsVP tbb omniORB4 omnithread dwarf elf)
if(SCV_FOUND)
set(SCV_LIBRARIES ${SystemC_LIBRARIES})
endif(SCV_FOUND)
if(CCI_FOUND)
set(CCI_LIBRARIES cciapi)
endif()
endif(SystemC_FOUND)

+ 3
- 24
cmake/FindSystemC.cmake View File

@@ -63,44 +63,23 @@ SET(_COMMON_PATHS
/usr/local/lib-linux64
/usr/local/lib-macos
)

SET(_SYSTEMC_PATHS
${CONAN_INCLUDE_DIRS_SYSTEMC}
${CONAN_LIB_DIRS_SYSTEMC}
${_COMMON_PATHS}
)

SET(_SCV_PATHS
${CONAN_INCLUDE_DIRS_SYSTEMCVERIFICATION}
${CONAN_LIB_DIRS_SYSTEMCVERIFICATION}
${_COMMON_PATHS}
)

SET(_CCI_PATHS
${CONAN_INCLUDE_DIRS_SYSTEMC}
${CONAN_LIB_DIRS_SYSTEMC}
${_COMMON_PATHS}
)
FIND_FILE(_SYSTEMC_HEADER_FILE
NAMES systemc
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
PATH_SUFFIXES sysc/kernel
PATHS ${_COMMON_PATHS}
)

FIND_FILE(_SCV_HEADER_FILE
NAMES scv.h
HINTS ${_SCV_HINTS}
PATHS ${_SCV_PATHS}
PATH_SUFFIXES sysc/kernel
PATHS ${_COMMON_PATHS}
)

FIND_FILE(_CCI_HEADER_FILE
NAMES cci_configuration
HINTS ${_CCI_HINTS}
PATHS ${_CCI_PATHS}
PATH_SUFFIXES sysc/kernel
PATHS ${_COMMON_PATHS}
)

if(NOT _SYSTEMC_HEADER_FILE STREQUAL _SYSTEMC_HEADER_FILE-NOTFOUND)

+ 24
- 9
src/CMakeLists.txt View File

@@ -1,5 +1,6 @@
FILE(GLOB LibHeaders ../incl/*/*.h)
set(LIB_HEADERS ${LibHeaders} )

set(LIB_SOURCES
sc_logic_7.cpp
utilities.cpp
@@ -7,6 +8,7 @@ set(LIB_SOURCES
perf_estimator.cpp
io-redirector.cpp
)

if(CCI_FOUND)
set(LIB_SOURCES ${LIB_SOURCES}
tracer_base.cpp
@@ -36,26 +38,39 @@ set(LIBRARY_NAME sc-components)

# Define the library
add_library(${LIBRARY_NAME} ${LIB_SOURCES})
target_include_directories (${LIBRARY_NAME} PUBLIC ${SystemC_INCLUDE_DIRS})
target_include_directories (${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../incl)
set_target_properties(${LIBRARY_NAME} PROPERTIES
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
FRAMEWORK FALSE
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
)

if(CCI_FOUND)
target_compile_definitions(${LIBRARY_NAME} PUBLIC -DWITH_CCI)
target_include_directories (${LIBRARY_NAME} PUBLIC ${CCI_INCLUDE_DIRS})
target_link_libraries(${LIBRARY_NAME} ${CCI_LIBRARIES} )
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0")
target_link_directories(${LIBRARY_NAME} PUBLIC ${CCI_LIBRARY_DIRS})
endif()
endif()

if(SCV_FOUND)
add_definitions(-DWITH_SCV)
target_compile_definitions(${LIBRARY_NAME} PUBLIC -DWITH_SCV)
target_include_directories (${LIBRARY_NAME} PUBLIC ${SCV_INCLUDE_DIRS})
target_link_libraries (${LIBRARY_NAME} ${SCV_LIBRARIES})
# target_link_libraries (${LIBRARY_NAME} fmt)
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0")
target_link_directories(${LIBRARY_NAME} PUBLIC ${SCV_LIBRARY_DIRS})
endif()
endif()
set_target_properties(${LIBRARY_NAME} PROPERTIES
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
FRAMEWORK FALSE
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
)

target_include_directories (${LIBRARY_NAME} PUBLIC ${SystemC_INCLUDE_DIRS})
target_link_libraries(${LIBRARY_NAME} ${SystemC_LIBRARIES} )
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0")
target_link_directories(${LIBRARY_NAME} PUBLIC ${SystemC_LIBRARY_DIRS})
endif()

# build a separate JSON linrary for the use in non-systemc based systems
# build a separate JSON library for the use in non-systemc based systems
add_library(jsoncpp jsoncpp.cpp)
FILE(GLOB JsonLibHeaders ../incl/json/*.h)
set_target_properties(jsoncpp PROPERTIES

Loading…
Cancel
Save