Browse Source

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

Eyck Jentzsch 7 months 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 @@
1 1
 cmake_minimum_required(VERSION 2.8)
2
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) # main (top) cmake dir
3 2
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir
4 3
 
5 4
 project (sc-components)
@@ -12,35 +11,12 @@ set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
12 11
 
13 12
 include(Common)
14 13
 
15
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
14
+if(NOT SystemCPackage)
15
+	set(SystemCPackage SystemC)
16
+endif()
16 17
 
17 18
 find_package(Threads)
18
-find_package(SystemC REQUIRED)
19 19
 find_package(ZLIB)
20
-if(SystemC_FOUND)
21
-    include_directories(${SystemC_INCLUDE_DIRS})
22
-    link_directories(${SystemC_LIBRARY_DIRS})
23
-else()
24
-    message( FATAL_ERROR "SystemC library not found." )
25
-endif()
26
-
27
-if(CCI_FOUND)
28
-    include_directories(${CCI_INCLUDE_DIRS})
29
-    link_directories(${CCI_LIBRARY_DIRS})
30
-#else()
31
-#    message( FATAL_ERROR "SystemC CCI library not found." )
32
-endif()
33
-
34
-if(ZLIB_FOUND)
35
-    include_directories( ${ZLIB_INCLUDE_DIRS} )
36
-    #link_directories(${ZLIB_LIBRARY_DIRS})
37
-    message( STATUS "ZLib found at ${ZLIB_INCLUDE_DIRS}." )
38
-endif(ZLIB_FOUND)
39
-
40
-if(SCV_FOUND)   
41
-    add_definitions(-DWITH_SCV)
42
-    include_directories(${SCV_INCLUDE_DIRS})
43
-    link_directories(${SCV_LIBRARY_DIRS})
44
-endif(SCV_FOUND)
20
+find_package(${SystemCPackage} REQUIRED)
45 21
 
46 22
 add_subdirectory (src)

+ 1
- 1
cmake/CPackConfig.cmake View File

@@ -13,7 +13,7 @@ else()
13 13
 endif()
14 14
 
15 15
 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SystemC components and extensions")
16
-set(CPACK_PACKAGE_CONTACT "Eyck Jentzsch <eyck@eminres.com>")
16
+set(CPACK_PACKAGE_CONTACT "MINRES Technolgies GmbH <info@minres.com>")
17 17
 set(CPACK_PACKAGE_VERSION ${VERSION})
18 18
 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
19 19
 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})

+ 121
- 0
cmake/FindSLSSystemC.cmake View File

