DBT-RISE-TGC/CMakeLists.txt

185 lines
7.2 KiB
CMake
Raw Normal View History

2020-04-10 17:14:04 +02:00
cmake_minimum_required(VERSION 3.12)
###############################################################################
#
###############################################################################
2021-07-27 15:55:08 +02:00
project(dbt-rise-tgc VERSION 1.0.0)
include(GNUInstallDirs)
find_package(elfio)
2022-01-12 07:21:16 +01:00
find_package(Boost COMPONENTS coroutine)
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
#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 21:22:07 +02:00
add_subdirectory(softfloat)
# library files
2021-11-25 19:59:50 +01:00
FILE(GLOB TGC_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/iss/*.cpp)
FILE(GLOB TGC_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/interp/vm_*.cpp)
2019-06-11 21:22:07 +02:00
set(LIB_SOURCES
src/vm/fp_functions.cpp
2019-06-11 21:22:07 +02:00
src/plugin/instruction_count.cpp
2022-01-31 21:38:18 +01:00
src/plugin/cov.cpp
2021-05-13 14:03:10 +02:00
${TGC_SOURCES}
2021-11-25 19:59:50 +01:00
${TGC_VM_SOURCES}
)
2022-02-01 19:28:11 +01:00
if(TARGET RapidJSON)
list(APPEND LIB_SOURCES src/plugin/cycle_estimate.cpp)
endif()
2021-05-13 14:03:10 +02:00
if(WITH_LLVM)
2021-10-12 14:24:55 +02:00
FILE(GLOB TGC_LLVM_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/vm/llvm/vm_*.cpp
)
list(APPEND LIB_SOURCES ${TGC_LLVM_SOURCES})
endif()
if(WITH_TCC)
FILE(GLOB TGC_TCC_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/vm/tcc/vm_*.cpp
)
list(APPEND LIB_SOURCES ${TGC_TCC_SOURCES})
endif()
2019-06-11 21:22:07 +02:00
# Define the library
2021-10-10 19:06:41 +02:00
add_library(${PROJECT_NAME} ${LIB_SOURCES})
# list code gen dependencies
if(TARGET ${CORE_NAME}_cpp)
add_dependencies(${PROJECT_NAME} ${CORE_NAME}_cpp)
endif()
2021-10-10 19:56:33 +02:00
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
2021-10-10 19:06:41 +02:00
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-shift-count-overflow)
2021-10-10 19:56:33 +02:00
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /wd4293)
2021-10-10 19:06:41 +02:00
endif()
2021-03-23 18:13:32 +01:00
target_include_directories(${PROJECT_NAME} PUBLIC incl)
2022-01-12 07:21:16 +01:00
target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp Boost::coroutine)
2021-10-10 19:56:33 +02:00
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
2021-10-10 19:06:41 +02:00
target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-core -Wl,--no-whole-archive)
else()
target_link_libraries(${PROJECT_NAME} PUBLIC dbt-core)
endif()
2021-07-26 12:03:40 +02:00
if(TARGET CONAN_PKG::elfio)
target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::elfio)
2021-07-26 12:03:40 +02:00
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")
2021-07-26 12:03:40 +02:00
endif()
2022-02-01 19:28:11 +01:00
if(TARGET RapidJSON)
target_link_libraries(${PROJECT_NAME} PUBLIC RapidJSON)
endif()
2021-03-23 18:13:32 +01:00
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
2019-06-11 21:22:07 +02:00
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
)
###############################################################################
#
###############################################################################
2021-05-13 14:03:10 +02:00
project(tgc-sim)
2021-07-27 15:55:08 +02:00
find_package(Boost COMPONENTS program_options thread REQUIRED)
2021-07-26 12:03:40 +02:00
2021-03-23 18:13:32 +01:00
add_executable(${PROJECT_NAME} src/main.cpp)
2021-11-25 19:59:50 +01:00
foreach(F IN LISTS TGC_SOURCES)
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})
endforeach()
if(WITH_LLVM)
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LLVM)
target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
endif()
2019-06-11 21:22:07 +02:00
# Links the target exe against the libraries
2021-10-10 19:06:41 +02:00
target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc)
2021-07-26 12:03:40 +02:00
if(TARGET Boost::program_options)
2021-11-02 10:24:34 +01:00
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::program_options)
2021-07-26 12:03:40 +02:00
else()
2021-11-02 10:24:34 +01:00
target_link_libraries(${PROJECT_NAME} PUBLIC ${BOOST_program_options_LIBRARY})
2021-07-26 12:03:40 +02:00
endif()
2021-10-10 19:06:41 +02:00
target_link_libraries(${PROJECT_NAME} PUBLIC ${CMAKE_DL_LIBS})
2019-06-11 21:22:07 +02:00
if (Tcmalloc_FOUND)
2021-10-10 19:06:41 +02:00
target_link_libraries(${PROJECT_NAME} PUBLIC ${Tcmalloc_LIBRARIES})
2019-06-11 21:22:07 +02:00
endif(Tcmalloc_FOUND)
install(TARGETS tgc-sim
2019-06-11 21:22:07 +02:00
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
2019-06-11 21:22:07 +02:00
)
###############################################################################
#
###############################################################################
2021-07-27 15:55:08 +02:00
project(dbt-rise-tgc_sc VERSION 1.0.0)
include(SystemCPackage)
2021-07-27 15:55:08 +02:00
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})
foreach(F IN LISTS TGC_SOURCES)
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})
endforeach()
2021-07-27 15:55:08 +02:00
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)
2021-07-27 15:55:08 +02:00
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}
2021-07-27 15:55:08 +02:00
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)
2021-07-27 15:55:08 +02:00
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
)
endif()