Modernized CMake
This commit is contained in:
parent
67d9beb7bd
commit
2758933c16
|
@ -7,8 +7,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
|||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
|
||||
add_subdirectory(softfloat)
|
||||
|
||||
# Set the name of your project here
|
||||
project("riscv")
|
||||
|
||||
|
@ -22,8 +20,7 @@ include_directories(
|
|||
${SOFTFLOAT_INCLUDE_DIRS}
|
||||
${LLVM_INCLUDE_DIRS}
|
||||
)
|
||||
add_dependent_subproject(dbt-core)
|
||||
add_dependent_subproject(sc-components)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/incl
|
||||
${PROJECT_SOURCE_DIR}/../external/elfio
|
||||
|
@ -39,7 +36,99 @@ 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(src)
|
||||
add_subdirectory(softfloat)
|
||||
|
||||
# library files
|
||||
FILE(GLOB RiscVSCHeaders ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*.h ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*/*.h)
|
||||
set(LIB_HEADERS ${RiscVSCHeaders} )
|
||||
set(LIB_SOURCES
|
||||
src/iss/rv32gc.cpp
|
||||
src/iss/rv32imac.cpp
|
||||
src/iss/rv64i.cpp
|
||||
src/iss/rv64gc.cpp
|
||||
src/internal/fp_functions.cpp
|
||||
src/internal/vm_rv32gc.cpp
|
||||
src/internal/vm_rv32imac.cpp
|
||||
src/internal/vm_rv64i.cpp
|
||||
src/internal/vm_rv64gc.cpp
|
||||
src/plugin/instruction_count.cpp
|
||||
src/plugin/cycle_estimate.cpp)
|
||||
|
||||
# Define two variables in order not to repeat ourselves.
|
||||
set(LIBRARY_NAME riscv)
|
||||
|
||||
# Define the library
|
||||
add_library(${LIBRARY_NAME} ${LIB_SOURCES})
|
||||
SET(${LIBRARY_NAME} -Wl,-whole-archive -l${LIBRARY_NAME} -Wl,-no-whole-archive)
|
||||
target_link_libraries(${LIBRARY_NAME} softfloat)
|
||||
target_link_libraries(${LIBRARY_NAME} dbt-core)
|
||||
target_link_libraries(${LIBRARY_NAME} scc)
|
||||
set_target_properties(${LIBRARY_NAME} PROPERTIES
|
||||
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
|
||||
FRAMEWORK FALSE
|
||||
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
||||
)
|
||||
#set_property(TARGET ${LIBRARY_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(SystemC_FOUND)
|
||||
set(SC_LIBRARY_NAME riscv_sc)
|
||||
add_library(${SC_LIBRARY_NAME} SHARED src/sysc/core_complex.cpp)
|
||||
add_definitions(-DWITH_SYSTEMC)
|
||||
include_directories(${SystemC_INCLUDE_DIRS})
|
||||
|
||||
include_directories(${CCI_INCLUDE_DIRS})
|
||||
|
||||
if(SCV_FOUND)
|
||||
add_definitions(-DWITH_SCV)
|
||||
include_directories(${SCV_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_link_libraries(${SC_LIBRARY_NAME} ${LIBRARY_NAME})
|
||||
target_link_libraries(${SC_LIBRARY_NAME} dbt-core)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} softfloat)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} scc)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} external)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} ${llvm_libs})
|
||||
target_link_libraries(${SC_LIBRARY_NAME} ${Boost_LIBRARIES} )
|
||||
set_target_properties(${SC_LIBRARY_NAME} PROPERTIES
|
||||
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
|
||||
FRAMEWORK FALSE
|
||||
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
||||
)
|
||||
endif()
|
||||
|
||||
# This is a make target, so you can do a "make riscv-sc"
|
||||
set(APPLICATION_NAME riscv-sim)
|
||||
|
||||
add_executable(${APPLICATION_NAME} src/main.cpp)
|
||||
|
||||
# Links the target exe against the libraries
|
||||
target_link_libraries(${APPLICATION_NAME} ${LIBRARY_NAME})
|
||||
target_link_libraries(${APPLICATION_NAME} jsoncpp)
|
||||
target_link_libraries(${APPLICATION_NAME} dbt-core)
|
||||
target_link_libraries(${APPLICATION_NAME} softfloat)
|
||||
target_link_libraries(${APPLICATION_NAME} external)
|
||||
target_link_libraries(${APPLICATION_NAME} ${llvm_libs})
|
||||
target_link_libraries(${APPLICATION_NAME} ${Boost_LIBRARIES} )
|
||||
if (Tcmalloc_FOUND)
|
||||
target_link_libraries(${APPLICATION_NAME} ${Tcmalloc_LIBRARIES})
|
||||
endif(Tcmalloc_FOUND)
|
||||
|
||||
# Says how and where to install software
|
||||
# Targets:
|
||||
# * <prefix>/lib/<libraries>
|
||||
# * header location after install: <prefix>/include/<project>/*.h
|
||||
# * headers can be included by C++ code `#<project>/Bar.hpp>`
|
||||
install(TARGETS ${LIBRARY_NAME} ${APPLICATION_NAME}
|
||||
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
|
||||
ARCHIVE DESTINATION lib COMPONENT libs # static lib
|
||||
RUNTIME DESTINATION bin COMPONENT libs # binaries
|
||||
LIBRARY DESTINATION lib COMPONENT libs # shared lib
|
||||
FRAMEWORK DESTINATION bin COMPONENT libs # for mac
|
||||
PUBLIC_HEADER DESTINATION incl/${PROJECT_NAME} COMPONENT devel # headers for mac (note the different component -> different package)
|
||||
INCLUDES DESTINATION incl # headers
|
||||
)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# SYSTEM PACKAGING (RPM, TGZ, ...)
|
||||
|
|
|
@ -26,13 +26,6 @@ add_definitions(
|
|||
# -DTHREAD_LOCAL=__thread
|
||||
)
|
||||
|
||||
set(SOFTFLOAT_INCLUDE_DIRS
|
||||
${PROJECT_SOURCE_DIR}/build/Linux-x86_64-GCC
|
||||
${PROJECT_SOURCE_DIR}/source/include
|
||||
${PROJECT_SOURCE_DIR}/source/${SPECIALIZATION}
|
||||
)
|
||||
|
||||
include_directories(${SOFTFLOAT_INCLUDE_DIRS})
|
||||
|
||||
set(LIB_HEADERS source/include/softfloat.h source/include/softfloat_types.h)
|
||||
set(PRIMITIVES
|
||||
|
@ -354,6 +347,8 @@ set(LIBRARY_NAME softfloat)
|
|||
# Define the library
|
||||
add_library(${LIBRARY_NAME} ${LIB_SOURCES})
|
||||
set_property(TARGET ${LIBRARY_NAME} PROPERTY C_STANDARD 99)
|
||||
target_include_directories(${LIBRARY_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/build/Linux-x86_64-GCC)
|
||||
target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/source/include ${CMAKE_CURRENT_SOURCE_DIR}/source/${SPECIALIZATION})
|
||||
# Set the build version. It will be used in the name of the lib, with corresponding
|
||||
# symlinks created. SOVERSION could also be specified for api version.
|
||||
set_target_properties(${LIBRARY_NAME} PROPERTIES
|
||||
|
@ -361,7 +356,6 @@ set_target_properties(${LIBRARY_NAME} PROPERTIES
|
|||
FRAMEWORK FALSE
|
||||
PUBLIC_HEADER "${LIB_HEADERS}"
|
||||
)
|
||||
target_include_directories (softfloat PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/source/include)
|
||||
|
||||
# Says how and where to install software
|
||||
# Targets:
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
# library files
|
||||
FILE(GLOB RiscVSCHeaders ${PROJECT_SOURCE_DIR}/incl/sysc/*.h ${PROJECT_SOURCE_DIR}/incl/sysc/*/*.h)
|
||||
set(LIB_HEADERS ${RiscVSCHeaders} )
|
||||
set(LIB_SOURCES
|
||||
iss/rv32gc.cpp
|
||||
iss/rv32imac.cpp
|
||||
iss/rv64i.cpp
|
||||
iss/rv64gc.cpp
|
||||
internal/fp_functions.cpp
|
||||
internal/vm_rv32gc.cpp
|
||||
internal/vm_rv32imac.cpp
|
||||
internal/vm_rv64i.cpp
|
||||
internal/vm_rv64gc.cpp
|
||||
plugin/instruction_count.cpp
|
||||
plugin/cycle_estimate.cpp)
|
||||
|
||||
# Define two variables in order not to repeat ourselves.
|
||||
set(LIBRARY_NAME riscv)
|
||||
|
||||
# Define the library
|
||||
add_library(${LIBRARY_NAME} ${LIB_SOURCES})
|
||||
SET(${LIBRARY_NAME} -Wl,-whole-archive -l${LIBRARY_NAME} -Wl,-no-whole-archive)
|
||||
set_target_properties(${LIBRARY_NAME} PROPERTIES
|
||||
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
|
||||
FRAMEWORK FALSE
|
||||
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
||||
)
|
||||
#set_property(TARGET ${LIBRARY_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(SystemC_FOUND)
|
||||
set(SC_LIBRARY_NAME riscv_sc)
|
||||
add_library(${SC_LIBRARY_NAME} SHARED sysc/core_complex.cpp)
|
||||
add_definitions(-DWITH_SYSTEMC)
|
||||
include_directories(${SystemC_INCLUDE_DIRS})
|
||||
|
||||
include_directories(${CCI_INCLUDE_DIRS})
|
||||
|
||||
if(SCV_FOUND)
|
||||
add_definitions(-DWITH_SCV)
|
||||
include_directories(${SCV_INCLUDE_DIRS})
|
||||
endif()
|
||||
set_target_properties(${SC_LIBRARY_NAME} PROPERTIES
|
||||
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
|
||||
FRAMEWORK FALSE
|
||||
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
||||
)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} ${LIBRARY_NAME})
|
||||
target_link_libraries(${SC_LIBRARY_NAME} dbt-core)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} softfloat)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} sc-components)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} external)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} ${llvm_libs})
|
||||
target_link_libraries(${SC_LIBRARY_NAME} ${Boost_LIBRARIES} )
|
||||
endif()
|
||||
|
||||
# This is a make target, so you can do a "make riscv-sc"
|
||||
set(APPLICATION_NAME riscv-sim)
|
||||
|
||||
add_executable(${APPLICATION_NAME} main.cpp)
|
||||
|
||||
# Links the target exe against the libraries
|
||||
target_link_libraries(${APPLICATION_NAME} ${LIBRARY_NAME})
|
||||
target_link_libraries(${APPLICATION_NAME} jsoncpp)
|
||||
target_link_libraries(${APPLICATION_NAME} dbt-core)
|
||||
target_link_libraries(${APPLICATION_NAME} softfloat)
|
||||
target_link_libraries(${APPLICATION_NAME} external)
|
||||
target_link_libraries(${APPLICATION_NAME} ${llvm_libs})
|
||||
target_link_libraries(${APPLICATION_NAME} ${Boost_LIBRARIES} )
|
||||
if (Tcmalloc_FOUND)
|
||||
target_link_libraries(${APPLICATION_NAME} ${Tcmalloc_LIBRARIES})
|
||||
endif(Tcmalloc_FOUND)
|
||||
|
||||
# Says how and where to install software
|
||||
# Targets:
|
||||
# * <prefix>/lib/<libraries>
|
||||
# * header location after install: <prefix>/include/<project>/*.h
|
||||
# * headers can be included by C++ code `#<project>/Bar.hpp>`
|
||||
install(TARGETS ${LIBRARY_NAME} ${APPLICATION_NAME}
|
||||
EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
|
||||
ARCHIVE DESTINATION lib COMPONENT libs # static lib
|
||||
RUNTIME DESTINATION bin COMPONENT libs # binaries
|
||||
LIBRARY DESTINATION lib COMPONENT libs # shared lib
|
||||
FRAMEWORK DESTINATION bin COMPONENT libs # for mac
|
||||
PUBLIC_HEADER DESTINATION incl/${PROJECT_NAME} COMPONENT devel # headers for mac (note the different component -> different package)
|
||||
INCLUDES DESTINATION incl # headers
|
||||
)
|
||||
|
Loading…
Reference in New Issue