@@ -0,0 +1,121 @@
1
+SET(_COMMON_HINTS
2
+  $ENV{SNPS_VP_HOME}/common/include
3
+  $ENV{SNPS_VP_HOME}/common/libso-$ENV{COWARE_CXX_COMPILER}
4
+  )
5
+
6
+SET(_SYSTEMC_HINTS
7
+  ${_COMMON_HINTS}
8
+  )
9
+
10
+SET(_TLM_HINTS
11
+  $ENV{SNPS_VP_HOME}/common/include/tlm
12
+  ${_COMMON_HINTS}
13
+  )
14
+
15
+SET(_SCV_HINTS
16
+  ${_COMMON_HINTS}
17
+  )
18
+
19
+SET(_CCI_HINTS
20
+  ${_COMMON_HINTS}
21
+  )
22
+
23
+SET(_COMMON_PATHS
24
+  /usr/include/systemc
25
+  /usr/lib
26
+  /usr/lib-linux
27
+  /usr/lib-linux64
28
+  /usr/lib-macos
29
+  /usr/local/include/sysc
30
+  /usr/local/lib
31
+  /usr/local/lib-linux
32
+  /usr/local/lib-linux64
33
+  /usr/local/lib-macos
34
+  )
35
+  
36
+FIND_FILE(_SYSTEMC_HEADER_FILE
37
+  NAMES systemc
38
+  HINTS ${_SYSTEMC_HINTS}
39
+  PATHS ${_COMMON_PATHS}
40
+)
41
+
42
+FIND_FILE(_SCV_HEADER_FILE
43
+  NAMES scv.h
44
+  HINTS ${_SCV_HINTS}
45
+  PATHS ${_COMMON_PATHS}
46
+)
47
+
48
+FIND_FILE(_CCI_HEADER_FILE
49
+  NAMES cci_configuration
50
+  HINTS ${_CCI_HINTS}
51
+  PATHS ${_COMMON_PATHS}
52
+)
53
+
54
+if(NOT _SYSTEMC_HEADER_FILE STREQUAL _SYSTEMC_HEADER_FILE-NOTFOUND)
55
+  set(SystemC_FOUND TRUE)
56
+endif()
57
+
58
+if(ENABLE_SCV)
59
+if(NOT _SCV_HEADER_FILE STREQUAL _SCV_HEADER_FILE-NOTFOUND)
60
+  set(SCV_FOUND TRUE)
61
+endif()
62
+endif()
63
+
64
+if(NOT _CCI_HEADER_FILE STREQUAL _CCI_HEADER_FILE-NOTFOUND)
65
+  set(CCI_FOUND TRUE)
66
+endif()
67
+
68
+FIND_PATH(SystemC_INCLUDE_DIRS
69
+  NAMES systemc
70
+  HINTS ${_SYSTEMC_HINTS}
71
+  PATHS ${_COMMON_PATHS}
72
+)
73
+
74
+FIND_PATH(TLM_INCLUDE_DIRS
75
+  NAMES tlm
76
+  HINTS ${_TLM_HINTS}
77
+  PATHS ${_COMMON_PATHS}
78
+)
79
+
80
+FIND_PATH(SystemC_LIBRARY_DIRS
81
+  NAMES libSnpsVP.so 
82
+  HINTS ${_SYSTEMC_HINTS}
83
+  PATHS ${_COMMON_PATHS}
84
+)
85
+
86
+FIND_PATH(SCV_INCLUDE_DIRS
87
+  NAMES scv.h
88
+  HINTS ${_SCV_HINTS}
89
+  PATHS ${_COMMON_PATHS}
90
+)
91
+
92
+FIND_PATH(SCV_LIBRARY_DIRS
93
+  NAMES libSnpsVP.so 
94
+  HINTS ${_SCV_HINTS}
95
+  PATHS ${_COMMON_PATHS}
96
+)
97
+
98
+FIND_PATH(CCI_INCLUDE_DIRS
99
+  NAMES cci_configuration
100
+  HINTS ${_CCI_HINTS}
101
+  PATHS ${_COMMON_PATHS}
102
+)
103
+
104
+FIND_PATH(CCI_LIBRARY_DIRS
105
+  NAMES libcciapi.a libcciapi.so
106
+  HINTS ${_CCI_HINTS}
107
+  PATHS ${_COMMON_PATHS}
108
+)
109
+
110
+if(SystemC_FOUND)
111
+	#see https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler
112
+   	#set(CMAKE_CXX_COMPILER $ENV{SNPS_VP_HOME}/common/bin/g++)
113
+   	set(SystemC_INCLUDE_DIRS ${TLM_INCLUDE_DIRS} ${SystemC_INCLUDE_DIRS})
114
+    set(SystemC_LIBRARIES SnpsVPExt SnpsVP tbb omniORB4 omnithread dwarf elf) 
115
+    if(SCV_FOUND)
116
+        set(SCV_LIBRARIES ${SystemC_LIBRARIES})
117
+    endif(SCV_FOUND)
118
+    if(CCI_FOUND)
119
+        set(CCI_LIBRARIES cciapi)
120
+    endif()
121
+endif(SystemC_FOUND)

+ 3
- 24
cmake/FindSystemC.cmake View File

@@ -63,44 +63,23 @@ SET(_COMMON_PATHS
63 63
   /usr/local/lib-linux64
64 64
   /usr/local/lib-macos
65 65
   )
66
-
67
-SET(_SYSTEMC_PATHS
68
-  ${CONAN_INCLUDE_DIRS_SYSTEMC}
69
-  ${CONAN_LIB_DIRS_SYSTEMC}
70
-  ${_COMMON_PATHS}
71
-  )
72
-
73
-SET(_SCV_PATHS
74
-  ${CONAN_INCLUDE_DIRS_SYSTEMCVERIFICATION}
75
-  ${CONAN_LIB_DIRS_SYSTEMCVERIFICATION}
76
-  ${_COMMON_PATHS}
77
-  )
78
-
79
-SET(_CCI_PATHS
80
-  ${CONAN_INCLUDE_DIRS_SYSTEMC}
81
-  ${CONAN_LIB_DIRS_SYSTEMC}
82
-  ${_COMMON_PATHS}
83
-  )
84 66
   
85 67
 FIND_FILE(_SYSTEMC_HEADER_FILE
86 68
   NAMES systemc
87 69
   HINTS ${_SYSTEMC_HINTS}
88
-  PATHS ${_SYSTEMC_PATHS}
89
-  PATH_SUFFIXES sysc/kernel
70
+  PATHS ${_COMMON_PATHS}
90 71
 )
