fix CMakeList.txt so that it builds without platform and external libs

This commit is contained in:
Eyck Jentzsch 2020-12-23 16:23:43 +00:00
parent be49b8b545
commit d43b35949e
1 changed files with 27 additions and 28 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.12)
project("riscv" VERSION 1.0.0) project("tgfs" VERSION 1.0.0)
include(GNUInstallDirs) include(GNUInstallDirs)
@ -28,7 +28,7 @@ add_subdirectory(softfloat)
# library files # library files
FILE(GLOB RiscVSCHeaders ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*.h ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*/*.h) FILE(GLOB RiscVSCHeaders ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*.h ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*/*.h)
set(LIB_HEADERS ${RiscVSCHeaders} ) set(LIB_HEADERS tgfscVSCHeaders} )
set(LIB_SOURCES set(LIB_SOURCES
src/iss/tgf_b.cpp src/iss/tgf_b.cpp
src/iss/tgf_c.cpp src/iss/tgf_c.cpp
@ -49,56 +49,55 @@ set(LIB_SOURCES ${LIB_SOURCES}
endif() endif()
# Define the library # Define the library
add_library(riscv SHARED ${LIB_SOURCES}) add_library(tgfs SHARED ${LIB_SOURCES})
target_compile_options(riscv PRIVATE -Wno-shift-count-overflow) target_compile_options(tgfs PRIVATE -Wno-shift-count-overflow)
target_include_directories(riscv PUBLIC incl ../external/elfio) target_include_directories(tgfs PUBLIC incl)
target_link_libraries(riscv PUBLIC softfloat scc-util) target_link_libraries(tgfs PUBLIC softfloat scc-util)
target_link_libraries(riscv PUBLIC -Wl,--whole-archive dbt-core -Wl,--no-whole-archive) target_link_libraries(tgfs PUBLIC -Wl,--whole-archive dbt-core -Wl,--no-whole-archive)
set_target_properties(riscv PROPERTIES set_target_properties(tgfs PROPERTIES
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
FRAMEWORK FALSE FRAMEWORK FALSE
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
) )
if(SystemC_FOUND) if(SystemC_FOUND)
add_library(riscv_sc src/sysc/core_complex.cpp) add_library(tgfs_sc src/sysc/core_complex.cpp)
target_compile_definitions(riscv_sc PUBLIC WITH_SYSTEMC) target_compile_definitions(tgfs_sc PUBLIC WITH_SYSTEMC)
target_include_directories(riscv_sc PUBLIC ../incl ${SystemC_INCLUDE_DIRS} ${CCI_INCLUDE_DIRS}) target_include_directories(tgfs_sc PUBLIC ../incl ${SystemC_INCLUDE_DIRS} ${CCI_INCLUDE_DIRS})
if(SCV_FOUND) if(SCV_FOUND)
target_compile_definitions(riscv_sc PUBLIC WITH_SCV) target_compile_definitions(tgfs_sc PUBLIC WITH_SCV)
target_include_directories(riscv_sc PUBLIC ${SCV_INCLUDE_DIRS}) target_include_directories(tgfs_sc PUBLIC ${SCV_INCLUDE_DIRS})
endif() endif()
target_link_libraries(riscv_sc PUBLIC riscv scc ) target_link_libraries(tgfs_sc PUBLIC tgfs scc )
if(WITH_LLVM) if(WITH_LLVM)
target_link_libraries(riscv_sc PUBLIC ${llvm_libs}) target_link_libraries(tgfs_sc PUBLIC ${llvm_libs})
endif() endif()
target_link_libraries(riscv_sc PUBLIC ${Boost_LIBRARIES} ) target_link_libraries(tgfs_sc PUBLIC ${Boost_LIBRARIES} )
set_target_properties(riscv_sc PROPERTIES set_target_properties(tgfs_sc PROPERTIES
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
FRAMEWORK FALSE FRAMEWORK FALSE
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
) )
endif() endif()
project("riscv-sim") project("tgfs-sim")
add_executable(riscv-sim src/main.cpp) add_executable(tgfs-sim 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_include_directories(riscv-sim PRIVATE ../external/libGIS)
if(WITH_LLVM) if(WITH_LLVM)
target_compile_definitions(riscv-sim PRIVATE WITH_LLVM) target_compile_definitions(tgfs-sim PRIVATE WITH_LLVM)
target_link_libraries(riscv-sim PUBLIC ${llvm_libs}) target_link_libraries(tgfs-sim PUBLIC ${llvm_libs})
endif() endif()
# Links the target exe against the libraries # Links the target exe against the libraries
target_link_libraries(riscv-sim riscv) target_link_libraries(tgfs-sim tgfs)
target_link_libraries(riscv-sim jsoncpp) target_link_libraries(tgfs-sim jsoncpp)
target_link_libraries(riscv-sim external) target_link_libraries(tgfs-sim ${Boost_LIBRARIES} )
target_link_libraries(riscv-sim ${Boost_LIBRARIES} )
if (Tcmalloc_FOUND) if (Tcmalloc_FOUND)
target_link_libraries(riscv-sim ${Tcmalloc_LIBRARIES}) target_link_libraries(tgfs-sim ${Tcmalloc_LIBRARIES})
endif(Tcmalloc_FOUND) endif(Tcmalloc_FOUND)
install(TARGETS riscv riscv-sim install(TARGETS tgfs tgfs-sim
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries