2020-04-10 17:14:04 +02:00
|
|
|
cmake_minimum_required(VERSION 3.12)
|
2019-06-11 18:49:37 +02:00
|
|
|
|
2021-05-13 14:03:10 +02:00
|
|
|
project(dbt-core-tgc VERSION 1.0.0)
|
2019-06-11 18:49:37 +02:00
|
|
|
|
2020-05-30 13:57:01 +02:00
|
|
|
include(GNUInstallDirs)
|
2019-06-11 18:49:37 +02:00
|
|
|
|
2020-05-30 13:57:01 +02:00
|
|
|
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()
|
2019-06-18 21:20:43 +02:00
|
|
|
|
2020-05-30 13:57:01 +02:00
|
|
|
#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)
|
2019-06-11 18:49:37 +02:00
|
|
|
|
2019-06-11 21:22:07 +02:00
|
|
|
add_subdirectory(softfloat)
|
|
|
|
|
|
|
|
# library files
|
2021-05-13 14:03:10 +02:00
|
|
|
FILE(GLOB TGC_SOURCES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/iss/*.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/vm/interp/vm_*.cpp
|
|
|
|
)
|
2019-06-11 21:22:07 +02:00
|
|
|
set(LIB_SOURCES
|
2020-05-30 11:27:44 +02:00
|
|
|
src/vm/fp_functions.cpp
|
2019-06-11 21:22:07 +02:00
|
|
|
src/plugin/instruction_count.cpp
|
2020-05-30 13:57:01 +02:00
|
|
|
src/plugin/cycle_estimate.cpp
|
2021-05-13 14:03:10 +02:00
|
|
|
${TGC_SOURCES}
|
2020-05-30 13:57:01 +02:00
|
|
|
)
|
2021-05-13 14:03:10 +02:00
|
|
|
|
2020-05-30 13:57:01 +02:00
|
|
|
if(WITH_LLVM)
|
2021-05-13 14:03:10 +02:00
|
|
|
set(LIB_SOURCES ${LIB_SOURCES}
|
2020-05-30 13:57:01 +02:00
|
|
|
src/vm/llvm/fp_impl.cpp
|
2021-05-13 14:03:10 +02:00
|
|
|
#src/vm/llvm/vm_tgf_b.cpp
|
|
|
|
#src/vm/llvm/vm_tgf_c.cpp
|
|
|
|
)
|
2020-05-30 13:57:01 +02:00
|
|
|
endif()
|
2019-06-11 21:22:07 +02:00
|
|
|
|
|
|
|
# Define the library
|
2021-03-23 18:13:32 +01:00
|
|
|
add_library(${PROJECT_NAME} SHARED ${LIB_SOURCES})
|
2020-12-30 08:29:52 +01:00
|
|
|
# list code gen dependencies
|
2021-06-07 22:22:36 +02:00
|
|
|
if(TARGET ${CORE_NAME}_cpp)
|
|
|
|
add_dependencies(${PROJECT_NAME} ${CORE_NAME}_cpp)
|
2021-03-12 11:16:24 +01:00
|
|
|
endif()
|
2020-12-30 08:29:52 +01:00
|
|
|
|
2021-03-23 18:13:32 +01:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-shift-count-overflow)
|
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC incl)
|
2021-04-07 17:42:08 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp)
|
2021-03-23 18:13:32 +01:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-core -Wl,--no-whole-archive)
|
2021-07-26 12:03:40 +02:00
|
|
|
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()
|
|
|
|
#target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_program_options_LIBRARY} ${Boost_system_LIBRARY} ${Boost_thread_LIBRARY} ${Boost_filesystem_LIBRARY} )
|
2021-03-23 18:13:32 +01:00
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
2020-05-30 13:57:01 +02:00
|
|
|
VERSION ${PROJECT_VERSION}
|
2019-06-11 21:22:07 +02:00
|
|
|
FRAMEWORK FALSE
|
|
|
|
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
|
|
|
)
|
|
|
|
|
2021-07-26 12:03:40 +02:00
|
|
|
include(FindSystemCPackage)
|
2019-06-11 21:22:07 +02:00
|
|
|
if(SystemC_FOUND)
|
2021-03-23 18:13:32 +01:00
|
|
|
add_library(${PROJECT_NAME}_sc src/sysc/core_complex.cpp)
|
2021-05-13 15:38:33 +02:00
|
|
|
target_compile_definitions(${PROJECT_NAME}_sc PUBLIC WITH_SYSTEMC)
|
2021-06-07 22:22:36 +02:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
|
2021-05-16 15:06:42 +02:00
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_b.h)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_sc PRIVATE CORE_TGC_B)
|
|
|
|
endif()
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_c.h)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_sc PRIVATE CORE_TGC_C)
|
|
|
|
endif()
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss/arch/tgc_d.h)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_sc PRIVATE CORE_TGC_D)
|
|
|
|
endif()
|
2021-04-07 17:42:08 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME}_sc PUBLIC ${PROJECT_NAME} scc)
|
2020-05-30 13:57:01 +02:00
|
|
|
if(WITH_LLVM)
|
2021-03-23 18:13:32 +01:00
|
|
|
target_link_libraries(${PROJECT_NAME}_sc PUBLIC ${llvm_libs})
|
2019-06-11 21:22:07 +02:00
|
|
|
endif()
|
2021-03-23 18:13:32 +01:00
|
|
|
set_target_properties(${PROJECT_NAME}_sc PROPERTIES
|
2020-05-30 13:57:01 +02:00
|
|
|
VERSION ${PROJECT_VERSION}
|
2019-06-11 21:22:07 +02:00
|
|
|
FRAMEWORK FALSE
|
|
|
|
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-05-13 14:03:10 +02:00
|
|
|
project(tgc-sim)
|
2021-07-26 12:03:40 +02:00
|
|
|
find_package(Boost COMPONENTS program_options system thread filesystem REQUIRED)
|
|
|
|
|
2021-03-23 18:13:32 +01:00
|
|
|
add_executable(${PROJECT_NAME} src/main.cpp)
|
2020-05-30 13:57:01 +02:00
|
|
|
# This sets the include directory for the reference project. This is the -I flag in gcc.
|
2021-05-13 15:38:33 +02:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
|
2020-05-30 13:57:01 +02:00
|
|
|
if(WITH_LLVM)
|
2021-03-23 18:13:32 +01:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LLVM)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
|
2020-05-30 13:57:01 +02:00
|
|
|
endif()
|
2019-06-11 21:22:07 +02:00
|
|
|
# Links the target exe against the libraries
|
2021-05-13 14:03:10 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} dbt-core-tgc)
|
2021-03-23 18:13:32 +01:00
|
|
|
target_link_libraries(${PROJECT_NAME} jsoncpp)
|
2021-07-26 12:03:40 +02:00
|
|
|
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} ${Boost_LIBRARIES}) #${Boost_program_options_LIBRARY} ${Boost_system_LIBRARY} ${Boost_filesystem_LIBRARY} ${Boost_thread_LIBRARY} )
|
|
|
|
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
|
2019-06-11 21:22:07 +02:00
|
|
|
if (Tcmalloc_FOUND)
|
2021-03-23 18:13:32 +01:00
|
|
|
target_link_libraries(${PROJECT_NAME} ${Tcmalloc_LIBRARIES})
|
2019-06-11 21:22:07 +02:00
|
|
|
endif(Tcmalloc_FOUND)
|
|
|
|
|
2021-05-13 14:03:10 +02:00
|
|
|
install(TARGETS dbt-core-tgc tgc-sim
|
2019-06-11 21:22:07 +02:00
|
|
|
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
|
2020-05-30 13:57:01 +02:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib
|
|
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # for mac
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} COMPONENT devel # headers for mac (note the different component -> different package)
|
|
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
|
2019-06-11 21:22:07 +02:00
|
|
|
)
|