Skip to content

Commit

Permalink
src/CMakeLists.txt: add "address sanitizing" compile options to debug…
Browse files Browse the repository at this point in the history
… options
  • Loading branch information
MatthewMasarik-NOAA committed Feb 2, 2024
1 parent 4bb4754 commit 9b39136
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions model/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(compile_flags_release -O3)
# SHELL: prefix fixes CMake attempting to de-duplicate the repeated uses of 'all' in -warn, -debug, -check
# See https://cmake.org/cmake/help/latest/command/target_compile_options.html#option-de-duplication
set(compile_flags_debug -O0 "SHELL:-debug all" "SHELL:-warn all" "SHELL:-check all" -check noarg_temp_created -fp-stack-check -heap-arrays -traceback -fpe0)
#
# ##MTM set(compile_flags_debug -O0 "SHELL:-debug all" "SHELL:-warn all" "SHELL:-check all" -check noarg_temp_created -fp-stack-check -heap-arrays -traceback -fpe0)
#
#
set(compile_flags_debug -O0 "SHELL:-debug all" "SHELL:-warn all" "SHELL:-check all" -check noarg_temp_created -fp-stack-check -heap-arrays -traceback -fpe0 -fno-omit-frame-pointer -fsanitize=address)
#
# ##MTM

if(APPLE)
# The linker on macOS does not include `common symbols` (usually module variables without a default value) by default
Expand All @@ -70,7 +76,7 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(compile_flags -g -fno-second-underscore -ffree-line-length-none)
set(compile_flags_release -O3)
set(compile_flags_debug -Wall -fcheck=all -ffpe-trap=invalid,zero,overflow -frecursive -fbacktrace)

if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10)
target_compile_options(ww3_lib PUBLIC -fallow-argument-mismatch)
endif()
Expand All @@ -79,7 +85,7 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
set(compile_flags -g -i4 -r4 -Kieee)
set(compile_flags_release -O3)
set(compile_flags_debug -O0 -Mbounds -Mchkfpstk -Mchkstk -Mdalign -Mdclchk -Mdepchk -Miomutex -Ktrap=fp -Mrecursive -traceback)

if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10)
target_compile_options(ww3_lib PUBLIC -fallow-argument-mismatch -fallow-invalid-boz)
endif()
Expand Down Expand Up @@ -131,13 +137,13 @@ if(MULTI_ESMF)
if (NOT TARGET esmf)
find_package(ESMF MODULE REQUIRED)
endif()

target_sources(ww3_lib PRIVATE wmesmfmd.F90)
target_link_libraries(ww3_lib PUBLIC esmf)
set_target_properties(ww3_lib PROPERTIES OUTPUT_NAME "ww3_multi_esmf")
# Don't build executables when building WW3 ESMF library
set(programs "")
endif()
endif()

set_property(SOURCE w3initmd.F90
APPEND
Expand Down Expand Up @@ -211,7 +217,7 @@ install(

install(FILES ${CMAKE_BINARY_DIR}/switch DESTINATION ${CMAKE_INSTALL_PREFIX})
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX})


export(EXPORT WW3Exports
NAMESPACE WW3::
Expand Down

0 comments on commit 9b39136

Please sign in to comment.