mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-10-31 23:26:22 +00:00
Fix for Clang 16
This commit is contained in:
parent
08dcf3f88c
commit
2479e889b8
@ -4,10 +4,24 @@
|
||||
# SPDX-FileCopyrightText: 2023 C. Fernandez-Prades cfernandez(at)cttc.es
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# Downloads and builds the protoc compiler and static libraries of Protocol
|
||||
# Buffers >= v22.0 (see https://protobuf.dev/) It requires CMake >= 3.10 and the
|
||||
# abseil-cpp >= 20230117 libraries (see https://github.com/abseil/abseil-cpp)
|
||||
# already installed. Zlib is used if found.
|
||||
#
|
||||
# Note: requires the patch command if using GCC >= 13 or Clang >= 16
|
||||
#
|
||||
# Creates protobuf::libprotobuf and protobuf::protoc imported targets.
|
||||
|
||||
|
||||
if(NOT GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION)
|
||||
set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.2")
|
||||
endif()
|
||||
|
||||
if(NOT GNSSSDR_BINARY_DIR)
|
||||
set(GNSSSDR_BINARY_DIR "${PROJECT_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
if(NOT ZLIB_FOUND)
|
||||
find_package(ZLIB)
|
||||
set_package_properties(ZLIB PROPERTIES
|
||||
@ -43,22 +57,19 @@ list(APPEND UTF8_LIBRARIES
|
||||
${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}utf8_range${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
)
|
||||
|
||||
# Fix for GCC 13
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "12.99")
|
||||
find_program(Patch_EXECUTABLE NAME patch PATHS ENV PATH)
|
||||
if(NOT Patch_EXECUTABLE)
|
||||
message(FATAL_ERROR "The patch command is not found. It is required to build Protocol Buffers. Please check your OS documentation and install the patch command.")
|
||||
endif()
|
||||
set(PROTOBUF_PATCH_COMMAND
|
||||
cd ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/ &&
|
||||
${Patch_EXECUTABLE} ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h < ${GNSSSDR_SOURCE_DIR}/src/tests/data/protobuf22.patch
|
||||
)
|
||||
# Patch only once
|
||||
if(EXISTS ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h)
|
||||
set(PROTOBUF_PATCH_COMMAND "")
|
||||
endif()
|
||||
else()
|
||||
# Fix for GCC 13 and Clang 16
|
||||
if(((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13")) OR
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16")))
|
||||
find_program(Patch_EXECUTABLE NAME patch PATHS ENV PATH)
|
||||
if(NOT Patch_EXECUTABLE)
|
||||
message(FATAL_ERROR "The patch command is not found. It is required to build Protocol Buffers. Please check your OS documentation and install the patch command.")
|
||||
endif()
|
||||
set(PROTOBUF_PATCH_COMMAND
|
||||
cd ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/ &&
|
||||
${Patch_EXECUTABLE} ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h < ${GNSSSDR_SOURCE_DIR}/src/tests/data/protobuf22.patch
|
||||
)
|
||||
# Patch only once
|
||||
if(EXISTS ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h)
|
||||
set(PROTOBUF_PATCH_COMMAND "")
|
||||
endif()
|
||||
else()
|
||||
|
Loading…
Reference in New Issue
Block a user