SystemC-Components-Test/CMakeLists.txt

86 lines
2.8 KiB
CMake
Raw Normal View History

2022-10-02 18:20:00 +02:00
cmake_minimum_required(VERSION 3.16)
2022-09-30 15:21:01 +02:00
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/scc/cmake)
2022-10-02 21:40:19 +02:00
cmake_policy(SET CMP0110 NEW)
2020-06-04 09:46:46 +02:00
project(SCC_Test)
2022-10-02 18:20:00 +02:00
option(FULL_TEST_SUITE "enable also long-running tests" OFF)
option(ENABLE_SCV "Enable use of SCV" OFF)
option(ENABLE_CLANG_TIDY "Enable clang-tidy checks" OFF)
2020-06-04 09:46:46 +02:00
include(ConanInline)
2022-09-30 15:21:01 +02:00
include(GNUInstallDirs)
2020-06-04 09:46:46 +02:00
include(BuildType)
set(CMAKE_CXX_STANDARD 14)
2020-06-04 09:46:46 +02:00
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
elseif(NOT(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(warnings "-Wall -Wextra -Werror")
set(CMAKE_CXX_FLAG_RELEASE "-O3 -DNDEBUG")
set(CMAKE_C_FLAG_RELEASE "-O3 -DNDEBUG")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(warnings "/W4 /WX /EHsc")
endif()
if(ENABLE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
set(COVERAGE_EXCLUDES "osci-lib/scc/*" "/engr/dev/tools/*")
endif()
2023-12-22 20:42:21 +01:00
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if(ENABLE_CLANG_TIDY)
2023-12-22 20:42:21 +01:00
if(CLANG_TIDY_EXE)
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
#set(CLANG_TIDY_CHECKS "-*,modernize-*,-modernize-use-trailing-return-type,clang-analyzer-core.*,clang-analyzer-cplusplus.*")
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXE};-fix)
else()
message(AUTHOR_WARNING "clang-tidy not found!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it
endif()
endif()
2020-06-04 09:46:46 +02:00
2023-12-22 20:42:21 +01:00
set(CLANG_FORMAT_EXCLUDE_PATTERNS "/third_party/")
find_package(ClangFormat)
set(CONAN_CMAKE_SILENT_OUTPUT ON)
2022-09-30 15:21:01 +02:00
conan_check()
2023-01-05 15:31:07 +01:00
conan_configure(REQUIRES fmt/8.0.1 spdlog/1.9.2 boost/1.75.0 gsl-lite/0.37.0 systemc/2.3.3 catch2/3.1.0 zlib/1.2.11 lz4/1.9.4
GENERATORS cmake_find_package
2023-01-05 15:31:07 +01:00
OPTIONS fmt:header_only=True spdlog:header_only=True
)
conan_install()
2020-06-04 09:46:46 +02:00
find_package(ZLIB)
2022-10-02 11:39:06 +02:00
find_package(lz4)
2020-06-04 09:46:46 +02:00
# This line finds the boost lib and headers.
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 COMPONENTS program_options filesystem system thread REQUIRED)
2023-01-05 15:31:07 +01:00
find_package(fmt REQUIRED)
find_package(spdlog REQUIRED)
find_package(Catch2)
2022-09-30 15:21:01 +02:00
include(SystemCPackage)
2022-10-02 21:40:19 +02:00
include(CTest)
include(Catch)
2020-06-04 09:46:46 +02:00
enable_testing()
2021-06-01 18:08:32 +02:00
add_subdirectory(scc)
add_subdirectory(src)
2020-06-04 09:46:46 +02:00
add_subdirectory(tests)