Make tidy and coverage optional and disabled by default
* Prevent warnings about required tools being unavailable when tidy/coverage targets aren't desired anyways (eg. when packaging) * Do not automatically execute tidy check when packaging in unclean environment
This commit is contained in:
parent
57d5d04d9f
commit
a4fc4024b5
|
@ -181,6 +181,8 @@ endif()
|
|||
|
||||
# add target for tidying with clang-format
|
||||
if(NOT META_NO_TIDY AND EXISTS "${CLANG_FORMAT_RULES}")
|
||||
option(CLANG_FORMAT_ENABLED "enables creation of tidy target using clang-format" OFF)
|
||||
if(CLANG_FORMAT_ENABLED)
|
||||
find_program(CLANG_FORMAT_BIN clang-format)
|
||||
if(CLANG_FORMAT_BIN)
|
||||
set(FORMATABLE_FILES
|
||||
|
@ -220,10 +222,9 @@ if(NOT META_NO_TIDY AND EXISTS "${CLANG_FORMAT_RULES}")
|
|||
)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "clang-format not found; unable to add tidy target")
|
||||
message(FATAL_ERROR "Unable to add tidy target; clang-format not found")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "No rules to invoke clang-format for ${META_PROJECT_NAME} present")
|
||||
endif()
|
||||
|
||||
# add autotools-style check target
|
||||
|
@ -237,13 +238,18 @@ if(NOT TARGET check)
|
|||
endif()
|
||||
|
||||
# enable source code based coverage analysis using clang
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CLANG_SOURCE_BASED_COVERAGE_ENABLED YES)
|
||||
option(CLANG_SOURCE_BASED_COVERAGE_ENABLED "enables creation of coverage targets for source-based coverage with clang" OFF)
|
||||
if(CLANG_SOURCE_BASED_COVERAGE_ENABLED)
|
||||
if(CMAKE_HOST_UNIX AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CLANG_SOURCE_BASED_COVERAGE_AVAILABLE YES)
|
||||
set(CLANG_SOURCE_BASED_COVERAGE_FLAGS -fprofile-instr-generate -fcoverage-mapping)
|
||||
list(APPEND META_PRIVATE_SHARED_LIB_COMPILE_OPTIONS ${CLANG_SOURCE_BASED_COVERAGE_FLAGS})
|
||||
list(APPEND META_PRIVATE_STATIC_LIB_COMPILE_OPTIONS ${CLANG_SOURCE_BASED_COVERAGE_FLAGS})
|
||||
list(APPEND META_ADDITIONAL_SHARED_LINK_FLAGS ${CLANG_SOURCE_BASED_COVERAGE_FLAGS})
|
||||
list(APPEND META_ADDITIONAL_STATIC_LINK_FLAGS ${CLANG_SOURCE_BASED_COVERAGE_FLAGS})
|
||||
else()
|
||||
message(FATAL_ERROR "Source-based coverage only available under UNIX with Clang")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(BASIC_PROJECT_CONFIG_DONE YES)
|
||||
|
|
|
@ -131,7 +131,7 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT)
|
|||
)
|
||||
|
||||
# enable source code based coverage analysis using clang
|
||||
if(CLANG_SOURCE_BASED_COVERAGE_ENABLED)
|
||||
if(CLANG_SOURCE_BASED_COVERAGE_AVAILABLE)
|
||||
# specify where to store raw clang profiling data via environment variable
|
||||
set(LLVM_PROFILE_RAW_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests.profraw")
|
||||
set(LLVM_PROFILE_RAW_LIST_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests.profraw.list")
|
||||
|
@ -204,7 +204,7 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT)
|
|||
endif()
|
||||
add_dependencies(coverage "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests_coverage")
|
||||
else()
|
||||
message(WARNING "Unable to generate target for coverage report because llvm-profdata and llvm-cov are not available.")
|
||||
message(FATAL_ERROR "Unable to generate target for coverage report because llvm-profdata and llvm-cov are not available.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -39,9 +39,19 @@ None of these are enabled or set by default, unless stated otherwise.
|
|||
* `EXCLUDE_TESTS_FROM_ALL=ON/OFF`: excludes tests from the all target
|
||||
(enabled by default)
|
||||
* `APPEND_GIT_REVISION=ON/OFF`: whether the build script should attempt to
|
||||
append the Git revision and the latest commit ID to the version displayed
|
||||
via --help (enabled by default but has no effect when the source directory is
|
||||
no Git checkout or Git is not installed)
|
||||
append the Git revision and the latest commit ID to the version
|
||||
* displayed via --help
|
||||
* enabled by default but has no effect when the source directory is
|
||||
no Git checkout or Git is not installed
|
||||
* `CLANG_FORMAT_ENABLED=ON/OFF`: enables tidy target for code formatting via
|
||||
`clang-format`
|
||||
* can be made unavailable by setting `META_NO_TIDY` in the project file
|
||||
* only available if format rules are available
|
||||
* also enables tidy check executed via `check` target
|
||||
* `CLANG_SOURCE_BASED_COVERAGE_ENABLED=ON/OFF`: enables `coverage` target to
|
||||
determine source-based test coverage using Clang/llvm
|
||||
* only available when building with Clang under UNIX
|
||||
* coverage report is stored in build directory
|
||||
|
||||
#### Windows specific
|
||||
* `USE_NATIVE_FILE_BUFFER=ON/OFF`: use native function to open file streams
|
||||
|
@ -95,6 +105,8 @@ and qtutilities.
|
|||
* `META_PROJECT_TYPE=application/library/plugin/qtplugin`: specifies whether
|
||||
to build an application, a library or a plugin
|
||||
* `META_CXX_STANDARD=11/14/..`: specifies the C++ version, default is 14
|
||||
* `META_NO_TIDY`: disables availability of enabling formatting via
|
||||
`CLANG_FORMAT_ENABLED` for this project
|
||||
|
||||
### Files
|
||||
* `HEADER_FILES`/`SRC_FILES`: specifies C++ header/source files
|
||||
|
|
Loading…
Reference in New Issue