Skip to content

Commit

Permalink
Clarify setting compiler flags in CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanBryan51 committed Mar 12, 2024
1 parent 69016f6 commit 8b6246a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(NETCDF REQUIRED IMPORTED_TARGET "netcdf-fortran")

set(CABLE_INTEL_Fortran_FLAGS -fp-model precise)
set(CABLE_INTEL_Fortran_FLAGS_DEBUG -O0 -g -traceback -fpe0)
set(CABLE_INTEL_Fortran_FLAGS_RELEASE -O2)
set(CABLE_Intel_Fortran_FLAGS -fp-model precise)
set(CABLE_Intel_Fortran_FLAGS_DEBUG -O0 -g -traceback -fpe0)
set(CABLE_Intel_Fortran_FLAGS_RELEASE -O2)
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(
CABLE_Fortran_FLAGS
${CABLE_INTEL_Fortran_FLAGS}
"$<$<CONFIG:Release>:${CABLE_INTEL_Fortran_FLAGS_RELEASE}>"
"$<$<CONFIG:Debug>:${CABLE_INTEL_Fortran_FLAGS_DEBUG}>"
${CABLE_Intel_Fortran_FLAGS}
"$<$<CONFIG:Release>:${CABLE_Intel_Fortran_FLAGS_RELEASE}>"
"$<$<CONFIG:Debug>:${CABLE_Intel_Fortran_FLAGS_DEBUG}>"
)
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Source files can be added easily by adding to the list of source files in [CMake

## Setting compiler flags

The recommended compiler flags for debug and release builds are set in the [CMakeLists.txt][CMakeLists.txt] file via [`target_compile_options`](https://cmake.org/cmake/help/latest/command/target_compile_options.html). These can be modified if required.
The recommended compiler flags for debug and release builds for each compiler are set in the [CMakeLists.txt][CMakeLists.txt] file via the `CABLE_<COMPILER_ID>_Fortran_FLAGS*` variables. These can be modified if required.

???+ warning
Compiler flags should be guarded by a check on the compiler ID as they are generally compiler specific. See [`CMAKE_<LANG>_COMPILER_ID`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html) for a list of supported compiler IDs.
Expand Down

0 comments on commit 8b6246a

Please sign in to comment.