Here is a CMakeLists.txt for an example project, which I am compiling with MSVC in VS2022:
cmake_minimum_required(VERSION 3.28.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(Example VERSION 1.0)
add_executable(${PROJECT_NAME}
# Only show warnings for the following files
src/main.cpp
src/foo.cpp
src/bar.cpp
src/header_only.hpp # Can I get warnings for standalone headers?
# No warnings for this next file please
lib/library.cpp
)
# I do not want to see any warnings from the compilation of example submodule
add_subdirectory(submodules/example_submodule)
target_include_directories(${PROJECT_NAME}
PRIVATE submodules/example_submodule/include
)
target_link_directories(${PROJECT_NAME}
PRIVATE submodules/example_submodule/src
)
target_link_libraries(${PROJECT_NAME}
PUBLIC example_submodule
)
I want to reduce the amount of unimportant compiler warnings from third party files. Is it possible for me to only see compiler warnings from main.cpp, foo.cpp, bar.cpp and header_only.hpp and none from the standard library or the example submodule. And can you see warnings from standalone headers? I could see them when compiling with GCC but I can't get them to appear with MSVC.