Вынос опций за пределы функций
This commit is contained in:
		| @@ -1,16 +1,19 @@ | |||||||
|  | find_program(CLANG_CHECK_EXE | ||||||
|  |              NAMES clang-check-10 | ||||||
|  |                    clang-check-9 | ||||||
|  |                    clang-check-8 | ||||||
|  |                    clang-check-7 | ||||||
|  |                    clang-check-6.0 | ||||||
|  |                    clang-check) | ||||||
|  | if(CLANG_CHECK_EXE) | ||||||
|  |   option(CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF) | ||||||
|  | endif() | ||||||
|  |  | ||||||
| function(add_clang_analyze_check) | function(add_clang_analyze_check) | ||||||
|   list(GET ARGN 0 _target) |   list(GET ARGN 0 _target) | ||||||
|   set(_sources ${ARGN}) |   set(_sources ${ARGN}) | ||||||
|   list(REMOVE_AT _sources 0) |   list(REMOVE_AT _sources 0) | ||||||
|  |  | ||||||
|   option(CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF) |  | ||||||
|   find_program(CLANG_CHECK_EXE |  | ||||||
|                NAMES clang-check-10 |  | ||||||
|                      clang-check-9 |  | ||||||
|                      clang-check-8 |  | ||||||
|                      clang-check-7 |  | ||||||
|                      clang-check-6.0 |  | ||||||
|                      clang-check) |  | ||||||
|   if(CLANG_CHECK_EXE) |   if(CLANG_CHECK_EXE) | ||||||
|     if(CLANG_CHECK_FIX) |     if(CLANG_CHECK_FIX) | ||||||
|       list(APPEND _args "-fix") |       list(APPEND _args "-fix") | ||||||
|   | |||||||
| @@ -1,20 +1,23 @@ | |||||||
|  | find_program(CLANG_TIDY_EXE | ||||||
|  |              NAMES clang-tidy-10 | ||||||
|  |                    clang-tidy-9 | ||||||
|  |                    clang-tidy-8 | ||||||
|  |                    clang-tidy-7 | ||||||
|  |                    clang-tidy-6.0 | ||||||
|  |                    clang-tidy) | ||||||
|  | if(CLANG_TIDY_EXE) | ||||||
|  |   option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF) | ||||||
|  |   if(CLANG_TIDY_FIX) | ||||||
|  |     list(APPEND _args "-fix") | ||||||
|  |   endif() | ||||||
|  | endif() | ||||||
|  |  | ||||||
| function(add_clang_tidy_check) | function(add_clang_tidy_check) | ||||||
|   list(GET ARGN 0 _target) |   list(GET ARGN 0 _target) | ||||||
|   set(_sources ${ARGN}) |   set(_sources ${ARGN}) | ||||||
|   list(REMOVE_AT _sources 0) |   list(REMOVE_AT _sources 0) | ||||||
|  |  | ||||||
|   option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF) |  | ||||||
|   find_program(CLANG_TIDY_EXE |  | ||||||
|                NAMES clang-tidy-10 |  | ||||||
|                      clang-tidy-9 |  | ||||||
|                      clang-tidy-8 |  | ||||||
|                      clang-tidy-7 |  | ||||||
|                      clang-tidy-6.0 |  | ||||||
|                      clang-tidy) |  | ||||||
|   if(CLANG_TIDY_EXE) |   if(CLANG_TIDY_EXE) | ||||||
|     if(CLANG_TIDY_FIX) |  | ||||||
|       list(APPEND _args "-fix") |  | ||||||
|     endif() |  | ||||||
|     if(NOT TARGET clang-tidy-check) |     if(NOT TARGET clang-tidy-check) | ||||||
|       add_custom_target(clang-tidy-check) |       add_custom_target(clang-tidy-check) | ||||||
|     endif() |     endif() | ||||||
|   | |||||||
| @@ -1,38 +1,42 @@ | |||||||
|  | option(ENABLE_CODE_COVERAGE "Enable code coverage support" OFF) | ||||||
|  | find_program(LCOV_EXE NAMES lcov) | ||||||
|  | find_program(GENHTML_EXE NAMES genhtml) | ||||||
|  |  | ||||||
| function(add_code_coverage) | function(add_code_coverage) | ||||||
|   list(GET ARGN 0 _target) |   list(GET ARGN 0 _target) | ||||||
|  |  | ||||||
|   if(ENABLE_CODE_COVERAGE AND CMAKE_CXX_COMPILER_IS_GCC) |   if(ENABLE_CODE_COVERAGE) | ||||||
|     find_program(LCOV_EXE NAMES lcov) |     if(CMAKE_CXX_COMPILER_IS_GCC) | ||||||
|     find_program(GENHTML_EXE NAMES genhtml) |       target_compile_options(${_target} PUBLIC "--coverage") | ||||||
|     target_compile_options(${_target} PUBLIC "--coverage") |       get_target_property(LF ${_target} LINK_FLAGS) | ||||||
|     get_target_property(LF ${_target} LINK_FLAGS) |       string(APPEND LF " --coverage") | ||||||
|     string(APPEND LF " --coverage") |       set_target_properties(${_target} PROPERTIES LINK_FLAGS ${LF}) | ||||||
|     set_target_properties(${_target} PROPERTIES LINK_FLAGS ${LF}) |  | ||||||
|  |  | ||||||
|     if(LCOV_EXE) |       if(LCOV_EXE) | ||||||
|       add_custom_target(coverage-${_target} |         add_custom_target(coverage-${_target} | ||||||
|                         WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |  | ||||||
|                         COMMAND ${LCOV_EXE} |  | ||||||
|                                 --test-name |  | ||||||
|                                 ${_target} |  | ||||||
|                                 --output |  | ||||||
|                                 "${_target}.lcov" |  | ||||||
|                                 --capture |  | ||||||
|                                 --directory |  | ||||||
|                                 ${CMAKE_BINARY_DIR}) |  | ||||||
|       add_dependencies(coverage-${_target} ${_target}) |  | ||||||
|  |  | ||||||
|       if(GENHTML_EXE) |  | ||||||
|         add_custom_target(coverage-report-${_target} |  | ||||||
|                           WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |                           WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||||||
|                           COMMAND ${GENHTML_EXE} |                           COMMAND ${LCOV_EXE} | ||||||
|                                   --output-directory |                                   --test-name | ||||||
|                                   "report-${_target}" |                                   ${_target} | ||||||
|                                   "${_target}.lcov") |                                   --output | ||||||
|         add_dependencies(coverage-report-${_target} coverage-${_target}) |                                   "${_target}.lcov" | ||||||
|  |                                   --capture | ||||||
|  |                                   --directory | ||||||
|  |                                   ${CMAKE_BINARY_DIR}) | ||||||
|  |         add_dependencies(coverage-${_target} ${_target}) | ||||||
|  |  | ||||||
|  |         if(GENHTML_EXE) | ||||||
|  |           add_custom_target(coverage-report-${_target} | ||||||
|  |                             WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||||||
|  |                             COMMAND ${GENHTML_EXE} | ||||||
|  |                                     --output-directory | ||||||
|  |                                     "report-${_target}" | ||||||
|  |                                     "${_target}.lcov") | ||||||
|  |           add_dependencies(coverage-report-${_target} coverage-${_target}) | ||||||
|  |         endif() | ||||||
|       endif() |       endif() | ||||||
|  |     else() | ||||||
|  |       message("Only GCC is supported for code coverage") | ||||||
|     endif() |     endif() | ||||||
|   else() |  | ||||||
|     message("Only GCC is supported for code coverage") |  | ||||||
|   endif() |   endif() | ||||||
| endfunction() | endfunction() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user