rework sc wrapper build

This commit is contained in:
Eyck Jentzsch 2023-07-10 12:52:48 +02:00
parent b4b03f7850
commit 57da07eb17
1 changed files with 19 additions and 17 deletions

View File

@ -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_PROPERTY:${THIS_PROJECT_NAME},INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(dbt-rise-tgc_sc INTERFACE $<TARGET_PROPERTY:dbt-rise-tgc,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(dbt-rise-tgc_sc INTERFACE
$<TARGET_PROPERTY:${DBT_RISE_SC_LIB_NAME},INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(dbt-rise-tgc_sc INTERFACE
-Wl,--whole-archive,$<TARGET_FILE:${THIS_PROJECT_NAME}>,--no-whole-archive
$<TARGET_PROPERTY:${THIS_PROJECT_NAME},INTERFACE_LINK_LIBRARIES>
-Wl,--whole-archive,$<TARGET_FILE:${DBT_RISE_SC_LIB_NAME}>,--no-whole-archive
$<TARGET_PROPERTY:${DBT_RISE_SC_LIB_NAME},INTERFACE_LINK_LIBRARIES>
scc-sysc)
endif()
endif()