Skip to content
Closed
Changes from all commits
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
42 changes: 37 additions & 5 deletions FindNanopb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,40 @@

include("GenericFindDependency")
option(nanopb_BUILD_GENERATOR "" OFF)
GenericFindDependency(
TARGET protobuf-nanopb
SOURCE_DIR "nanopb"
SYSTEM_INCLUDES
)

if(USE_OFFICIAL_NANOPB)
# Using official Nanopb from github and therefore manually including FindNanopb.cmake
GenericFindDependency(
TARGET protobuf-nanopb-static
SOURCE_DIR "nanopb"
SYSTEM_INCLUDES
)

# Instead of patches to the official Nanopb, we need to make all the adaptions here
include("${nanopb_SOURCE_DIR}/extra/FindNanopb.cmake")
target_include_directories(
protobuf-nanopb-static
PUBLIC
$<BUILD_INTERFACE:${nanopb_SOURCE_DIR}>
)
# without this, the compilations fails due to C99 asserts
target_compile_definitions(
protobuf-nanopb-static
PUBLIC
PB_NO_STATIC_ASSERT
)
# This is needed to avoid warnings about switch statements on enum types
target_compile_options(
protobuf-nanopb-static
PUBLIC
-Wno-switch-enum
)
# This is how the lib is used
add_library(protobuf-nanopb ALIAS protobuf-nanopb-static)
else()
GenericFindDependency(
TARGET protobuf-nanopb
SOURCE_DIR "nanopb"
SYSTEM_INCLUDES
)
endif()
Loading