aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmake
diff options
context:
space:
mode:
authorGravatar Rich Gowman <rgowman@google.com>2018-02-05 13:55:20 -0500
committerGravatar Rich Gowman <rgowman@google.com>2018-02-06 10:02:30 -0500
commitfd0b332f4609bb3a2e3918f24ca470b1a3c2a301 (patch)
tree7e62f15dae074c8370488184be0e1d9decf2e67a /cmake
parentc896fab35f0b37123175eb1011e6155ecb36a92b (diff)
Downgrade nanopb from 0.4.0-dev to 0.3.8.
Also regenerate the protos
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindNanopb.cmake2
-rw-r--r--cmake/external/nanopb.cmake40
2 files changed, 19 insertions, 23 deletions
diff --git a/cmake/FindNanopb.cmake b/cmake/FindNanopb.cmake
index fab6f4a..fb22aef 100644
--- a/cmake/FindNanopb.cmake
+++ b/cmake/FindNanopb.cmake
@@ -21,7 +21,7 @@ find_package_handle_standard_args(
)
if(NANOPB_FOUND)
- set(NANOPB_INCLUDE_DIRS ${NANOPB_INCLUDE_DIR} )
+ set(NANOPB_INCLUDE_DIRS ${NANOPB_INCLUDE_DIR})
if (NOT TARGET nanopb)
add_library(nanopb UNKNOWN IMPORTED)
diff --git a/cmake/external/nanopb.cmake b/cmake/external/nanopb.cmake
index d602d9a..c78613f 100644
--- a/cmake/external/nanopb.cmake
+++ b/cmake/external/nanopb.cmake
@@ -1,6 +1,4 @@
-# Copyright 2018 Google
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
+# Copyright 2018 Google # # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@@ -18,7 +16,7 @@ include(ExternalProjectFlags)
ExternalProject_GitSource(
NANOPB_GIT
GIT_REPOSITORY "https://github.com/nanopb/nanopb.git"
- GIT_TAG "master" # Needs the most recent. 0.3.9 doesn't fully support cmake.
+ GIT_TAG "0.3.8"
)
ExternalProject_Add(
@@ -28,34 +26,32 @@ ExternalProject_Add(
${NANOPB_GIT}
+ BUILD_IN_SOURCE ON
+
PREFIX ${PROJECT_BINARY_DIR}/external/nanopb
+ # Note for (not yet released) nanopb 0.4.0: nanopb will (likely) switch to
+ # cmake for the protoc plugin. Set these additional cmake variables to use
+ # it.
+ # -Dnanopb_BUILD_GENERATOR:BOOL=ON
+ # -Dnanopb_PROTOC_PATH:STRING=${FIREBASE_INSTALL_DIR}/external/protobuf/src/protobuf-build/src/protoc
CMAKE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS:BOOL=OFF
- -Dnanopb_BUILD_GENERATOR:BOOL=ON
- -Dnanopb_PROTOC_PATH:STRING=${FIREBASE_INSTALL_DIR}/external/protobuf/src/protobuf-build/src/protoc
BUILD_COMMAND
- ${CMAKE_COMMAND} --build .
- # NB: The following additional build commands are only necessary to
- # regenerate the nanopb proto files.
- COMMAND
- ${CMAKE_COMMAND} -E make_directory <BINARY_DIR>/generator/proto
COMMAND
- ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/generator/proto/__init__.py <BINARY_DIR>/generator/proto/
- COMMAND
- ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/generator/protoc-gen-nanopb <BINARY_DIR>/generator/
- COMMAND
- ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/generator/nanopb_generator.py <BINARY_DIR>/generator/
- COMMAND
- ${CMAKE_COMMAND} -E copy <BINARY_DIR>/nanopb_pb2.py <BINARY_DIR>/generator/proto/
+ ${CMAKE_COMMAND} --build .
+ # NB: The following additional command is only necessary to regenerate the
+ # nanopb proto files.
COMMAND
- ${CMAKE_COMMAND} -E copy <BINARY_DIR>/plugin_pb2.py <BINARY_DIR>/generator/proto/
+ make -C <SOURCE_DIR>/generator/proto
- # TODO: once we clone via a tag (rather than the master branch) we should
- # disable updates; i.e.:
- # UPDATE_COMMAND ""
+ # nanopb relies on $PATH for the location of protoc. cmake makes it difficult
+ # to adjust the path, so we'll just patch the build files with the exact
+ # location of protoc.
+ PATCH_COMMAND perl -i -pe s,protoc,${FIREBASE_INSTALL_DIR}/external/protobuf/src/protobuf-build/src/protoc,g ./CMakeLists.txt ./generator/proto/Makefile
+ UPDATE_COMMAND ""
INSTALL_COMMAND ""
)