Supress IntelliSense warning for 3-rd party libs in a CMake project

The Norman 1 Reputation point
2021-10-13T18:12:18.633+00:00

Hello, there.
Similar question was asked before here, but it doesn't seem to be updated for CMake projects since such project don't have "standard" Visual Studio structure and it does not let me open View > Property Pages for a file. In my case the project structure looks as follows:

140270-asdd.png

I don't want anything outside of src folder to trigger IntelliSense warnings, as those are libraries, but i can't find any settings that controls the scope of IntelliSense checking. Is such option available at all? And if not, is it possible to disable IntelliSense warning for all files (and leave only linting tools specified under CMakeSettings.json:

{  
    "environments": [ { "VCPKG_PATH": "D:/Path/To/VCPkg/vcpkg/scripts/buildsystems/vcpkg.cmake" } ],  
    "configurations": [  
        {  
            "name": "x64-Debug",  
            "generator": "Ninja",  
            "configurationType": "Debug",  
            "inheritEnvironments": [ "clang_cl_x64" ],  
            "buildRoot": "${projectDir}\\out\\build\\${name}",  
            "installRoot": "${projectDir}\\out\\install\\${name}",  
            "cmakeCommandArgs": "",  
            "buildCommandArgs": "-v",  
            "ctestCommandArgs": "",  
            "cmakeToolchain": "${env.VCPKG_PATH}",  
            "enableClangTidyCodeAnalysis": false,  
            "intelliSenseMode": "windows-clang-x64"  
        }  
    ]  
}  
Developer technologies | C++
Developer technologies | Visual Studio | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Minxin Yu 13,506 Reputation points Microsoft External Staff
    2021-10-15T03:19:03.67+00:00

    Hi, @The Norman

    You could use code like:

    #pragma warning(push)  
    #pragma warning(disable:4321)  
    #include <Mylib.h>  
    #pragma warning(pop)  
    

    Here is a similar thread I found: Disable the warning of specific libraries by cmake

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.