diff options
author | rsgowman <rgowman@google.com> | 2018-02-09 12:15:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-09 12:15:21 -0500 |
commit | 274fe52bbf817ef9d35638effb4de08454acfc6d (patch) | |
tree | d422177d355315a3314578c8554e4ebc86d1e042 /cmake | |
parent | ecef4aa308c213c000d115123824d55482ffbdad (diff) |
cmake build fixes (#770)
* Fix nanopb (in cmake build)
Look for binaries in the src dir (since that's where we build now.) This
error would be masked if a previous build had completed prior to
switching nanopb to build out of src.
Also, don't patch the protoc path multiple times. This could be
triggered by (eg) 'make && make clean && make'.
* Add resource_path.{h,cc} to the cmake build
* Fix signed/unsigned int comparison warnings
* Ensure FieldValue tag_ is initialized during cp/mv ctor.
Otherwise, the assignment operator attempts to deallocate based on the
(uninitialized) tag_ variable, posssibly leading to segfaults.
* Fix tests that throw exceptions.
The (previous) tests checked to ensure that an abort() occurs, but if
ABSL_HAVE_EXCEPTIONS is defined on non-macos (which is currently the
default) then the assertions will throw a std::logic_error rather than
abort()ing.
On macos, an exception is thrown too, but the exception doesn't derrive
from std::exception, so ASSERT_DEATH_* doesn't catch it (hence why
ASSERT_DEATH_* actually works.)
To resolve this, I've switched to ASSERT_ANY_THROW.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindNanopb.cmake | 2 | ||||
-rw-r--r-- | cmake/external/nanopb.cmake | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/cmake/FindNanopb.cmake b/cmake/FindNanopb.cmake index fb22aef..43c2886 100644 --- a/cmake/FindNanopb.cmake +++ b/cmake/FindNanopb.cmake @@ -10,7 +10,7 @@ find_path( find_library( NANOPB_LIBRARY NAMES protobuf-nanopb protobuf-nanopbd - HINTS ${BINARY_DIR}/src/nanopb-build + HINTS ${BINARY_DIR}/src/nanopb ) find_package_handle_standard_args( diff --git a/cmake/external/nanopb.cmake b/cmake/external/nanopb.cmake index 5df0cf5..d09c668 100644 --- a/cmake/external/nanopb.cmake +++ b/cmake/external/nanopb.cmake @@ -55,9 +55,14 @@ ExternalProject_Add( # 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. + # + # NB: cmake sometimes runs the patch command multiple times in the same src + # dir, so we need to make sure this is idempotent. (eg 'make && make clean && + # make') PATCH_COMMAND - perl -i -pe s,protoc,${NANOPB_PROTOC_BIN},g - ./CMakeLists.txt ./generator/proto/Makefile + grep ${NANOPB_PROTOC_BIN} ./generator/proto/Makefile + || perl -i -pe s,protoc,${NANOPB_PROTOC_BIN},g + ./CMakeLists.txt ./generator/proto/Makefile UPDATE_COMMAND "" INSTALL_COMMAND "" |