question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] How to disable warnings from headers from dependencies

See original GitHub issue

I am using some dependency packages in my project and their headers generate a lot of warnings when compiling with my code. Is there a way to mark the dependencies’ headers as system headers similar to gcc’s -isystem flag? So that the warnings will be ignored.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
solvingjcommented, Feb 24, 2021

Ah, yes, the lack of docs is a problem. here’s this.

https://github.com/conan-io/docs/issues/601

So, I guess that the easiest thing that you might be able to do is mentioned here by @uilianries

https://github.com/bincrafters/community/issues/1100#issuecomment-604997132

set(CONAN_SYSTEM_INCLUDES ON)

But, I think the issue with this is that it only works for globals. If you’re using Conan via find_package and targets , I don’t think it works. Is that right @uilianries ?

0reactions
uilianriescommented, Mar 3, 2021

Hi @kakashidinho that’s first time I see it. Actually, the default behavior for me, when using Conan, is with -isystem for cmake generator. As example, let’s use gtest recipe when building its test package:

gtest/1.10.0 (test package): Calling build()

----Running------
> cd '/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="gcc" -DCONAN_COMPILER_VERSION="9" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++" -DCMAKE_MODULE_PATH="/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DWITH_GMOCK="True" -DWITH_MAIN="True" -Wno-dev '/home/conan/project/test_package'
-----------------
-- The CXX compiler identification is GNU 9.2.1
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: called by CMake conan helper
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Compiler GCC>=5, checking major version 9
-- Conan: Checking correct version: 9
-- Conan: C++ stdlib: libstdc++
CMake Warning at CMakeLists.txt:30 (message):
  CONAN_SYSTEM_INCLUDES:


CMake Warning at CMakeLists.txt:31 (message):
  CONAN_C_FLAGS: -m64


-- Conan: Using autogenerated FindGTest.cmake
-- Found GTest: 1.10.0 (found version "1.10.0") 
-- Library gtest_main found /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest_main.a
-- Found: /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest_main.a
-- Library gmock_main found /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock_main.a
-- Found: /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock_main.a
-- Library gmock found /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock.a
-- Found: /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock.a
-- Library gtest found /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest.a
-- Found: /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest.a
-- Library gtest found /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest.a
-- Found: /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest.a
-- Library gmock found /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock.a
-- Found: /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock.a
-- Library gmock_main found /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock_main.a
-- Found: /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock_main.a
-- Library gtest_main found /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest_main.a
-- Found: /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest_main.a
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXPORT_NO_PACKAGE_REGISTRY


-- Build files have been written to: /home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f

----Running------
> cmake --build '/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f' '--' '-j4'
-----------------
/usr/bin/cmake -S/home/conan/project/test_package -B/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f/CMakeFiles /home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f/CMakeFiles/progress.marks
/usr/bin/make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f'
/usr/bin/make -f CMakeFiles/test_package.dir/build.make CMakeFiles/test_package.dir/depend
make[2]: Entering directory '/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f'
cd /home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/conan/project/test_package /home/conan/project/test_package /home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f /home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f /home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f/CMakeFiles/test_package.dir/DependInfo.cmake --color=
Scanning dependencies of target test_package
make[2]: Leaving directory '/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f'
/usr/bin/make -f CMakeFiles/test_package.dir/build.make CMakeFiles/test_package.dir/build
make[2]: Entering directory '/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f'
[ 50%] Building CXX object CMakeFiles/test_package.dir/test_package.cpp.o
/usr/bin/g++  -DWITH_GMOCK -D_GLIBCXX_USE_CXX11_ABI=0 -isystem /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/include  -m64 -O3 -DNDEBUG    -std=gnu++11 -o CMakeFiles/test_package.dir/test_package.cpp.o -c /home/conan/project/test_package/test_package.cpp
[100%] Linking CXX executable bin/test_package
/usr/bin/cmake -E cmake_link_script CMakeFiles/test_package.dir/link.txt --verbose=1
/usr/bin/g++    -m64 -O3 -DNDEBUG        -rdynamic CMakeFiles/test_package.dir/test_package.cpp.o  -o bin/test_package   -L/home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib  -Wl,-rpath,/home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest_main.a /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock_main.a /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgmock.a /home/conan/.conan/data/gtest/1.10.0/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib/libgtest.a -lpthread 
make[2]: Leaving directory '/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f'
[100%] Built target test_package
make[1]: Leaving directory '/home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f'
/usr/bin/cmake -E cmake_progress_start /home/conan/project/test_package/build/7e3f3c9f8b0319ca5c01315759aeda2f877da74f/CMakeFiles 0
gtest/1.10.0 (test package): Running test()

As you can see, CONAN_SYSTEM_INCLUDE is not enabled, but still Conan uses -isystem for GTest include folder. I have no sure how, but my guess some other flags affect CMake behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to suppress GCC warnings from library headers?
I have a project that uses log4cxx, boost, etc. libraries whose headers generate lots of (repetitive) warnings. Is there a way to suppress...
Read more >
How can I suppress warnings for external headers in VS2017 ...
I want to use the Code Analysis in Visual Studio 2017. This is NOT A BUILD - I'm going to Analyze->Run Code Analysis->On...
Read more >
[Solved]-MSVC - stop warnings in headers-C++
You can disable specific warnings using the /wdXXXX flag where XXXX is the number of the warnings you wish to ignore. No need...
Read more >
Preprocessor Options - GCC, the GNU Compiler Collection
Make all warnings into hard errors. Source code which triggers warnings will be rejected. -Wsystem-headers: Issue warnings for code in system headers. These...
Read more >
Customized Warning Levels and Code Analysis for External ...
Set the warning level, code analysis, and other settings for external header in the. Customizing Code Analysis Settings for External Headers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found