threeal / CheckWarning.cmake

Check for compiler warnings in your CMake project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CheckWarning.cmake

version license test status

CheckWarning.cmake is a CMake module that provides utility functions for checking compiler warnings during your project's build process. This module contains a target_check_warning function that helps in checking all recommended warnings on a given target.

Integration

Including the Script File

You can integrate this module into your project by including the target_check_warning.cmake file in your project.

include(target_check_warning.cmake)

Using CPM.cmake

Alternatively, you can use CPM.cmake to seamlessly integrate this module into your project.

cpmaddpackage(gh:threeal/CheckWarning.cmake@1.2.0)

Usage

Checking Warnings on a Target

To enable all recommended warnings on a target and treat them as errors, use the target_check_warning function. This will cause the build process to fail when a warning is violated.

add_executable(main main.cpp)
target_check_warning(main)

Ignoring Specific Warnings

You can pass FLAGS to the target_check_warning function to ignore specific warnings on a target.

target_check_warning(main FLAGS -Wno-unused-variable)

License

This project is licensed under the terms of the MIT License.

Copyright © 2023 Alfi Maulana

About

Check for compiler warnings in your CMake project

License:MIT License


Languages

Language:CMake 96.4%Language:C 2.1%Language:C++ 1.5%