CMakeLists.txt: Fix protoc-c crashes on Linux

-lpthread was missing from the linker command line. See
https://github.com/protocolbuffers/protobuf/issues/5107 for more
details.

.travis.yml: Run CMake debug build for verification
This commit is contained in:
Ilya Lipnitskiy 2020-05-08 18:55:03 -07:00
parent db6c49cc43
commit ce75229b6a
2 changed files with 11 additions and 0 deletions

View File

@ -15,6 +15,7 @@ env:
global:
- PROTOBUF_VERSION=3.7.1
- PKG_CONFIG_PATH=$HOME/protobuf-$PROTOBUF_VERSION-bin/lib/pkgconfig
- CMAKE_PREFIX_PATH=$HOME/protobuf-$PROTOBUF_VERSION-bin
install:
- pip install --user cpp-coveralls
@ -27,6 +28,7 @@ script:
- ./configure && make -j2 distcheck VERBOSE=1 && make clean
- ./configure --enable-valgrind-tests CFLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined" && make -j2 distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-valgrind-tests CFLAGS=\"-fsanitize=undefined -fno-sanitize-recover=undefined\"" VERBOSE=1 && make clean
- ./configure --enable-code-coverage && make -j2 && make check
- ( mkdir build-cmake/bin && cd build-cmake/bin && cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=protobuf-c-bin ../ && make -j2 && make test && make install)
after_success:
- cpp-coveralls --build-root . --exclude t/ --exclude /usr/include --exclude protobuf-$PROTOBUF_VERSION --exclude protoc-c

View File

@ -134,6 +134,15 @@ TARGET_LINK_LIBRARIES(test-generated-code3 protobuf-c)
ENDIF()
# https://github.com/protocolbuffers/protobuf/issues/5107
IF(CMAKE_HOST_UNIX)
FIND_PACKAGE(Threads REQUIRED)
TARGET_LINK_LIBRARIES(protoc-gen-c ${CMAKE_THREAD_LIBS_INIT})
IF(CMAKE_BUILD_TYPE MATCHES Debug)
TARGET_LINK_LIBRARIES(cxx-generate-packed-data ${CMAKE_THREAD_LIBS_INIT})
ENDIF()
ENDIF()
INSTALL(TARGETS protoc-gen-c protobuf-c RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
INSTALL(FILES ${MAIN_DIR}/protobuf-c/protobuf-c.h DESTINATION include/protobuf-c)
INSTALL(FILES ${MAIN_DIR}/protobuf-c/protobuf-c.h DESTINATION include)