Skip to content

Commit 7b15fae

Browse files
committed
Guard --debug/--reldebug mutual exclusion, validate CMAKE_BUILD_TYPE, add Flang debug flags
1 parent 36249ac commit 7b15fae

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ if (MFC_ALL)
3838
set(MFC_DOCUMENTATION ON FORCE)
3939
endif()
4040

41+
# Validate CMAKE_BUILD_TYPE to catch typos (CMake is case-sensitive).
42+
set(_VALID_BUILD_TYPES "Debug" "Release" "RelDebug" "")
43+
if (NOT CMAKE_BUILD_TYPE IN_LIST _VALID_BUILD_TYPES)
44+
message(FATAL_ERROR "Unknown CMAKE_BUILD_TYPE '${CMAKE_BUILD_TYPE}'. Valid: Debug, RelDebug, Release")
45+
endif()
46+
4147
# RelDebug: a lighter debug mode for CI. Compiler-specific blocks below add the
4248
# actual flags; these defaults just tell CMake it is a recognised build type.
4349
set(CMAKE_C_FLAGS_RELDEBUG "-g" CACHE STRING "")
@@ -230,6 +236,10 @@ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Flang")
230236
$<$<COMPILE_LANGUAGE:Fortran>:-Mpreprocess>
231237
$<$<COMPILE_LANGUAGE:Fortran>:-fdefault-real-8>
232238
)
239+
240+
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelDebug")
241+
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-O1> $<$<COMPILE_LANGUAGE:Fortran>:-g>)
242+
endif()
233243
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
234244
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-free>)
235245

toolchain/mfc/build.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ def is_buildable(self) -> bool:
365365
return True
366366

367367
def configure(self, case: Case):
368+
if ARG("debug") and ARG("reldebug"):
369+
raise MFCException("--debug and --reldebug are mutually exclusive.")
370+
368371
build_dirpath = self.get_staging_dirpath(case)
369372
cmake_dirpath = self.get_cmake_dirpath()
370373
install_dirpath = self.get_install_dirpath(case)

0 commit comments

Comments
 (0)