Conversation
CMakeLists.txt
Outdated
| endif() | ||
|
|
||
| # NetCDF compiler flags | ||
| add_compile_options("$<$<COMPILE_LANGUAGE:Fortran>:-I ${NETCDF_INC_DIR};-L ${NETCDF_LIB_DIR} -lnetcdff>") |
There was a problem hiding this comment.
Ideally, these flags would come from target_link_libraries
There was a problem hiding this comment.
Wow, that was fast! I was still writing the PR description. I'll try your suggestion in then next version. Thanks!
CMakeLists.txt
Outdated
| message(FATAL_ERROR "G95 Fortran compiler not configured.") | ||
| elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") | ||
| # Mac OS Gfortran F90FLAGS and FREESOURCE flags | ||
| add_compile_options("$<$<COMPILE_LANGUAGE:Fortran>:-g;-cpp;-fbacktrace;-Wall;-fcheck=all>") |
There was a problem hiding this comment.
Options like -g and -Wall are specific to what any particular user wants in a given build. Thus, they should not be hard-coded in the project's CMake file.
If the project wants to enforce warning clean development, -Wall -Werror could go in CI instead.
There was a problem hiding this comment.
Sound good. I was replicating the flags in config/user_build_options* in PR #102.
|
@PhilMiller: I responded to your notes. Could you please take another look? |
FindNetCDF.cmake
Outdated
| set (NETCDF_F90 "YES") | ||
| find_package (NetCDF REQUIRED) |
There was a problem hiding this comment.
Is this meant to be uncommented here?
There was a problem hiding this comment.
Removed these lines from CMakeLists.txt and removed find_package() from FindNetCDF.cmake .
|
The changes look fine so far. Ping me again when this comes out of draft, please. Thanks for digging into these build system improvements. |
This PR contains a first version of CMake files that build noah-owp-modular.exe and noahowp_driver_test.exe in the noah_om_grid branch. The CMake files reference a new file, FindNetCDF.cmake, which searches the filesystem for netCDF-related files. These build files were developed and tested on MacOS Sonoma (v14.4.1) and contain stubs for building on other OSes, however, they have not been tested on other OSes and are unlikely to work on them without modification. Although the original Makefiles are not referenced by the CMake files, they are left in-place until this new build system has been tested on all supported platforms. Three files were moved to limit circular dependencies. These are:
bmi/bmi_noahowp.f90 -> src/bmi_noahowp.f90
driver/AsciiReadModule.f90 -> src/AsciiReadModule.f90
driver/OutputModule.f90 -> src/OutputModule.f90
Compilation occurs outside of the source code directory. CMake usage is documented in the root CMakeLists.txt file and is duplicated here: