As noted in CMake MR 12455 CMake's own test suite doesn't test CMAKE_COMPILE_WARNING_AS_ERROR, so we made this little test.
Created
August 31, 2026 19:14
-
-
Save scivision/ea9882f92577a1992de2202031324aed to your computer and use it in GitHub Desktop.
Test CMAKE_COMPILE_WARNING_AS_ERROR with Fortran
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 4.4) | |
| project(FlangErr LANGUAGES Fortran) | |
| if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU|LLVMFlang") | |
| add_compile_options(-Wunused-variable) | |
| elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") | |
| add_compile_options(-warn:unused) | |
| endif() | |
| file(GENERATE OUTPUT "err.f90" | |
| CONTENT "program test | |
| integer :: i | |
| end program") | |
| set(CMAKE_COMPILE_WARNING_AS_ERROR ON) | |
| add_executable(Err ${CMAKE_CURRENT_BINARY_DIR}/err.f90) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment