cmake_minimum_required(VERSION 3.12) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/scc/cmake) list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}) project(SCC_Test) set(ENABLE_SCV TRUE CACHE BOOL "Enable use of SCV") set(ENABLE_SHARED TRUE CACHE BOOL "Build shared libraries") set(NO_SUBMODULE_CHECK FALSE CACHE BOOL "Disable the submodule check") set(ENABLE_CLANG_TIDY FALSE CACHE BOOL "Enable clang-tidy checks") include(GitFunctions) get_info_from_git() ### set the directory names of the submodules set(GIT_SUBMODULES scc) set(GIT_SUBMODULE_DIR_sc-components .) ## set each submodules's commit or tag that is to be checked out ## (leave empty if you want master) set(GIT_SUBMODULE_BRANCH_sc-components ${GIT_BRANCH}) include(GNUInstallDirs) if(NOT NO_SUBMODULE_CHECK) include(Submodules) endif() include(BuildType) set(CMAKE_CXX_STANDARD 11) 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() find_program(CLANG_TIDY_EXE NAMES "clang-tidy-9") if(ENABLE_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-core.*,clang-analyzer-cplusplus.*") set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXE}; -checks=${CLANG_TIDY_CHECKS}; -fix;) else() message(AUTHOR_WARNING "clang-tidy not found!") set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it endif() endif() ########################################################## ## get conan packages ########################################################## include(ConanInline) set(CONAN_BOOST_OPTIONS boost:fPIC=True boost:shared=True boost:header_only=False boost:without_context=True boost:without_contract=True boost:without_coroutine=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 ) set(CONAN_PACKAGE_LIST fmt/6.1.2 boost/1.75.0 gsl-lite/0.37.0) set(CONAN_PACKAGE_OPTIONS fmt:header_only=True ${CONAN_BOOST_OPTIONS}) if(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-cci:shared=False) endif() conan_check() conan_add_remote(NAME minres URL https://artifactory.minres.com/artifactory/api/conan/oss) conan_cmake_configure(REQUIRES ${CONAN_PACKAGE_LIST} GENERATORS cmake_find_package OPTIONS ${CONAN_PACKAGE_OPTIONS} ) conan_install() find_package(fmt) find_package(gsl-lite) find_package(SystemCLanguage) find_package(systemc-cci) ######################################################################################## # 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) # set-up SystemC and SCV find_package(OSCISystemC) if(NOT SystemC_FOUND) message( FATAL_ERROR "SystemC library not found." ) endif() enable_testing() add_subdirectory(scc) add_subdirectory(examples) add_subdirectory(tests) # # SYSTEM PACKAGING (RPM, TGZ, ...) # _____________________________________________________________________________ #include(CPackConfig) # # CMAKE PACKAGING (for other CMake projects to use this one easily) # _____________________________________________________________________________ #include(PackageConfigurator) #include(FeatureSummary) #feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES PACKAGES_FOUND)