@@ -22,6 +22,7 @@ option(MFC_OpenACC "Build with OpenACC" OFF)
2222option (MFC_PRE_PROCESS "Build pre_process" OFF )
2323option (MFC_SIMULATION "Build simulation" OFF )
2424option (MFC_POST_PROCESS "Build post_process" OFF )
25+ option (MFC_SYSCHECK "Build syscheck" OFF )
2526option (MFC_DOCUMENTATION "Build documentation" OFF )
2627option (MFC_ALL "Build everything" OFF )
2728
@@ -94,7 +95,8 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
9495
9596 if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
9697 add_compile_options (
97- -fcheck=all -fbacktrace
98+ -fcheck=all ,no -array-temps
99+ -fbacktrace
98100 -fimplicit-none
99101 )
100102 endif ()
@@ -220,25 +222,36 @@ endif()
220222# and generate documentation. Instead, we can simply include the list of .f90
221223# files that will eventually be used to compile <target>.
222224
223- macro (HANDLE_SOURCES target )
225+ macro (HANDLE_SOURCES target useCommon )
224226 set (${target} _DIR "${CMAKE_SOURCE_DIR} /src/${target} " )
225227 set (common_DIR "${CMAKE_SOURCE_DIR} /src/common" )
226228
227229 # Gather src/[<target>,common]/*.f90
228230 file (GLOB ${target} _F90s CONFIGURE_DEPENDS "${${target} _DIR}/*.f90" )
229- file (GLOB common_F90s CONFIGURE_DEPENDS "${common_DIR} /*.f90" )
230- set (${target} _SRCs ${${target} _F90s} ${common_F90s} )
231+ set (${target} _SRCs ${${target} _F90s})
232+ if (${useCommon} )
233+ file (GLOB common_F90s CONFIGURE_DEPENDS "${common_DIR} /*.f90" )
234+ list (APPEND ${target} _SRCs ${common_F90s} )
235+ endif ()
231236
232237 # src/[<target>,common]/*.fpp -> src/<target>/autogen/*.f90
233238 file (GLOB ${target} _FPPs CONFIGURE_DEPENDS "${${target} _DIR}/*.fpp" )
234- file (GLOB common_FPPs CONFIGURE_DEPENDS "${common_DIR} /*.fpp" )
239+ if (${useCommon} )
240+ file (GLOB common_FPPs CONFIGURE_DEPENDS "${common_DIR} /*.fpp" )
241+ list (APPEND ${target} _FPPs ${common_FPPs} )
242+ endif ()
235243
236244 # Locate src/[<target>,common]/include/*.fpp
237- file (GLOB ${target} _incs CONFIGURE_DEPENDS "${${target} _DIR}/include/*.fpp" )
238- file (GLOB common_incs CONFIGURE_DEPENDS "${common_DIR} /include/*.fpp" )
245+ if (EXISTS "${${target} _DIR}/include" )
246+ file (GLOB ${target} _incs CONFIGURE_DEPENDS "${${target} _DIR}/include/*.fpp" )
247+ endif ()
248+ if (${useCommon} )
249+ file (GLOB common_incs CONFIGURE_DEPENDS "${common_DIR} /include/*.fpp" )
250+ list (APPEND ${target} _incs ${common_incs} )
251+ endif ()
239252
240253 file (MAKE_DIRECTORY "${${target} _DIR}/autogen" )
241- foreach (fpp ${${target} _FPPs} ${common_FPPs} )
254+ foreach (fpp ${${target} _FPPs})
242255 cmake_path(GET fpp FILENAME fpp_filename)
243256 set (f90 "${${target} _DIR}/autogen/${fpp_filename} .f90" )
244257
@@ -253,7 +266,7 @@ macro(HANDLE_SOURCES target)
253266 --line-numbering
254267 --no -folding
255268 "${fpp} " "${f90} "
256- DEPENDS "${fpp} ;${${target} _incs}; ${common_incs} "
269+ DEPENDS "${fpp} ;${${target} _incs}"
257270 COMMENT "Preprocessing (Fypp) ${fpp_filename} "
258271 VERBATIM
259272 )
@@ -263,9 +276,10 @@ macro(HANDLE_SOURCES target)
263276endmacro ()
264277
265278
266- HANDLE_SOURCES(pre_process)
267- HANDLE_SOURCES(simulation)
268- HANDLE_SOURCES(post_process)
279+ HANDLE_SOURCES(pre_process ON )
280+ HANDLE_SOURCES(simulation ON )
281+ HANDLE_SOURCES(post_process ON )
282+ HANDLE_SOURCES(syscheck OFF )
269283
270284
271285# MFC_SETUP_TARGET: Given a target (herein <target>), this macro creates a new
@@ -293,8 +307,12 @@ function(MFC_SETUP_TARGET)
293307 target_include_directories (${ARGS_TARGET} PRIVATE
294308 "${CMAKE_SOURCE_DIR} /src/common"
295309 "${CMAKE_SOURCE_DIR} /src/common/include"
296- "${CMAKE_SOURCE_DIR} /src/${ARGS_TARGET} "
297- "${CMAKE_SOURCE_DIR} /src/${ARGS_TARGET} /include" )
310+ "${CMAKE_SOURCE_DIR} /src/${ARGS_TARGET} " )
311+
312+ if (EXISTS "${CMAKE_SOURCE_DIR} /src/${ARGS_TARGET} /include" )
313+ target_include_directories (${ARGS_TARGET} PRIVATE
314+ "${CMAKE_SOURCE_DIR} /src/${ARGS_TARGET} /include" )
315+ endif ()
298316
299317 string (TOUPPER "${ARGS_TARGET} " ARGS_TARGET_UPPER)
300318 target_compile_definitions (
@@ -338,6 +356,7 @@ function(MFC_SETUP_TARGET)
338356 endif ()
339357
340358 target_link_libraries (${ARGS_TARGET} PRIVATE OpenACC::OpenACC_Fortran)
359+ target_compile_definitions (${ARGS_TARGET} PRIVATE MFC_OpenACC)
341360
342361 if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
343362 # FIXME: This should work with other cards than gfx90a ones.
@@ -401,6 +420,11 @@ if (MFC_POST_PROCESS)
401420 target_compile_options (post_process PRIVATE -O0)
402421endif ()
403422
423+ if (MFC_SYSCHECK)
424+ MFC_SETUP_TARGET(TARGET syscheck
425+ SOURCES "${syscheck_SRCs} "
426+ MPI OpenACC)
427+ endif ()
404428
405429if (MFC_DOCUMENTATION)
406430 # GEN_DOCS: Given a target name (herein <target>), this macro sets up a
0 commit comments