„CMakeLists.txt“ ändern

This commit is contained in:
Eyck Jentzsch 2020-05-27 15:16:20 +00:00
parent f77b4d56e7
commit 71e2a7e0ef

View File

@ -1,104 +1,104 @@
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.12)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/sc-components/cmake) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/sc-components/cmake)
project(SCC_Test) project(SCC_Test)
set(ENABLE_SCV TRUE CACHE BOOL "Enable use of SCV") set(ENABLE_SCV TRUE CACHE BOOL "Enable use of SCV")
set(ENABLE_SHARED TRUE CACHE BOOL "Build shared libraries") set(ENABLE_SHARED TRUE CACHE BOOL "Build shared libraries")
set(NO_SUBMODULE_CHECK FALSE CACHE BOOL "Disable the submodule check") set(NO_SUBMODULE_CHECK FALSE CACHE BOOL "Disable the submodule check")
include(GitFunctions) include(GitFunctions)
get_branch_from_git() get_branch_from_git()
### set the directory names of the submodules ### set the directory names of the submodules
set(GIT_SUBMODULES sc-components) set(GIT_SUBMODULES sc-components)
set(GIT_SUBMODULE_DIR_sc-components .) set(GIT_SUBMODULE_DIR_sc-components .)
### set each submodules's commit or tag that is to be checked out ### set each submodules's commit or tag that is to be checked out
### (leave empty if you want master) ### (leave empty if you want master)
#set(GIT_SUBMODULE_VERSION_sc-components 3af6b9836589b082c19d9131c5d0b7afa8ddd7cd) #set(GIT_SUBMODULE_VERSION_sc-components 3af6b9836589b082c19d9131c5d0b7afa8ddd7cd)
set(GIT_SUBMODULE_BRANCH_sc-components ${GIT_BRANCH}) set(GIT_SUBMODULE_BRANCH_sc-components ${GIT_BRANCH})
include(GNUInstallDirs) include(GNUInstallDirs)
if(NOT NO_SUBMODULE_CHECK) if(NOT NO_SUBMODULE_CHECK)
include(Submodules) include(Submodules)
endif() endif()
include(Conan) include(Conan)
include(BuildType) include(BuildType)
#enable_testing() #enable_testing()
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE) CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE) if(COMPILER_SUPPORTS_MARCH_NATIVE)
if("${CMAKE_BUILD_TYPE}" STREQUAL "") if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
elseif(NOT(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")) elseif(NOT(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif() endif()
endif() endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(warnings "-Wall -Wextra -Werror") set(warnings "-Wall -Wextra -Werror")
set(CMAKE_CXX_FLAG_RELEASE "-O3 -DNDEBUG") set(CMAKE_CXX_FLAG_RELEASE "-O3 -DNDEBUG")
set(CMAKE_C_FLAG_RELEASE "-O3 -DNDEBUG") set(CMAKE_C_FLAG_RELEASE "-O3 -DNDEBUG")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(warnings "/W4 /WX /EHsc") set(warnings "/W4 /WX /EHsc")
endif() endif()
if(ENABLE_COVERAGE) if(ENABLE_COVERAGE)
include(CodeCoverage) include(CodeCoverage)
append_coverage_compiler_flags() append_coverage_compiler_flags()
set(COVERAGE_EXCLUDES "osci-lib/scc/*" "/engr/dev/tools/*") set(COVERAGE_EXCLUDES "osci-lib/scc/*" "/engr/dev/tools/*")
endif() endif()
find_program(CLANG_TIDY_EXE NAMES "clang-tidy-9") find_program(CLANG_TIDY_EXE NAMES "clang-tidy-9")
if (CLANG_TIDY_EXE) if (CLANG_TIDY_EXE)
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
set(CLANG_TIDY_CHECKS "-*,modernize-*,-modernize-use-trailing-return-type,clang-analyzer-core.*") set(CLANG_TIDY_CHECKS "-*,modernize-*,-modernize-use-trailing-return-type,clang-analyzer-core.*,clang-analyzer-cplusplus.*")
set(CMAKE_CXX_CLANG_TIDY set(CMAKE_CXX_CLANG_TIDY
${CLANG_TIDY_EXE}; ${CLANG_TIDY_EXE};
-checks=${CLANG_TIDY_CHECKS}; -checks=${CLANG_TIDY_CHECKS};
-fix;) -fix;)
else() else()
message(AUTHOR_WARNING "clang-tidy not found!") message(AUTHOR_WARNING "clang-tidy not found!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it
endif() endif()
setup_conan() setup_conan()
# This line finds the boost lib and headers. # 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. 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) find_package(Boost COMPONENTS program_options filesystem system thread REQUIRED)
# set-up SystemC and SCV # set-up SystemC and SCV
find_package(OSCISystemC) find_package(OSCISystemC)
if(NOT SystemC_FOUND) if(NOT SystemC_FOUND)
message( FATAL_ERROR "SystemC library not found." ) message( FATAL_ERROR "SystemC library not found." )
endif() endif()
add_subdirectory(sc-components) add_subdirectory(sc-components)
add_subdirectory(examples) add_subdirectory(examples)
add_subdirectory(tests) add_subdirectory(tests)
# #
# SYSTEM PACKAGING (RPM, TGZ, ...) # SYSTEM PACKAGING (RPM, TGZ, ...)
# _____________________________________________________________________________ # _____________________________________________________________________________
#include(CPackConfig) #include(CPackConfig)
# #
# CMAKE PACKAGING (for other CMake projects to use this one easily) # CMAKE PACKAGING (for other CMake projects to use this one easily)
# _____________________________________________________________________________ # _____________________________________________________________________________
#include(PackageConfigurator) #include(PackageConfigurator)
#include(FeatureSummary) #include(FeatureSummary)
#feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES PACKAGES_FOUND) #feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES PACKAGES_FOUND)