Skip to content

Commit

Permalink
add USE_G2C_API option to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Dec 30, 2024
1 parent 1f0f249 commit fb14827
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ option(BUILD_WITH_W3EMC "Build with NCEPLIBS-w3emc, enabling some GRIB1 function
option(BUILD_UTILS "Build grib utilities" ON)
option(USE_AEC "Build with AEC (CCSDS) compression support" OFF)
option(G2C_COMPARE "Enable copygb2 tests using g2c_compare" OFF)
option(USE_G2C_API "Support new file-based API from NCEPLIBS-g2c" OFF)

# Developers can use this option to specify a local directory which
# holds the test files. They will be copied instead of fetching the
Expand Down Expand Up @@ -70,10 +71,17 @@ if(OPENMP)
find_package(OpenMP REQUIRED COMPONENTS Fortran)
endif()

# We need g2c if G2C_COMPARE or USE_G2C_API are specified.
if (G2C_COMPARE or USE_G2C_API)
find_package(g2c 2.1.0 REQUIRED)
add_definitions(-DG2C)
else()
find_package(g2c REQUIRED)
endif()

# There was a bug in jasper for the intel compiler that was fixed in
# 2.0.25.
find_package(Jasper 2.0.25 REQUIRED)
find_package(g2c REQUIRED)
find_package(PNG REQUIRED)
find_package(bacio REQUIRED)
if(bacio_VERSION LESS 2.5.0)
Expand All @@ -89,11 +97,6 @@ if (BUILD_WITH_W3EMC)
endif()
endif()

# We need g2c if G2C_COMPARE is chosen.
if (G2C_COMPARE)
find_package(g2c 1.7.0 REQUIRED)
endif()

# Figure whether user wants a _4, a _d, or both libraries.
if(BUILD_4 AND BUILD_D)
set(kinds "4" "d")
Expand Down
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ g2grids.F90 g2get.F90 g2getgb2.F90 g2index.F90 g2gf.F90 g2unpack.F90
g2create.F90 ${CMAKE_CURRENT_BINARY_DIR}/gribmod.F90 gridtemplates.F90
intmath.F90 g2jpc.F90 pack_gp.f params_ecmwf.F90 params.F90
pdstemplates.F90 g2png.F90 realloc.F90 reduce.f g2sim.F90 skgb.F90
g2spec.F90 g2logging.F90 g2cf.F90 g2c_interface.F90)
g2spec.F90 g2logging.F90)

# Add the new file-based API if desired.
if (USE_G2C_API)
set(fortran_src ${fortran_src} g2cf.F90 g2c_interface.F90)
endif()

# This function calls NCEPLIBS-w3emc.
if (BUILD_WITH_W3EMC)
Expand Down
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ copy_test_data(ref_jpeg_bitmap.grib2)
# Build a _4 and _d version of each test and link them to the _4 and
# _d builds of the library, for 4-byte real, and 8-byte real.
foreach(kind ${kinds})
create_test(test_g2cf ${kind})
if (USE_G2C_API)
create_test(test_g2cf ${kind})
endif()
create_test(test_misc ${kind})
create_test(test_g2 ${kind})
create_test(test_g1 ${kind})
Expand Down

0 comments on commit fb14827

Please sign in to comment.