Browse Source

update build system

develop
Eyck Jentzsch 1 month ago
parent
commit
86ce966985
2 changed files with 81 additions and 81 deletions
  1. 80
    80
      CMakeLists.txt
  2. 1
    1
      cmake/FindClangFormat.cmake

+ 80
- 80
CMakeLists.txt View File

@@ -1,58 +1,57 @@
cmake_minimum_required(VERSION 3.11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir

# Set the version number of your project here (format is MAJOR.MINOR.PATCHLEVEL - e.g. 1.0.0)
set(VERSION_MAJOR "0")
set(VERSION_MINOR "0")
set(VERSION_PATCH "1")
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})

if(${CMAKE_VERSION} VERSION_LESS "3.0")
project(scc)
else()
if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW) # CMake 3.0.0
endif()
project(scc VERSION ${VERSION})
endif()

project(scc VERSION 0.9.0 LANGUAGES CXX C)

include(Common)
include(GNUInstallDirs)

###############################################################################
# build a separate SCC-UTIL library for the use in non-systemc based systems
###############################################################################
add_library(scc-util STATIC src/io-redirector.cpp)
target_include_directories (scc-util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/incl)

FILE(GLOB SccUtilHeaders incl/util/*.h)
set_target_properties(scc-util PROPERTIES
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
FRAMEWORK FALSE
PUBLIC_HEADER "${SccUtilHeaders}" # specify the public headers
VERSION ${PROJECT_VERSION} # ${VERSION} was defined in the main CMakeLists.
FRAMEWORK FALSE
PUBLIC_HEADER "${SccUtilHeaders}" # specify the public headers
)

install(TARGETS scc-util
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/util
)

###############################################################################
# build a SCC
###############################################################################
if(NOT SystemCPackage)
if(TARGET SystemC::SystemC)
set(SystemCPackage SystemC)
else()
set(SystemCPackage OSCISystemC)
endif()
if(TARGET SystemC::SystemC)
set(SystemCPackage SystemC)
else()
set(SystemCPackage OSCISystemC)
endif()
endif()

message("Using ${SystemCPackage} package")

if(TARGET SystemCVerification::SystemCVerification)
set(SCV_FOUND TRUE)
set(SCV_LIBRARIES SystemCVerification::SystemCVerification)
endif()
if(TARGET SystemC-CCI::SystemC-CCI)
set(CCI_FOUND TRUE)
set(CCI_LIBRARIES SystemC-CCI::SystemC-CCI)
endif()




find_package(Threads)
find_package(ZLIB)
find_package(${SystemCPackage} REQUIRED)

set(CLANG_FORMAT_EXCLUDE_PATTERNS "/spdlog/" "/json/" "jsoncpp.cpp" "sqlite3")
find_package(ClangFormat)

@@ -74,38 +73,41 @@ set(LIB_SOURCES
src/tracer_base.cpp
src/tracer.cpp
)

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
set(LIB_SOURCES ${LIB_SOURCES} src/watchdog.cpp)
endif()

if(CCI_FOUND)
set(LIB_SOURCES ${LIB_SOURCES}
src/configurable_tracer.cpp
src/value_registry.cpp
src/configurable_tracer.cpp
src/value_registry.cpp
)
endif()

# check which version of spdlog to use.
if(TARGET spdlog::spdlog)
set(SPDLOG_TARGET spdlog::spdlog)
set(SPDLOG_TARGET spdlog::spdlog)
elseif(TARGET CONAN_PKG::spdlog)
set(SPDLOG_TARGET CONAN_PKG::spdlog)
set(SPDLOG_TARGET CONAN_PKG::spdlog)
else()
add_library(spdlog_local INTERFACE IMPORTED)
add_library(spdlog_local INTERFACE IMPORTED)
set_property(TARGET spdlog_local PROPERTY INTERFACE_COMPILE_DEFINITIONS SPDLOG_HEADER_ONLY)
set_property(TARGET spdlog_local PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/third_party)
set(SPDLOG_TARGET spdlog_local)
message("Using built-in version of spdlog")
set(SPDLOG_TARGET spdlog_local)
message("Using built-in version of spdlog")
endif()

# check which version of fmt to use
if(TARGET fmt::fmt)
set(FMT_TARGET fmt::fmt)
set(FMT_TARGET fmt::fmt)
elseif(TARGET CONAN_PKG::fmt)
set(FMT_TARGET CONAN_PKG::fmt)
set(FMT_TARGET CONAN_PKG::fmt)
else()
add_library(fmt_local INTERFACE IMPORTED)
add_library(fmt_local INTERFACE IMPORTED)
set_property(TARGET fmt_local PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog)
set(FMT_TARGET fmt_local)
message("Using built-in version of fmt")
set(FMT_TARGET fmt_local)
message("Using built-in version of fmt")
endif()

if(SCV_FOUND )
@@ -113,17 +115,17 @@ if(SCV_FOUND )
set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_compressed.cpp)
endif(ZLIB_FOUND)
if(FALSE)
set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_binary/scv_tr_binary.cpp)
if(CONAN_LEVELDB_ROOT)
set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_ldb/scv_tr_ldb.cpp )
endif()
set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_binary/scv_tr_binary.cpp)
if(CONAN_LEVELDB_ROOT)
set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_ldb/scv_tr_ldb.cpp )
endif()
endif()
set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_sqlite/scv_tr_sqlite.cpp src/scv_tr_sqlite/sqlite3.c )
set(LIB_SOURCES ${LIB_SOURCES} src/scv_tr_sqlite/scv_tr_sqlite.cpp src/scv_tr_sqlite/sqlite3.c )
endif(SCV_FOUND)

# Define two variables in order not to repeat ourselves.
if(${CMAKE_VERSION} VERSION_LESS "3.13.0")
link_directories(${SystemC_LIBRARY_DIRS})
link_directories(${SystemC_LIBRARY_DIRS})
endif()

# Define the scc library
@@ -131,13 +133,8 @@ add_library(scc ${LIB_SOURCES})
target_include_directories (scc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/incl)
target_include_directories (scc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
if(HAVE_GETENV)
target_compile_definitions(scc PUBLIC HAVE_GETENV)
target_compile_definitions(scc PUBLIC HAVE_GETENV)
endif()
set_target_properties(scc PROPERTIES
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
FRAMEWORK FALSE
PUBLIC_HEADER "incl/scc.h" # specify the public headers
)

target_link_libraries(scc PUBLIC scc-util ${CMAKE_DL_LIBS})
target_link_libraries(scc PUBLIC ${FMT_TARGET} ${SPDLOG_TARGET})
@@ -145,40 +142,59 @@ target_link_libraries(scc PUBLIC Threads::Threads)

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

if(SCV_FOUND)
target_compile_definitions(scc PUBLIC -DWITH_SCV)
target_include_directories (scc PUBLIC ${SCV_INCLUDE_DIRS})
target_include_directories (scc PUBLIC ${SCV_INCLUDE_DIRS})
target_link_libraries (scc PUBLIC ${SCV_LIBRARIES})
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0")
target_link_directories(scc PUBLIC ${SCV_LIBRARY_DIRS})
endif()
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.13.0")
target_link_directories(scc PUBLIC ${SCV_LIBRARY_DIRS})
endif()
endif()

if(ZLIB_FOUND)
target_link_libraries (scc PUBLIC ${ZLIB_LIBRARIES})
endif(ZLIB_FOUND)

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

set_target_properties(scc PROPERTIES
VERSION ${PROJECT_VERSION}
FRAMEWORK FALSE
PUBLIC_HEADER "incl/scc.h" # specify the public headers
)
install(TARGETS scc
RUNTIME DESTINATION ${CMAKE_INSTALL_LCMAKE_INSTALL_BINDIRIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/incl/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*")

###############################################################################
# build a separate JSON library for the use in non-systemc based systems
###############################################################################
add_library(jsoncpp STATIC src/jsoncpp.cpp)
target_include_directories (jsoncpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/incl)

FILE(GLOB JsonLibHeaders incl/json/*.h)
set_target_properties(jsoncpp PROPERTIES
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
FRAMEWORK FALSE
PUBLIC_HEADER "${JsonLibHeaders}" # specify the public headers
VERSION 1.8.3
FRAMEWORK FALSE
PUBLIC_HEADER "${JsonLibHeaders}" # specify the public headers
)

install(TARGETS jsoncpp
@@ -187,19 +203,3 @@ install(TARGETS jsoncpp
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json
)
install(TARGETS scc-util
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/util
)
install(TARGETS scc
RUNTIME DESTINATION ${CMAKE_INSTALL_LCMAKE_INSTALL_BINDIRIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/incl/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*")

+ 1
- 1
cmake/FindClangFormat.cmake View File

@@ -19,7 +19,7 @@ find_program(CLANG_FORMAT_BIN NAMES ${CLANG_FORMAT_BIN_NAME})

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
CLANG_FORMAT
ClangFormat
DEFAULT_MSG
CLANG_FORMAT_BIN)


Loading…
Cancel
Save