diff --git a/CMakeLists.txt b/CMakeLists.txt
index 077e3180e6bf002b116452cb1a17d24337407d73..5f03d30a9f03b99ea02664a1e1575099fcb95f3b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,10 +18,10 @@ option(BUILD_DOCUMENTATION "Build documentation" OFF)
 option(MTIME_ENABLE_FORTRAN_HL "Enable the high-level Fortran interface" ON)
 
 # Set line limit to none for GNU compiler (default is 132) to enable long
-# __FILE__ macro
-if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
-  add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-ffree-line-length-none>)
-endif()
+# __FILE__ macro:
+add_compile_options(
+  $<$<COMPILE_LANG_AND_ID:Fortran,GNU>:-ffree-line-length-none>
+)
 
 include(GNUInstallDirs)