TGC-VP/CMakeLists.txt

205 lines
6.8 KiB
CMake
Raw Normal View History

2022-04-11 09:22:28 +02:00
cmake_minimum_required(VERSION 3.16)
2023-10-15 10:02:31 +02:00
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/scc/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/tgc-iss/dbt-rise-tgc/cmake/)
2022-04-11 09:22:28 +02:00
project(ecosystem-vp LANGUAGES C CXX VERSION 1.0.0)
option(ENABLE_SCV "Enable the use of SCV" ON)
option(LIBS_ONLY "Just build the shared libraries needed to build the VP" OFF)
2023-08-15 13:54:13 +02:00
option(FW_BUILD "Enable the automatic download and build of some firmware to run on the VP" OFF)
2022-04-11 09:22:28 +02:00
option(EN_EXT_DEBUG "Enable extended debug output at runtime" OFF)
option(ENABLE_COVERAGE "Enable code coverage" OFF)
option(ENABLE_SANITIZER "Enable address sanitizer" OFF)
option(ENABLE_CLANGTIDY "Enable static analysis with clang-tidy." OFF)
2023-10-15 10:02:31 +02:00
option(WITH_TCC "Build TCC backend" ON)
2023-10-23 10:19:16 +02:00
option(WITH_LLVM "Build LLVM backend" OFF)
option(WITH_ASMJIT "Build ASMJIT backend" ON)
2022-04-11 09:22:28 +02:00
set(SCC_LIB_ONLY ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(CheckCXXCompilerFlag)
include(GNUInstallDirs)
# add address sanitizer
if(ENABLE_SANITIZER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_compile_options(/vmg /wd26812) # suppress Warnung C26812: "enum class" gegenüber "enum" (Enum.3) bevorzugen
endif()
include(ConanInline)
if(BUILD_SHARED_LIBS)
set(SHARED_FLAG "True")
else()
set(SHARED_FLAG "False")
endif()
2022-04-11 09:22:28 +02:00
set(CONAN_BOOST_OPTIONS
boost:fPIC=True
boost:shared=${SHARED_FLAG}
2022-04-11 09:22:28 +02:00
boost:header_only=False
boost:without_contract=True
boost:without_fiber=True
boost:without_graph=True
boost:without_graph_parallel=True
boost:without_iostreams=True
boost:without_json=True
boost:without_locale=True
boost:without_log=True
boost:without_math=True
boost:without_mpi=True
boost:without_nowide=True
boost:without_python=True
boost:without_random=True
boost:without_regex=True
boost:without_stacktrace=True
boost:without_test=True
boost:without_timer=True
boost:without_type_erasure=True
boost:without_wave=True
)
2023-07-31 12:57:29 +02:00
set(B2_VERSION 4.9.6)
2023-02-28 14:56:36 +01:00
set(CONAN_PACKAGE_LIST
fmt/8.0.1
spdlog/1.9.2
boost/1.75.0
gsl-lite/0.37.0
elfio/3.8
lz4/1.9.3
2023-02-28 14:56:36 +01:00
yaml-cpp/0.7.0
2023-10-26 06:52:30 +02:00
jsoncpp/1.9.5
zlib/1.2.13
2023-02-28 14:56:36 +01:00
)
2023-07-09 22:21:49 +02:00
set(CONAN_PACKAGE_OPTIONS fmt:header_only=True ${CONAN_BOOST_OPTIONS})
2023-10-15 10:02:31 +02:00
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND WITH_TCC)
2023-07-31 12:57:29 +02:00
list(APPEND CONAN_PACKAGE_LIST seasocks/1.4.4 tcc/0.9.27)
2023-07-09 22:21:49 +02:00
list(APPEND CONAN_PACKAGE_OPTIONS lua:compile_as_cpp=False )
2023-07-31 12:57:29 +02:00
endif()
if(WITH_LLVM)
list(APPEND CONAN_PACKAGE_LIST llvm-core/13.0.0)
2023-10-26 06:52:30 +02:00
list(APPEND CONAN_PACKAGE_OPTIONS libiconv:shared=False)
2023-07-31 12:57:29 +02:00
endif()
2023-10-22 23:21:02 +02:00
if(WITH_ASMJIT)
list(APPEND CONAN_PACKAGE_LIST asmjit/cci.20230325)
list(APPEND CONAN_PACKAGE_OPTIONS asmjit:shared=False)
endif()
2023-07-31 12:57:29 +02:00
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tgc-iss/dbt-rise-plugins)
list(APPEND CONAN_PACKAGE_OPTIONS lua:compile_as_cpp=False)
list(APPEND CONAN_PACKAGE_LIST lua/5.4.3)
2022-04-11 09:22:28 +02:00
endif()
2023-07-31 12:57:29 +02:00
2022-04-11 09:22:28 +02:00
if(NOT USE_CWR_SYSTEMC AND NOT USE_NCSC_SYSTEMC AND NOT DEFINED ENV{SYSTEMC_HOME})
set(CONAN_PACKAGE_LIST ${CONAN_PACKAGE_LIST}
systemc/2.3.3
systemc-cci/1.0.0
)
set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS}
systemc:shared=${SHARED_FLAG}
systemc-cci:shared=${SHARED_FLAG}
systemc:disable_virtual_bind=False)
2022-04-11 09:22:28 +02:00
endif()
conan_check()
2023-02-19 12:03:26 +01:00
conan_add_remote(NAME minres URL https://git.minres.com/api/packages/Tooling/conan)
# Boost on CentOS 7 quirks: the b2 of conan-center is build against a newer libstdc++ and therefore does not run
# with the oooooold libs on CentOS 7. Therefore we build our own version of b2 if it is not there
set(B2_META $ENV{HOME}/.conan/data/b2/${B2_VERSION}/_/_/metadata.json)
if(DEFINED ENV{CONAN_USER_HOME})
set(B2_META $ENV{CONAN_USER_HOME}/.conan/data/b2/${B2_VERSION}/_/_/metadata.json)
endif()
if(NOT EXISTS ${B2_META})
conan_configure(REQUIRES b2/${B2_VERSION})
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE . BUILD b2 SETTINGS ${settings})
endif()
# Boost on CentOS 7 quirks end
2022-04-11 09:22:28 +02:00
conan_cmake_configure(REQUIRES ${CONAN_PACKAGE_LIST}
GENERATORS cmake_find_package
OPTIONS ${CONAN_PACKAGE_OPTIONS}
)
conan_cmake_autodetect(settings)
conan_install()
set(CONAN_CMAKE_SILENT_OUTPUT ON)
2022-07-18 11:49:51 +02:00
find_package(tcc QUIET)
2022-04-11 09:22:28 +02:00
find_package(elfio)
find_package(fmt)
2023-02-28 14:56:36 +01:00
find_package(spdlog)
2022-04-11 09:22:28 +02:00
find_package(gsl-lite)
2023-10-15 10:02:31 +02:00
find_package(yaml-cpp)
2022-04-11 09:22:28 +02:00
set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install.
find_package(Boost REQUIRED COMPONENTS program_options QUIET)
set(CLANG_FORMAT_EXCLUDE_PATTERNS "scc")
find_package(ClangFormat)
if(ENABLE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
set(COVERAGE_EXCLUDES "${tgfs_verif_SOURCE_DIR}/scc/*" "${tgfs_verif_SOURCE_DIR}/build/*" "$ENV{HOME}/.conan/*" "/opt/*")
endif()
if(ENABLE_CLANGTIDY)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if (CLANG_TIDY_EXE)
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
set(CLANG_TIDY_CHECKS
"-*,modernize-*,-modernize-use-trailing-return-type,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,boost-*,bugprone-*,performance-*,portability-*,readability-*")
#set(CLANG_TIDY_CHECKS "*")
set(CMAKE_CXX_CLANG_TIDY
${CLANG_TIDY_EXE};
-header-filter=${tgfs_verif_SOURCE_DIR};
-checks=${CLANG_TIDY_CHECKS};)
else()
message(AUTHOR_WARNING "clang-tidy not found!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it
endif()
endif ()
add_subdirectory(scc)
add_subdirectory(tgc-iss/dbt-rise-core)
add_subdirectory(tgc-iss/dbt-rise-tgc)
2023-07-31 12:57:29 +02:00
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tgc-iss//dbt-rise-plugins)
add_subdirectory(tgc-iss/dbt-rise-plugins)
endif()
if(NOT USE_CWR_SYSTEMC)
2022-04-11 09:22:28 +02:00
add_subdirectory(vpvper)
2023-07-31 12:57:29 +02:00
endif()
2022-04-11 09:22:28 +02:00
if(NOT LIBS_ONLY)
add_subdirectory(src)
endif()
2023-08-15 13:54:13 +02:00
2022-07-18 11:49:51 +02:00
if(FW_BUILD)
2023-08-15 13:54:13 +02:00
include(FetchContent)
set(FETCHCONTENT_BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}/..)
FetchContent_Declare(
riscvfw
GIT_REPOSITORY https://git.minres.com/VP/Firmwares.git
GIT_TAG main
GIT_SHALLOW OFF
UPDATE_DISCONNECTED ON
2023-08-15 13:54:13 +02:00
)
FetchContent_GetProperties(riscvfw)
if(NOT riscvfw_POPULATED)
FetchContent_Populate(riscvfw)
endif()
2023-10-26 06:52:30 +02:00
set(BOARD tgc-vp)
2023-08-20 16:47:47 +02:00
add_subdirectory(${riscvfw_SOURCE_DIR})
2022-04-11 09:22:28 +02:00
endif()
2023-10-26 11:39:04 +02:00
install(FILES ${CMAKE_CURRENT_LIST_DIR}/fw/hello-world/prebuilt/hello.elf DESTINATION share/tgc-vp)
2022-04-11 09:22:28 +02:00
# CTest is a testing tool that can be used to test your project.
2022-04-11 09:34:07 +02:00
enable_testing()
add_test(NAME tgc-vp-hello-world
#WORKING_DIRECTORY ${ecosystem-vp_DIR}/bin
COMMAND tgc-vp -f ${CMAKE_CURRENT_LIST_DIR}/fw/hello-world/prebuilt/hello.elf)