Skip to content

Commit

Permalink
Add fprettify to cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderRichert-NOAA committed Mar 5, 2024
1 parent 30beaa0 commit 965aa4c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ install/

*.swp
.DS_Store

*.bkp
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ option(BUILD_D "Build the 8-byte real version of the library, libip_d.{a,so}" ON
option(BUILD_8 "Build the 8-byte integer & real version of the library, libip_8.{a,so}" OFF)
option(BUILD_DEPRECATED "Build deprecated spectral processing functions" OFF)
option(TEST_TIME_LIMIT "Set timeout for tests" OFF)
option(F90_AUTOFORMAT "Use fprettify to reformat source code" OFF)

# Figure whether user wants a _4, a _d, and/or _8.
if(BUILD_4)
Expand Down Expand Up @@ -86,3 +87,23 @@ if(ENABLE_DOCS)
set(abs_top_srcdir "${CMAKE_SOURCE_DIR}")
add_subdirectory(docs)
endif()

# Run 'fprettify' autoformatter directly on src/*.F90
if(F90_AUTOFORMAT)
find_program(FPRETTIFY_EXE fprettify REQUIRED)
execute_process(
COMMAND ${FPRETTIFY_EXE} --version
OUTPUT_VARIABLE FPRETTIFY_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT ${FPRETTIFY_VERSION} MATCHES "-emc$")
message(FATAL_ERROR "The EMC-modified version of fprettify is required")
endif()
message(STATUS "Creating 'fprettify' target to directly update src/*.F90")
add_custom_target(
fprettify
COMMAND ${FPRETTIFY_EXE} --case 1 1 1 1 1 --indent 4
--whitespace 1 --enable-replacements --bkup_suffix .bkp
"${CMAKE_SOURCE_DIR}/src/*.F90"
)
endif()

0 comments on commit 965aa4c

Please sign in to comment.