Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore/only show errors/warnings from certain directory using CMake

Tags:

main question: Is there a configuration for cmake, to show or ignore compiler warnings/errors only from a certain directory?

alternative solution: How can I toggle this in QtCreator?

background / motivation: I'm working on a bigger CMake-project and want to focus on warnings and errors only from my subproject. I'm working with QtCreator and it annoys me to look for "my" errors/warnings under a pile of foreign ones.

like image 857
hardmooth Avatar asked Feb 28 '13 10:02

hardmooth


People also ask

How do I ignore a warning on CMake?

cmake:48 (include) CMakeLists. txt:208 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. You can disable the warning like this when you are configuring your build.

What is CMake and CMakeLists?

CMake is a meta build system that uses scripts called CMakeLists to generate build files for a specific environment (for example, makefiles on Unix machines). When you create a new CMake project in CLion, a CMakeLists. txt file is automatically generated under the project root.

What is the use of CMake command?

CMake can generate a native build environment that will compile source code, create libraries, generate wrappers and build executables in arbitrary combinations. CMake supports in-place and out-of-place builds, and can therefore support multiple builds from a single source tree.


1 Answers

You can set compiler warning options in CMake at least for certain target or certain files.

# For target set_target_properties(your_project_name PROPERTIES COMPILE_FLAGS "...")  # For files set_source_files_properties(   ${list_of_your_files}   PROPERTIES   COMPILE_FLAGS "..." ) 

It is also possible to set the options per-folder basis by separating your project as subproject, add it using add_subdirectory(your_project) and in your project CMakeLists.txt use add_definitions(...).

From CMake documentation:

add_definitions Adds flags to the compiler command line for sources in the current directory and below.

like image 139
ronkot Avatar answered Oct 21 '22 09:10

ronkot