fix SystemC lib handling in build system

This commit is contained in:
Eyck Jentzsch 2021-07-27 12:25:31 +02:00
parent 5ef5d57d30
commit da819d8890
1 changed files with 33 additions and 28 deletions

View File

@ -5,13 +5,13 @@ project(dbt-core-tgc VERSION 1.0.0)
include(GNUInstallDirs) include(GNUInstallDirs)
if(WITH_LLVM) if(WITH_LLVM)
if(DEFINED ENV{LLVM_HOME}) if(DEFINED ENV{LLVM_HOME})
find_path (LLVM_DIR LLVM-Config.cmake $ENV{LLVM_HOME}/lib/cmake/llvm) find_path (LLVM_DIR LLVM-Config.cmake $ENV{LLVM_HOME}/lib/cmake/llvm)
endif(DEFINED ENV{LLVM_HOME}) endif(DEFINED ENV{LLVM_HOME})
find_package(LLVM REQUIRED CONFIG) find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
llvm_map_components_to_libnames(llvm_libs support core mcjit x86codegen x86asmparser) llvm_map_components_to_libnames(llvm_libs support core mcjit x86codegen x86asmparser)
endif() endif()
#Mac needed variables (adapt for your needs - http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH) #Mac needed variables (adapt for your needs - http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH)
@ -29,7 +29,7 @@ FILE(GLOB TGC_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/vm/interp/vm_*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/interp/vm_*.cpp
) )
set(LIB_SOURCES set(LIB_SOURCES
src/vm/fp_functions.cpp src/vm/fp_functions.cpp
src/plugin/instruction_count.cpp src/plugin/instruction_count.cpp
src/plugin/cycle_estimate.cpp src/plugin/cycle_estimate.cpp
${TGC_SOURCES} ${TGC_SOURCES}
@ -37,7 +37,7 @@ set(LIB_SOURCES
if(WITH_LLVM) if(WITH_LLVM)
set(LIB_SOURCES ${LIB_SOURCES} set(LIB_SOURCES ${LIB_SOURCES}
src/vm/llvm/fp_impl.cpp src/vm/llvm/fp_impl.cpp
#src/vm/llvm/vm_tgf_b.cpp #src/vm/llvm/vm_tgf_b.cpp
#src/vm/llvm/vm_tgf_c.cpp #src/vm/llvm/vm_tgf_c.cpp
) )
@ -55,13 +55,12 @@ target_include_directories(${PROJECT_NAME} PUBLIC incl)
target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp) target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp)
target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-core -Wl,--no-whole-archive) target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-core -Wl,--no-whole-archive)
if(TARGET CONAN_PKG::elfio) if(TARGET CONAN_PKG::elfio)
target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::elfio) target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::elfio)
elseif(TARGET elfio::elfio) elseif(TARGET elfio::elfio)
target_link_libraries(${PROJECT_NAME} PUBLIC elfio::elfio) target_link_libraries(${PROJECT_NAME} PUBLIC elfio::elfio)
else() else()
message(FATAL_ERROR "No elfio library found, maybe a find_package() call is missing") message(FATAL_ERROR "No elfio library found, maybe a find_package() call is missing")
endif() endif()
#target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_program_options_LIBRARY} ${Boost_system_LIBRARY} ${Boost_thread_LIBRARY} ${Boost_filesystem_LIBRARY} )
set_target_properties(${PROJECT_NAME} PROPERTIES set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
FRAMEWORK FALSE FRAMEWORK FALSE
@ -70,27 +69,33 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
include(FindSystemCPackage) include(FindSystemCPackage)
if(SystemC_FOUND) if(SystemC_FOUND)
add_library(${PROJECT_NAME}_sc src/sysc/core_complex.cpp) add_library(${PROJECT_NAME}_sc src/sysc/core_complex.cpp)
target_compile_definitions(${PROJECT_NAME}_sc PUBLIC WITH_SYSTEMC) target_compile_definitions(${PROJECT_NAME}_sc PUBLIC WITH_SYSTEMC)
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME}) target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_b.h) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_b.h)
target_compile_definitions(${PROJECT_NAME}_sc PRIVATE CORE_TGC_B) target_compile_definitions(${PROJECT_NAME}_sc PRIVATE CORE_TGC_B)
endif() endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_c.h) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_c.h)
target_compile_definitions(${PROJECT_NAME}_sc PRIVATE CORE_TGC_C) target_compile_definitions(${PROJECT_NAME}_sc PRIVATE CORE_TGC_C)
endif() endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_d.h) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_d.h)
target_compile_definitions(${PROJECT_NAME}_sc PRIVATE CORE_TGC_D) target_compile_definitions(${PROJECT_NAME}_sc PRIVATE CORE_TGC_D)
endif() endif()
target_link_libraries(${PROJECT_NAME}_sc PUBLIC ${PROJECT_NAME} scc) target_link_libraries(${PROJECT_NAME}_sc PUBLIC ${PROJECT_NAME} scc)
if(WITH_LLVM) if(WITH_LLVM)
target_link_libraries(${PROJECT_NAME}_sc PUBLIC ${llvm_libs}) target_link_libraries(${PROJECT_NAME}_sc PUBLIC ${llvm_libs})
endif() endif()
set_target_properties(${PROJECT_NAME}_sc PROPERTIES if(SystemC_INCLUDE_DIRS)
VERSION ${PROJECT_VERSION} target_include_directories (${PROJECT_NAME} PUBLIC ${SystemC_INCLUDE_DIRS})
FRAMEWORK FALSE target_link_directories(${PROJECT_NAME} PUBLIC ${SystemC_LIBRARY_DIRS})
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers endif()
) target_link_libraries(${PROJECT_NAME} PUBLIC ${SystemC_LIBRARIES} )
set_target_properties(${PROJECT_NAME}_sc PROPERTIES
VERSION ${PROJECT_VERSION}
FRAMEWORK FALSE
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
)
endif() endif()
project(tgc-sim) project(tgc-sim)
@ -100,16 +105,16 @@ add_executable(${PROJECT_NAME} src/main.cpp)
# This sets the include directory for the reference project. This is the -I flag in gcc. # This sets the include directory for the reference project. This is the -I flag in gcc.
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME}) target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
if(WITH_LLVM) if(WITH_LLVM)
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LLVM) target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LLVM)
target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs}) target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
endif() endif()
# Links the target exe against the libraries # Links the target exe against the libraries
target_link_libraries(${PROJECT_NAME} dbt-core-tgc) target_link_libraries(${PROJECT_NAME} dbt-core-tgc)
target_link_libraries(${PROJECT_NAME} jsoncpp) target_link_libraries(${PROJECT_NAME} jsoncpp)
if(TARGET Boost::program_options) if(TARGET Boost::program_options)
target_link_libraries(${PROJECT_NAME} Boost::program_options Boost::thread) target_link_libraries(${PROJECT_NAME} Boost::program_options Boost::thread)
else() else()
target_link_libraries(${PROJECT_NAME} ${BOOST_program_options_LIBRARY} ${BOOST_thread_LIBRARY}) target_link_libraries(${PROJECT_NAME} ${BOOST_program_options_LIBRARY} ${BOOST_thread_LIBRARY})
endif() endif()
#target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES}) #${Boost_program_options_LIBRARY} ${Boost_system_LIBRARY} ${Boost_filesystem_LIBRARY} ${Boost_thread_LIBRARY} ) #target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES}) #${Boost_program_options_LIBRARY} ${Boost_system_LIBRARY} ${Boost_filesystem_LIBRARY} ${Boost_thread_LIBRARY} )
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS}) target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})