Add option to use system Nanopb (#352)

This commit is contained in:
Florian Märkl 2020-10-25 21:08:13 +01:00 committed by GitHub
commit cbfa49551d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 13 deletions

25
cmake/FindNanopb.cmake Normal file
View file

@ -0,0 +1,25 @@
# Provides Nanopb::nanopb and NANOPB_GENERATOR_PY
find_package(nanopb CONFIG)
find_file(NANOPB_GENERATOR_PY nanopb_generator.py PATH_SUFFIXES bin)
find_path(Jerasure_INCLUDE_DIR NAMES pb_encode.h pb_decode.h)
find_library(Jerasure_LIBRARY NAMES Jerasure)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Nanopb
FOUND_VAR Nanopb_FOUND
REQUIRED_VARS
nanopb_FOUND
NANOPB_GENERATOR_PY
)
if(Nanopb_FOUND)
if(NOT TARGET Nanopb::nanopb)
add_library(Nanopb::nanopb ALIAS nanopb::protobuf-nanopb-static)
set_target_properties(Jerasure::Jerasure PROPERTIES
IMPORTED_LOCATION "${Jerasure_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${Jerasure_INCLUDE_DIRS}"
)
endif()
endif()