Skip to content

Commit

Permalink
adding cmake options from grib_util
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA committed May 30, 2024
1 parent 424e497 commit 5c4a240
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(lib_name ${PROJECT_NAME})
include(GNUInstallDirs)

# Handle user build options.
option(OPENMP "Use OpenMP threading" OFF)
option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(FTP_TEST_FILES "Fetch and test with files on FTP site." OFF)
Expand All @@ -21,6 +22,7 @@ option(LOGGING "Turn on internal logging messages. Only useful to g2 developers.
option(BUILD_4 "Build libg2_4.a" ON)
option(BUILD_D "Build libg2_d.a" ON)
option(BUILD_WITH_W3EMC "Build with NCEPLIBS-w3emc, enabling some GRIB1 functionality" ON)
option(G2C_COMPARE "Enable copygb2 tests using g2c_compare" 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 @@ -61,14 +63,24 @@ if(${CMAKE_Fortran_COMPILER_ID} MATCHES "^(GNU)$" AND ${CMAKE_Fortran_COMPILER_V
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
endif()

# Find openMP if we need it.
if(OPENMP)
find_package(OpenMP REQUIRED COMPONENTS Fortran)
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(PNG REQUIRED)
find_package(bacio REQUIRED)
find_package(ZLIB REQUIRED)
if(bacio_VERSION LESS 2.5.0)
add_library(bacio::bacio ALIAS bacio::bacio_4)
endif()
find_package(ip 3.3.3 REQUIRED)
if(ip_VERSION LESS 5.0)
find_package(sp 2.3.3 REQUIRED)
endif()

# NCEPLIBS-w3emc may be required.
if (BUILD_WITH_W3EMC)
Expand Down
11 changes: 1 addition & 10 deletions src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
#
# George Gayno, Mark Potts, Alyson Stahl

# Set the compiler flags.
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$")
set(CMAKE_Fortran_FLAGS "-g -r8 -auto ${CMAKE_Fortran_FLAGS}")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 ${CMAKE_Fortran_FLAGS}")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "-g -fdefault-real-8 ${CMAKE_Fortran_FLAGS}")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 ${CMAKE_Fortran_FLAGS}")
endif()

# This is the fortran source code.
set(fortran_src copygb.F90)

# Build the executable.
set(exe_name copygb)
add_executable(${exe_name} ${fortran_src})
target_link_libraries(${exe_name} PRIVATE bacio::${bacio_name} w3emc::w3emc_d ip::ip_d)
target_link_libraries(${exe_name} PRIVATE bacio::bacio w3emc::w3emc_d ip::ip_d)
if(ip_VERSION LESS 5.0)
target_link_libraries(${exe_name} PRIVATE sp::sp_d)
endif()
Expand Down

0 comments on commit 5c4a240

Please sign in to comment.