Hello,
I am trying to compile my c++ source files with certain gcc compiler flags (namely -Wall
), but not external libs. But I can’t figure out how to achieve this. I have this mock setup for my cmakelists project file:
cmake_minimum_required(VERSION 3.11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE "Release")
project(test)
add_subdirectory(extern/libs/efg)
include_directories("extern/libs/xyz")
add_executable(binary my_source_file1.cpp
my_source_file2.cpp
my_source_file3.cpp
my_source_file4.cpp
)
target_compile_options(binary PRIVATE
-Wall)
target_link_libraries(binary efg)
However when I build the project, it also gives compiler flag warnings for the external libs I have included. How would I avoid this? I just want to get warnings for my own source files, and not any other external dependencies. I am quite novice to cmake, so not sure how to achieve this
Thanks