A SystemC productivity library for virtual platform development utilizing SCV and TLM2.0 https://www.minres.com/#opensource
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. cmake_minimum_required(VERSION 3.11)
  2. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir
  3. project(scc VERSION 0.9.0 LANGUAGES CXX C)
  4. include(Common)
  5. include(GNUInstallDirs)
  6. ###############################################################################
  7. # build a separate SCC-UTIL library for the use in non-systemc based systems
  8. ###############################################################################
  9. add_library(scc-util STATIC src/io-redirector.cpp)
  10. target_include_directories (scc-util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/incl)
  11. FILE(GLOB SccUtilHeaders incl/util/*.h)
  12. set_target_properties(scc-util PROPERTIES
  13. VERSION ${PROJECT_VERSION} # ${VERSION} was defined in the main CMakeLists.
  14. FRAMEWORK FALSE
  15. PUBLIC_HEADER "${SccUtilHeaders}" # specify the public headers
  16. )
  17. install(TARGETS scc-util
  18. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  19. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  20. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
  21. PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/util
  22. )
  23. ###############################################################################
  24. # build a SCC
  25. ###############################################################################
  26. if(NOT SystemCPackage)
  27. if(TARGET SystemC::SystemC)
  28. set(SystemCPackage SystemC)
  29. else()
  30. set(SystemCPackage OSCISystemC)
  31. endif()
  32. endif()
  33. message("Using ${SystemCPackage} package")
  34. if(TARGET SystemCVerification::SystemCVerification)
  35. set(SCV_FOUND TRUE)
  36. set(SCV_LIBRARIES SystemCVerification::SystemCVerification)
  37. endif()
  38. if(TARGET SystemC-CCI::SystemC-CCI)
  39. set(CCI_FOUND TRUE)
  40. set(CCI_LIBRARIES SystemC-CCI::SystemC-CCI)
  41. endif()
  42. find_package(Threads)
  43. find_package(ZLIB)
  44. find_package(${SystemCPackage} REQUIRED)
  45. set(CLANG_FORMAT_EXCLUDE_PATTERNS "/spdlog/" "/json/" "jsoncpp.cpp" "sqlite3")
  46. find_package(ClangFormat)
  47. include(CheckSymbolExists)
  48. # Check for function getenv()
  49. check_symbol_exists(getenv "stdlib.h" HAVE_GETENV)
  50. set(LIB_SOURCES
  51. src/sc_logic_7.cpp
  52. src/utilities.cpp
  53. src/report.cpp
  54. src/perf_estimator.cpp
  55. src/io-redirector.cpp
  56. src/ordered_semaphore.cpp
  57. src/configurer.cpp
  58. src/jsoncpp.cpp
  59. src/tlm_ahb_bfm_initiator.cpp
  60. src/tlm_ahb_bfm_target.cpp
  61. src/tracer_base.cpp
  62. src/tracer.cpp
  63. src/mt19937_rng.cpp
  64. )
  65. if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
  66. set(LIB_SOURCES ${LIB_SOURCES} src/watchdog.cpp)
  67. endif()
  68. if(CCI_FOUND)
  69. set(LIB_SOURCES ${LIB_SOURCES}
  70. src/configurable_tracer.cpp
  71. src/value_registry.cpp
  72. )
  73. endif()
  74. # check which version of spdlog to use.
  75. if(TARGET spdlog::spdlog)
  76. set(SPDLOG_TARGET spdlog::spdlog)
  77. elseif(TARGET CONAN_PKG::spdlog)
  78. set(SPDLOG_TARGET CONAN_PKG::spdlog)
  79. else()
  80. add_library(spdlog_local INTERFACE IMPORTED)
  81. set_property(TARGET spdlog_local PROPERTY INTERFACE_COMPILE_DEFINITIONS SPDLOG_HEADER_ONLY)
  82. set_property(TARGET spdlog_local PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/third_party)
  83. set(SPDLOG_TARGET spdlog_local)
  84. message("Using built-in version of spdlog")
  85. endif()
  86. # check which version of fmt to use
  87. if(TARGET fmt::fmt)
  88. set(FMT_TARGET fmt::fmt)
  89. elseif(TARGET CONAN_PKG::fmt)
  90. set(FMT_TARGET CONAN_PKG::fmt)
  91. else()
  92. add_library(fmt_local INTERFACE IMPORTED)
  93. set_property(TARGET fmt_local PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog)
  94. set(FMT_TARGET fmt_local)
  95. message("Using built-in version of fmt")
  96. endif()
  97. if(SCV_FOUND )
  98. if(ZLIB_FOUND)
  99. set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_compressed.cpp)
  100. endif(ZLIB_FOUND)
  101. if(FALSE)
  102. set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_binary/scv_tr_binary.cpp)
  103. if(CONAN_LEVELDB_ROOT)
  104. set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_ldb/scv_tr_ldb.cpp )
  105. endif()
  106. endif()
  107. set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_sqlite/scv_tr_sqlite.cpp src/scv_tr_sqlite/sqlite3.c )
  108. endif(SCV_FOUND)
  109. # Define two variables in order not to repeat ourselves.
  110. if(${CMAKE_VERSION} VERSION_LESS "3.13.0")
  111. link_directories(${SystemC_LIBRARY_DIRS})
  112. endif()
  113. # Define the scc library
  114. add_library(scc ${LIB_SOURCES})
  115. target_include_directories (scc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/incl)
  116. target_include_directories (scc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
  117. if(HAVE_GETENV)
  118. target_compile_definitions(scc PUBLIC HAVE_GETENV)
  119. endif()
  120. target_link_libraries(scc PUBLIC scc-util ${CMAKE_DL_LIBS})
  121. target_link_libraries(scc PUBLIC ${FMT_TARGET} ${SPDLOG_TARGET})
  122. target_link_libraries(scc PUBLIC Threads::Threads)
  123. if(CCI_FOUND)
  124. target_compile_definitions(scc PUBLIC -DWITH_CCI)
  125. target_include_directories (scc PUBLIC ${CCI_INCLUDE_DIRS})
  126. target_link_libraries(scc PUBLIC ${CCI_LIBRARIES} )
  127. if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0")
  128. target_link_directories(scc PUBLIC ${CCI_LIBRARY_DIRS})
  129. endif()
  130. endif()
  131. if(SCV_FOUND)
  132. target_compile_definitions(scc PUBLIC -DWITH_SCV)
  133. target_include_directories (scc PUBLIC ${SCV_INCLUDE_DIRS})
  134. target_link_libraries (scc PUBLIC ${SCV_LIBRARIES})
  135. if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0")
  136. target_link_directories(scc PUBLIC ${SCV_LIBRARY_DIRS})
  137. endif()
  138. endif()
  139. if(ZLIB_FOUND)
  140. target_link_libraries (scc PUBLIC ${ZLIB_LIBRARIES})
  141. endif(ZLIB_FOUND)
  142. target_include_directories (scc PUBLIC ${SystemC_INCLUDE_DIRS})
  143. target_link_libraries(scc PUBLIC ${SystemC_LIBRARIES} )
  144. if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0")
  145. target_link_directories(scc PUBLIC ${SystemC_LIBRARY_DIRS})
  146. endif()
  147. set_target_properties(scc PROPERTIES
  148. VERSION ${PROJECT_VERSION}
  149. FRAMEWORK FALSE
  150. PUBLIC_HEADER "incl/scc.h" # specify the public headers
  151. )
  152. install(TARGETS scc
  153. RUNTIME DESTINATION ${CMAKE_INSTALL_LCMAKE_INSTALL_BINDIRIBDIR}
  154. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  155. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
  156. PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  157. )
  158. install(
  159. DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/incl/
  160. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  161. FILES_MATCHING PATTERN "*")
  162. ###############################################################################
  163. # build a separate JSON library for the use in non-systemc based systems
  164. ###############################################################################
  165. add_library(jsoncpp STATIC src/jsoncpp.cpp)
  166. target_include_directories (jsoncpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/incl)
  167. FILE(GLOB JsonLibHeaders incl/json/*.h)
  168. set_target_properties(jsoncpp PROPERTIES
  169. VERSION 1.8.3
  170. FRAMEWORK FALSE
  171. PUBLIC_HEADER "${JsonLibHeaders}" # specify the public headers
  172. )
  173. install(TARGETS jsoncpp
  174. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  175. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  176. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
  177. PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json
  178. )