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.
ronkot :
You can set compiler warning options in CMake at least for certain target or certain files. \n\n# For target\nset_target_properties(your_project_name PROPERTIES COMPILE_FLAGS \"...\")\n\n# For files\nset_source_files_properties(\n ${list_of_your_files}\n PROPERTIES\n COMPILE_FLAGS \"...\"\n)\n\n\nIt 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(...). \n\nFrom CMake documentation:\n\n\n add_definitions Adds flags to the compiler command line for sources in the current directory and below.\n",
2013-03-01T06:20:05
JustWe :
Basically the same as @ronkot's answer. But don't need add_subdirectory for certain directory, using set_source_files_properties with file(GLOB_RECURSE ...) also works.\n\nfile(GLOB_RECURSE SRC_DIR \"SRC_DIR/*.c\" \"SRC_DIR/*.h\")\n\nset_source_files_properties(\n ${SRC_DIR}\n PROPERTIES\n COMPILE_FLAGS \"-w\"\n)\n",
2018-11-21T01:53:24