Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/github_cmake_gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ jobs:
image: ghcr.io/noaa-gfdl/fms/fms-ci-rocky-gnu:13.2.0
env:
CMAKE_FLAGS: "${{ matrix.build-type }} ${{ matrix.omp-flags }} ${{ matrix.libyaml-flag }}"
PKG_CONFIG_PATH: "/opt/views/view/lib64/pkgconfig:/opt/views/view/lib/pkgconfig:/opt/views/view/share/pkgconfig"
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Generate makefiles with CMake
run: |
mkdir build
cd build
cmake $CMAKE_FLAGS -DNetCDF_ROOT=/opt/view -DLIBYAML_ROOT=/opt/view ..
cmake $CMAKE_FLAGS -DNetCDF_ROOT=/opt/view ..
- name: Build the library
run: make -C build

Expand All @@ -41,13 +42,14 @@ jobs:
image: ghcr.io/noaa-gfdl/fms/fms-ci-rocky-gnu:13.2.0-arm
env:
CMAKE_FLAGS: "${{ matrix.build-type }} ${{ matrix.omp-flags }} ${{ matrix.libyaml-flag }}"
PKG_CONFIG_PATH: "/opt/views/view/lib64/pkgconfig:/opt/views/view/lib/pkgconfig:/opt/views/view/share/pkgconfig"
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Generate makefiles with CMake
run: |
mkdir build
cd build
cmake $CMAKE_FLAGS -DNetCDF_ROOT=/opt/view -DLIBYAML_ROOT=/opt/view ..
cmake $CMAKE_FLAGS -DNetCDF_ROOT=/opt/view ..
- name: Build the library
run: make -C build
5 changes: 0 additions & 5 deletions CMAKE_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ MPI compiler wrappers may be named different on your system, so its best to ensu
export NetCDF_ROOT=`nc-config --prefix`
```

#### If building with yaml parser (-DWITH_YAML)
```
export LIBYAML_ROOT=<your libyaml install directory>
```

### Running CMake
It's best to create a build directory inside of the FMS folder to avoid building on top of the source code.
Once that is done, CMake can be ran to generate the necessary build files:
Expand Down
24 changes: 13 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ if (OPENMP)
endif()

if (WITH_YAML)
find_package(libyaml REQUIRED COMPONENTS C)
include_directories(${LIBYAML_INCLUDE_DIR})
find_package(PkgConfig REQUIRED)
pkg_check_modules(YAML REQUIRED IMPORTED_TARGET "yaml-0.1")
endif ()

# Enables position independent code (i.e., -fPIC)
Expand Down Expand Up @@ -417,6 +417,10 @@ foreach(kind ${kinds})
NetCDF::NetCDF_Fortran
MPI::MPI_Fortran)

if(YAML_FOUND)
target_link_libraries(${libTgt} PRIVATE PkgConfig::YAML)
endif()

if(OpenMP_Fortran_FOUND)
target_link_libraries(${libTgt} PRIVATE OpenMP::OpenMP_C OpenMP::OpenMP_Fortran)
endif()
Expand Down Expand Up @@ -450,12 +454,6 @@ if(NOT kinds)
target_link_libraries(${libTgt}_c PRIVATE OpenMP::OpenMP_C)
endif()

if(WITH_YAML)
target_link_libraries(${libTgt}_c PRIVATE libyaml_C)
set_target_properties(${libTgt}_c PROPERTIES COMPILE_FLAGS "-L${LIBYAML_LIBRARIES} -lyaml")
endif()


# Fortran
add_library(${libTgt}_f OBJECT ${fms_fortran_src_files})

Expand Down Expand Up @@ -560,6 +558,10 @@ if(NOT kinds)
NetCDF::NetCDF_Fortran
MPI::MPI_Fortran)

if(YAML_FOUND)
target_link_libraries(${libTgt} PRIVATE PkgConfig::YAML)
endif()

if(OpenMP_Fortran_FOUND)
target_link_libraries(${libTgt} PRIVATE OpenMP::OpenMP_C OpenMP::OpenMP_Fortran)
endif()
Expand Down Expand Up @@ -785,7 +787,7 @@ foreach (testFile ${TEST_SRC_SINGLE_TARGET})
)

if(WITH_YAML)
target_link_libraries(${TName} PRIVATE yaml ${LIBYAML_LIBRARIES})
target_link_libraries(${TName} PRIVATE PkgConfig::YAML)
endif()

if(OPENMP)
Expand Down Expand Up @@ -821,8 +823,8 @@ foreach (testFile ${TEST_SRC_MULTI_TARGET})
)

if(WITH_YAML)
target_link_libraries(${TName}_r4 PRIVATE yaml ${LIBYAML_LIBRARIES})
target_link_libraries(${TName}_r8 PRIVATE yaml ${LIBYAML_LIBRARIES})
target_link_libraries(${TName}_r4 PRIVATE PkgConfig::YAML)
target_link_libraries(${TName}_r8 PRIVATE PkgConfig::YAML)
endif()

if(OPENMP)
Expand Down
4 changes: 4 additions & 0 deletions cmake/FMSConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
find_dependency(NetCDF COMPONENTS C Fortran)
if(@WITH_YAML@)
find_dependency(PkgConfig REQUIRED)
pkg_check_modules(YAML REQUIRED IMPORTED_TARGET "yaml-0.1")
endif()
list(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})


Expand Down
11 changes: 0 additions & 11 deletions cmake/Findlibyaml.cmake

This file was deleted.

Loading