Unverified Commit 0b629e68 authored by Robert Edmonds's avatar Robert Edmonds Committed by GitHub

Merge pull request #714 from clementperon/fix_cmake

Fix CI issues with CMake
parents 5c13d7df af0ea6fa
...@@ -17,7 +17,9 @@ jobs: ...@@ -17,7 +17,9 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install Linux dependencies - name: Install Linux dependencies
if: startsWith(matrix.os, 'ubuntu') if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev run: |
sudo apt-get update -y
sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev
- name: Install Mac dependencies - name: Install Mac dependencies
if: startsWith(matrix.os, 'macos') if: startsWith(matrix.os, 'macos')
run: brew install protobuf automake run: brew install protobuf automake
...@@ -60,7 +62,9 @@ jobs: ...@@ -60,7 +62,9 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install dependencies - name: Install dependencies
run: sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev valgrind run: |
sudo apt-get update -y
sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev valgrind
- name: Run distcheck with valgrind - name: Run distcheck with valgrind
run: | run: |
./autogen.sh ./autogen.sh
...@@ -72,7 +76,9 @@ jobs: ...@@ -72,7 +76,9 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install dependencies - name: Install dependencies
run: sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev lcov run: |
sudo apt-get update -y
sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev lcov
- name: Run coverage build - name: Run coverage build
run: | run: |
./autogen.sh ./autogen.sh
...@@ -96,7 +102,9 @@ jobs: ...@@ -96,7 +102,9 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install Linux dependencies - name: Install Linux dependencies
if: startsWith(matrix.os, 'ubuntu') if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev run: |
sudo apt-get update -y
sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev
- name: Install Mac dependencies - name: Install Mac dependencies
if: startsWith(matrix.os, 'macos') if: startsWith(matrix.os, 'macos')
run: brew install protobuf abseil run: brew install protobuf abseil
......
...@@ -8,6 +8,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR) ...@@ -8,6 +8,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
cmake_policy(SET CMP0074 NEW) cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0091 NEW) cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0112 NEW) cmake_policy(SET CMP0112 NEW)
# TODO: Convert DART to CTEST
if(POLICY CMP0145)
cmake_policy(SET CMP0145 OLD)
endif()
PROJECT(protobuf-c C CXX) PROJECT(protobuf-c C CXX)
...@@ -15,7 +19,14 @@ if (MSVC AND NOT BUILD_SHARED_LIBS) ...@@ -15,7 +19,14 @@ if (MSVC AND NOT BUILD_SHARED_LIBS)
SET(Protobuf_USE_STATIC_LIBS ON) SET(Protobuf_USE_STATIC_LIBS ON)
endif (MSVC AND NOT BUILD_SHARED_LIBS) endif (MSVC AND NOT BUILD_SHARED_LIBS)
FIND_PACKAGE(Protobuf REQUIRED) FIND_PACKAGE(Protobuf CONFIG)
if(Protobuf_FOUND)
# Keep compatibility with FindProtobuf CMake module
set(PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protobuf::protoc>)
else()
MESSAGE(STATUS "Protobuf CMake config not found fallback to Cmake Module")
FIND_PACKAGE(Protobuf REQUIRED)
endif()
file(REAL_PATH "${PROTOBUF_INCLUDE_DIR}" PROTOBUF_INCLUDE_DIR) file(REAL_PATH "${PROTOBUF_INCLUDE_DIR}" PROTOBUF_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
...@@ -112,7 +123,7 @@ if (MSVC AND NOT BUILD_SHARED_LIBS) ...@@ -112,7 +123,7 @@ if (MSVC AND NOT BUILD_SHARED_LIBS)
foreach(flag_var foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_FLAGS_RELWITHDEBINFO) CMAKE_C_FLAGS_MINSIZEREL CMAKE_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD") if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
...@@ -209,7 +220,7 @@ GENERATE_TEST_SOURCES(${TEST_DIR}/test-full.proto t/test-full.pb-c.c t/test-full ...@@ -209,7 +220,7 @@ GENERATE_TEST_SOURCES(${TEST_DIR}/test-full.proto t/test-full.pb-c.c t/test-full
ADD_EXECUTABLE(cxx-generate-packed-data ${TEST_DIR}/generated-code2/cxx-generate-packed-data.cc t/test-full.pb.h t/test-full.pb.cc protobuf-c/protobuf-c.pb.cc protobuf-c/protobuf-c.pb.h) ADD_EXECUTABLE(cxx-generate-packed-data ${TEST_DIR}/generated-code2/cxx-generate-packed-data.cc t/test-full.pb.h t/test-full.pb.cc protobuf-c/protobuf-c.pb.cc protobuf-c/protobuf-c.pb.h)
TARGET_LINK_LIBRARIES(cxx-generate-packed-data TARGET_LINK_LIBRARIES(cxx-generate-packed-data
${PROTOBUF_LIBRARY} protobuf::libprotobuf
${protobuf_ABSL_USED_TARGETS} ${protobuf_ABSL_USED_TARGETS}
${protobuf_UTF8_USED_TARGETS} ${protobuf_UTF8_USED_TARGETS}
) )
...@@ -316,12 +327,12 @@ ADD_TEST(test-version test-version) ...@@ -316,12 +327,12 @@ ADD_TEST(test-version test-version)
if(WIN32) if(WIN32)
set_tests_properties( set_tests_properties(
test-generated-code test-generated-code
test-generated-code2 test-generated-code2
test-generated-code3 test-generated-code3
test-issue220 test-issue220
test-issue251 test-issue251
test-version test-version
PROPERTIES ENVIRONMENT "PATH=${WINDOWS_PATH_VARIABLE}\\;$<TARGET_FILE_DIR:protoc-gen-c>" ) PROPERTIES ENVIRONMENT "PATH=${WINDOWS_PATH_VARIABLE}\\;$<TARGET_FILE_DIR:protoc-gen-c>" )
endif(WIN32) endif(WIN32)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment