CMake add target for invoking clang analyzer

前端 未结 2 1465
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 13:58

I\'d basically like to achieve the same as http://blog.alexrp.com/2013/09/26/clangs-static-analyzer-and-automake, but with CMake.

analyze_srcs = foo.c
analyz         


        
2条回答
  •  梦毁少年i
    2020-12-24 14:39

    I found a way:

    function(add_clang_static_analysis target)
        get_target_property(SRCs ${target} SOURCES)
        add_library(${target}_analyze OBJECT EXCLUDE_FROM_ALL ${SRCs})
        set_target_properties(${target}_analyze PROPERTIES
                              COMPILE_OPTIONS "--analyze"
                              EXCLUDE_FROM_DEFAULT_BUILD true)
    endfunction()
    

    Combining clang's plist files (which get extension .o this way) into a report is still open ($?).

提交回复
热议问题