Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Findwgrib2.cmake #55

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions Modules/Findwgrib2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This module produces the target wgrib2::wgrib2

find_path(WGRIB2_INCLUDES wgrib2api.mod)

find_library(WGRIB2_LIBRARIES libwgrib2.a)

find_program(WGRIB2_EXE wgrib2)
execute_process(COMMAND ${WGRIB2_EXE} --version OUTPUT_VARIABLE version_str)
string(SUBSTRING ${version_str} 3 5 version)

mark_as_advanced(WGRIB2_INCLUDES WGRIB2_LIBRARIES)

add_library(wgrib2::wgrib2 UNKNOWN IMPORTED)

set_target_properties(wgrib2::wgrib2 PROPERTIES
IMPORTED_LOCATION "${WGRIB2_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${WGRIB2_INCLUDES}"
INTERFACE_LINK_LIBRARIES "${WGRIB2_LIBRARIES}")

find_package_handle_standard_args(wgrib2
REQUIRED_VARS WGRIB2_LIBRARIES WGRIB2_INCLUDES WGRIB2_EXE
VERSION_VAR version
)