From 57da07eb17c2cfcdca2a4a62c674173b0ec1897e Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 10 Jul 2023 12:52:48 +0200 Subject: [PATCH] rework sc wrapper build --- CMakeLists.txt | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8480fb..d7977b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,37 +178,39 @@ install(TARGETS tgc-sim ############################################################################### if(TARGET scc-sysc) if(BUILD_SHARED_LIBS) - set(THIS_PROJECT_NAME dbt-rise-tgc_sc) + set(DBT_RISE_SC_LIB_NAME dbt-rise-tgc_sc) else() - set(THIS_PROJECT_NAME dbt-rise-tgc_sc_lib) + set(DBT_RISE_SC_LIB_NAME dbt-rise-tgc_sc_lib) + set(CREATE_INTERFACE_LIB ON) endif() - project(${THIS_PROJECT_NAME} VERSION 1.0.0) - add_library(${PROJECT_NAME} + project(dbt-rise-tgc_sc VERSION 1.0.0) + + add_library(${DBT_RISE_SC_LIB_NAME} src/sysc/core_complex.cpp src/sysc/register_tgc_c.cpp ) - target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) - target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_SYSTEMC) - target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME}) + target_include_directories(${DBT_RISE_SC_LIB_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) + target_compile_definitions(${DBT_RISE_SC_LIB_NAME} PUBLIC WITH_SYSTEMC) + target_compile_definitions(${DBT_RISE_SC_LIB_NAME} PRIVATE CORE_${CORE_NAME}) foreach(F IN LISTS TGC_SOURCES) if (${F} MATCHES ".*/arch/([^/]*)\.cpp") string(REGEX REPLACE ".*/([^/]*)\.cpp" "\\1" CORE_NAME_LC ${F}) string(TOUPPER ${CORE_NAME_LC} CORE_NAME) - target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME}) + target_compile_definitions(${DBT_RISE_SC_LIB_NAME} PRIVATE CORE_${CORE_NAME}) endif() endforeach() - target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc scc-sysc) + target_link_libraries(${DBT_RISE_SC_LIB_NAME} PUBLIC dbt-rise-tgc scc-sysc) if(WITH_LLVM) - target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs}) + target_link_libraries(${DBT_RISE_SC_LIB_NAME} PUBLIC ${llvm_libs}) endif() set(LIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/sysc/core_complex.h) - set_target_properties(${PROJECT_NAME} PROPERTIES + set_target_properties(${DBT_RISE_SC_LIB_NAME} PROPERTIES VERSION ${PROJECT_VERSION} FRAMEWORK FALSE PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers ) - install(TARGETS ${PROJECT_NAME} COMPONENT ${PROJECT_NAME} + install(TARGETS ${DBT_RISE_SC_LIB_NAME} COMPONENT ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets # for downstream dependencies ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static lib RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # binaries @@ -217,13 +219,13 @@ if(TARGET scc-sysc) PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sysc # headers for mac (note the different component -> different package) INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers ) - if(NOT BUILD_SHARED_LIBS) + if(CREATE_INTERFACE_LIB) add_library(dbt-rise-tgc_sc INTERFACE) - target_include_directories(dbt-rise-tgc_sc INTERFACE $) - target_include_directories(dbt-rise-tgc_sc INTERFACE $) + target_include_directories(dbt-rise-tgc_sc INTERFACE + $) target_link_libraries(dbt-rise-tgc_sc INTERFACE - -Wl,--whole-archive,$,--no-whole-archive - $ + -Wl,--whole-archive,$,--no-whole-archive + $ scc-sysc) endif() endif()