91 72
 
92 73
 FIND_FILE(_SCV_HEADER_FILE
93 74
   NAMES scv.h
94 75
   HINTS ${_SCV_HINTS}
95
-  PATHS ${_SCV_PATHS}
96
-  PATH_SUFFIXES sysc/kernel
76
+  PATHS ${_COMMON_PATHS}
97 77
 )
98 78
 
99 79
 FIND_FILE(_CCI_HEADER_FILE
100 80
   NAMES cci_configuration
101 81
   HINTS ${_CCI_HINTS}
102
-  PATHS ${_CCI_PATHS}
103
-  PATH_SUFFIXES sysc/kernel
82
+  PATHS ${_COMMON_PATHS}
104 83
 )
105 84
 
106 85
 if(NOT _SYSTEMC_HEADER_FILE STREQUAL _SYSTEMC_HEADER_FILE-NOTFOUND)

+ 24
- 9
src/CMakeLists.txt View File

@@ -1,5 +1,6 @@
1 1
 FILE(GLOB LibHeaders ../incl/*/*.h)
2 2
 set(LIB_HEADERS ${LibHeaders} )
3
+
3 4
 set(LIB_SOURCES
4 5
     sc_logic_7.cpp
5 6
     utilities.cpp
@@ -7,6 +8,7 @@ set(LIB_SOURCES
7 8
     perf_estimator.cpp
8 9
     io-redirector.cpp
9 10
 )
11
+
10 12
 if(CCI_FOUND)
11 13
     set(LIB_SOURCES ${LIB_SOURCES} 
12 14
 	    tracer_base.cpp
@@ -36,26 +38,39 @@ set(LIBRARY_NAME sc-components)
36 38
 
37 39
 # Define the library
38 40
 add_library(${LIBRARY_NAME} ${LIB_SOURCES})
39
-target_include_directories (${LIBRARY_NAME} PUBLIC ${SystemC_INCLUDE_DIRS})	
41
+
40 42
 target_include_directories (${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../incl)
43
+set_target_properties(${LIBRARY_NAME} PROPERTIES
44
+  VERSION ${VERSION}  # ${VERSION} was defined in the main CMakeLists.
45
+  FRAMEWORK FALSE
46
+  PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
47
+)
48
+
41 49
 if(CCI_FOUND)
50
+    target_compile_definitions(${LIBRARY_NAME} PUBLIC -DWITH_CCI)
42 51
 	target_include_directories (${LIBRARY_NAME} PUBLIC ${CCI_INCLUDE_DIRS})
43 52
 	target_link_libraries(${LIBRARY_NAME} ${CCI_LIBRARIES} )
53
+	if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0") 
54
+		target_link_directories(${LIBRARY_NAME} PUBLIC ${CCI_LIBRARY_DIRS})
55
+	endif()
44 56
 endif()
57
+
45 58
 if(SCV_FOUND)   
46
-    add_definitions(-DWITH_SCV)
59
+    target_compile_definitions(${LIBRARY_NAME} PUBLIC -DWITH_SCV)
47 60
 	target_include_directories (${LIBRARY_NAME} PUBLIC ${SCV_INCLUDE_DIRS})
48 61
     target_link_libraries (${LIBRARY_NAME} ${SCV_LIBRARIES})
49
-#    target_link_libraries (${LIBRARY_NAME} fmt)
62
+	if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0") 
63
+		target_link_directories(${LIBRARY_NAME} PUBLIC ${SCV_LIBRARY_DIRS})
64
+	endif()
50 65
 endif()
51
-set_target_properties(${LIBRARY_NAME} PROPERTIES
52
-  VERSION ${VERSION}  # ${VERSION} was defined in the main CMakeLists.
53
-  FRAMEWORK FALSE
54
-  PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
55
-)
66
+
67
+target_include_directories (${LIBRARY_NAME} PUBLIC ${SystemC_INCLUDE_DIRS})	
56 68
 target_link_libraries(${LIBRARY_NAME} ${SystemC_LIBRARIES} )
69
+if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0") 
70
+	target_link_directories(${LIBRARY_NAME} PUBLIC ${SystemC_LIBRARY_DIRS})
71
+endif()
57 72
 
58
-# build a separate JSON linrary for the use in non-systemc based systems
73
+# build a separate JSON library for the use in non-systemc based systems
59 74
 add_library(jsoncpp jsoncpp.cpp)
60 75
 FILE(GLOB JsonLibHeaders ../incl/json/*.h)
61 76
 set_target_properties(jsoncpp PROPERTIES