Skip to content

Commit

Permalink
add wgrib2_meta.h (#109)
Browse files Browse the repository at this point in the history
* add wgrib2_meta.h

* more values in meta file
  • Loading branch information
edwardhartnett authored Apr 10, 2024
1 parent 55312de commit 9cac176
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ option(USE_AEC "Use AEC?" off)
option(MAKE_FTN_API "add ftn api?" off)
option(DISABLE_STAT "disable posix feature" off)
set(BUILD_COMMENTS "stock build")

option(BUILD_LIB "Build wgrib2 library?" on)
option(BUILD_SHARED_LIB "Build shared library?" off)


list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

#set default install path if not provided
# Set default install path if not provided.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"${CMAKE_BINARY_DIR}/install"
Expand Down Expand Up @@ -129,7 +127,8 @@ if(USE_PNG)
find_package(PNG REQUIRED)
endif()

# write config.h
# write config.h. This is used internally by wgrib2 code and is not
# installed.
message(STATUS "Writing config.h...")
FILE(WRITE "wgrib2/config.h" "/* config.h generated by cmake */\n")
FILE(APPEND "wgrib2/config.h" "#ifndef _CONFIG_H\n")
Expand Down
11 changes: 10 additions & 1 deletion wgrib2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,22 @@ if(MAKE_FTN_API)
endif()

add_subdirectory(gctpc)

# make this an object lib so we can re-use most of object files
# The only files that differ are ${callable_src} which are compiled
# with -DCALLABLE_WGRIB2
add_library(obj_lib OBJECT ${lib_src})
target_compile_definitions(obj_lib PUBLIC ${definitions_list})

# Write wgrib2_meta.h. This is installed and contains pre-processor
# defines for other packages using wgrib2.
configure_file (
"${PROJECT_SOURCE_DIR}/wgrib2/wgrib2_meta.h.in"
"${PROJECT_BINARY_DIR}/wgrib2/wgrib2_meta.h"
)

if(BUILD_LIB)

# with -DCALLABLE_WGRIB2 for the lib
if(BUILD_SHARED_LIB)
add_library(wgrib2_lib SHARED ${lib_src} $<TARGET_OBJECTS:gctpc> ${callable_src})
Expand Down Expand Up @@ -132,7 +141,7 @@ target_link_libraries(wgrib2_exe PRIVATE gctpc)
target_link_libraries(wgrib2_exe PRIVATE obj_lib)

if(BUILD_LIB)
set(headers wgrib2_api.h wgrib2.h)
set(headers wgrib2_api.h wgrib2.h ${CMAKE_BINARY_DIR}/wgrib2_meta.h)
target_link_libraries(wgrib2_lib PUBLIC gctpc)
# if(USE_IPOLATES EQUAL 1)
# target_link_libraries(wgrib2_lib PRIVATE ip:ip_4 sp:sp_4)
Expand Down
37 changes: 37 additions & 0 deletions wgrib2/wgrib2_meta.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* This header file may be used by other packages to learn about this
* wgrib2 build.
*
* Edward Hartnett 3/29/24 */
#ifndef _WGRIB2_META_H
#define _WGRIB2_META_H

#cmakedefine USE_NETCDF3
#cmakedefine USE_NETCDF4
#cmakedefine USE_HDF5
#cmakedefine USE_REGEX
#cmakedefine USE_TIGGE
#cmakedefine USE_MYSQL
#define USE_IPOLATES @USE_IPOLATES@
#cmakedefine USE_UDF
#cmakedefine USE_OPENMP
#cmakedefine USE_PROJ4
#cmakedefine USE_WMO_VALIDATION
#cmakedefine DISABLE_TIMEZONE
#cmakedefine DISABLE_ALARM
#cmakedefine USE_NAMES NCEP
#cmakedefine USE_G2CLIB
#cmakedefine USE_PNG
#cmakedefine USE_JASPER
#cmakedefine USE_OPENJPEG
#cmakedefine MAKE_FTN_API
#cmakedefine USE_AEC

#define WGRIB2_VERSION "@CMAKE_PROJECT_VERSION@"
#define BUILD_COMMENTS "@BUILD_COMMENTS@"
#define CC "@CMAKE_C_COMPILER@ @CMAKE_C_COMPILER_ID@"
#define FORTRAN "@CMAKE_Fortran_COMPILER@ @CMAKE_Fortran_COMPILER_ID@"
#define CPPFLAGS "@CMAKE_C_FLAGS@"
#define FFLAGS "@CMAKE_Fortran_FLAGS@"
#define WGRIB2_VERSION "@CMAKE_PROJECT_VERSION@"

#endif

0 comments on commit 9cac176

Please sign in to comment.