@@ -30,27 +30,21 @@ include(${CMAKE_CURRENT_LIST_DIR}/f03utf8.cmake)
3030# -- compiler feature checks BEFORE setting flags to avoid intermittant failures in general
3131
3232if (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel" )
33- if (WIN32 )
34- add_compile_options (/QxHost)
35- string (APPEND CMAKE_Fortran_FLAGS " /traceback /heap-arrays" )
36- string (APPEND CMAKE_Fortran_FLAGS_DEBUG " /stand:f18 /warn" )
37- string (APPEND CMAKE_Fortran_FLAGS_DEBUG " /debug /check:all" )
38- else ()
39- add_compile_options (-xHost)
40- string (APPEND CMAKE_Fortran_FLAGS " -traceback -heap-arrays" )
41- string (APPEND CMAKE_Fortran_FLAGS_DEBUG " -stand f18 -warn" )
42- string (APPEND CMAKE_Fortran_FLAGS_DEBUG " -debug extended -check all" )
43- endif ()
33+ add_compile_options (
34+ $<IF:$<BOOL :${WIN32} >,/QxHost,-xHost>
35+ "$<$<COMPILE_LANGUAGE:Fortran>:-traceback;-heap-arrays>"
36+ "$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Debug>>:-warn;-debug extended;-check all>"
37+ )
4438elseif (CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
45- # add_compile_options(-mtune=native -Wall)
46- # if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 8)
47- # string(APPEND CMAKE_Fortran_FLAGS " -std=f2018")
48- # endif()
49-
50- string (APPEND CMAKE_Fortran_FLAGS " -fimplicit-none" )
51- # string(APPEND CMAKE_Fortran_FLAGS " -Wrealloc-lhs") # not -Wrealloc-lhs-all which warns on character
52- string (APPEND CMAKE_Fortran_FLAGS " -Werror=array-bounds -fcheck=all" )
39+
40+ add_compile_options (-mtune=native -Wall
41+ "$<$<COMPILE_LANGUAGE:Fortran>:-fimplicit-none;-Werror=array-bounds;-fcheck=all>"
42+ )
43+
44+ # "$<$<COMPILE_LANGAUGE:Fortran>:-Wrealloc-lhs>" # not -Wrealloc-lhs-all which warns on character
5345elseif (CMAKE_Fortran_COMPILER_ID STREQUAL NAG)
5446 # https://www.nag.co.uk/nagware/np/r70_doc/manual/compiler_2_4.html#OPTIONS
55- string (APPEND CMAKE_Fortran_FLAGS " -f2018 -C -colour -gline -nan -info -u" )
47+ add_compile_options (
48+ "$<$<COMPILE_LANGUAGE:Fortran>:-f2018;-C;-colour;-gline;-nan;-info;-u>"
49+ )
5650endif ()
0 commit comments