161 lines
6.6 KiB
CMake
161 lines
6.6 KiB
CMake
cmake_minimum_required(VERSION 3.12)
|
|
###############################################################################
|
|
#
|
|
###############################################################################
|
|
project(dbt-rise-tgc VERSION 1.0.0)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
if(WITH_LLVM)
|
|
if(DEFINED ENV{LLVM_HOME})
|
|
find_path (LLVM_DIR LLVM-Config.cmake $ENV{LLVM_HOME}/lib/cmake/llvm)
|
|
endif(DEFINED ENV{LLVM_HOME})
|
|
find_package(LLVM REQUIRED CONFIG)
|
|
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
|
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
|
llvm_map_components_to_libnames(llvm_libs support core mcjit x86codegen x86asmparser)
|
|
endif()
|
|
|
|
#Mac needed variables (adapt for your needs - http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH)
|
|
#set(CMAKE_MACOSX_RPATH ON)
|
|
#set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
|
#set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
|
#set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
|
#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
add_subdirectory(softfloat)
|
|
|
|
# library files
|
|
FILE(GLOB TGC_SOURCES
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/iss/*.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/vm/interp/vm_*.cpp
|
|
)
|
|
set(LIB_SOURCES
|
|
src/vm/fp_functions.cpp
|
|
src/plugin/instruction_count.cpp
|
|
src/plugin/cycle_estimate.cpp
|
|
${TGC_SOURCES}
|
|
)
|
|
|
|
if(WITH_LLVM)
|
|
set(LIB_SOURCES ${LIB_SOURCES}
|
|
src/vm/llvm/fp_impl.cpp
|
|
#src/vm/llvm/vm_tgf_b.cpp
|
|
#src/vm/llvm/vm_tgf_c.cpp
|
|
)
|
|
endif()
|
|
|
|
# Define the library
|
|
add_library(${PROJECT_NAME} SHARED ${LIB_SOURCES})
|
|
# list code gen dependencies
|
|
if(TARGET ${CORE_NAME}_cpp)
|
|
add_dependencies(${PROJECT_NAME} ${CORE_NAME}_cpp)
|
|
endif()
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-shift-count-overflow)
|
|
target_include_directories(${PROJECT_NAME} PUBLIC incl)
|
|
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)
|
|
if(TARGET CONAN_PKG::elfio)
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::elfio)
|
|
elseif(TARGET elfio::elfio)
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC elfio::elfio)
|
|
else()
|
|
message(FATAL_ERROR "No elfio library found, maybe a find_package() call is missing")
|
|
endif()
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
VERSION ${PROJECT_VERSION}
|
|
FRAMEWORK FALSE
|
|
)
|
|
install(TARGETS ${PROJECT_NAME} COMPONENT ${PROJECT_NAME}
|
|
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static lib
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # binaries
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # shared lib
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} # for mac
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} # headers for mac (note the different component -> different package)
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
|
|
)
|
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss COMPONENT ${PROJECT_NAME}
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # target directory
|
|
FILES_MATCHING # install only matched files
|
|
PATTERN "*.h" # select header files
|
|
)
|
|
###############################################################################
|
|
#
|
|
###############################################################################
|
|
project(tgc-sim)
|
|
find_package(Boost COMPONENTS program_options thread REQUIRED)
|
|
|
|
add_executable(${PROJECT_NAME} src/main.cpp)
|
|
# 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})
|
|
if(WITH_LLVM)
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LLVM)
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
|
|
endif()
|
|
# Links the target exe against the libraries
|
|
target_link_libraries(${PROJECT_NAME} dbt-rise-tgc)
|
|
#target_link_libraries(${PROJECT_NAME} jsoncpp)
|
|
if(TARGET Boost::program_options)
|
|
target_link_libraries(${PROJECT_NAME} Boost::program_options Boost::thread)
|
|
else()
|
|
target_link_libraries(${PROJECT_NAME} ${BOOST_program_options_LIBRARY} ${BOOST_thread_LIBRARY})
|
|
endif()
|
|
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
|
|
if (Tcmalloc_FOUND)
|
|
target_link_libraries(${PROJECT_NAME} ${Tcmalloc_LIBRARIES})
|
|
endif(Tcmalloc_FOUND)
|
|
|
|
install(TARGETS tgc-sim
|
|
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static lib
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # binaries
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # shared lib
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} # for mac
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} # headers for mac (note the different component -> different package)
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
|
|
)
|
|
###############################################################################
|
|
#
|
|
###############################################################################
|
|
project(dbt-rise-tgc_sc VERSION 1.0.0)
|
|
|
|
include(SystemCPackage)
|
|
if(SystemC_FOUND)
|
|
add_library(${PROJECT_NAME} src/sysc/core_complex.cpp)
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_SYSTEMC)
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_b.h)
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_TGC_B)
|
|
endif()
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_c.h)
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_TGC_C)
|
|
endif()
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_d.h)
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_TGC_D)
|
|
endif()
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc scc)
|
|
if(WITH_LLVM)
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
|
|
endif()
|
|
|
|
set(LIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/core_complex.h)
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
VERSION ${PROJECT_VERSION}
|
|
FRAMEWORK FALSE
|
|
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
|
)
|
|
install(TARGETS ${PROJECT_NAME} COMPONENT ${PROJECT_NAME}
|
|
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static lib
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # binaries
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # shared lib
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} # for mac
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sysc # headers for mac (note the different component -> different package)
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
|
|
)
|
|
endif()
|
|
|