mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-28 18:04:51 +00:00
Fix detection of Protocol Buffers when using CMake < 3.6
This commit is contained in:
parent
e0f3fe66f0
commit
8ab202b666
@ -1797,7 +1797,24 @@ set_package_properties(Protobuf PROPERTIES
|
||||
PURPOSE "Used to serialize output data in a way that can be read by other applications."
|
||||
TYPE REQUIRED
|
||||
)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.6)
|
||||
if(PROTOBUF_FOUND)
|
||||
set(Protobuf_FOUND ${PROTOBUF_FOUND})
|
||||
endif()
|
||||
endif()
|
||||
if(Protobuf_FOUND AND CMAKE_VERSION VERSION_LESS 3.9)
|
||||
if(PROTOBUF_INCLUDE_DIR)
|
||||
set(Protobuf_INCLUDE_DIR ${PROTOBUF_INCLUDE_DIR})
|
||||
endif()
|
||||
if(PROTOBUF_LIBRARY)
|
||||
set(Protobuf_LIBRARY ${PROTOBUF_LIBRARY})
|
||||
endif()
|
||||
if(PROTOBUF_PROTOC_EXECUTABLE)
|
||||
set(Protobuf_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE})
|
||||
endif()
|
||||
if(PROTOBUF_PROTOC_LIBRARY)
|
||||
set(Protobuf_PROTOC_LIBRARY ${PROTOBUF_PROTOC_EXECUTABLE})
|
||||
endif()
|
||||
add_library(protobuf::libprotobuf SHARED IMPORTED)
|
||||
set_target_properties(protobuf::libprotobuf PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
||||
@ -1811,6 +1828,20 @@ if(Protobuf_FOUND AND CMAKE_VERSION VERSION_LESS 3.9)
|
||||
IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE}"
|
||||
INTERFACE_LINK_LIBRARIES "${Protobuf_PROTOC_LIBRARY}"
|
||||
)
|
||||
if(${Protobuf_VERSION} VERSION_EQUAL "0.0.0")
|
||||
set(_PROTOBUF_COMMON_HEADER ${Protobuf_INCLUDE_DIR}/google/protobuf/stubs/common.h)
|
||||
set(Protobuf_VERSION "")
|
||||
set(Protobuf_LIB_VERSION "")
|
||||
file(STRINGS ${_PROTOBUF_COMMON_HEADER} _PROTOBUF_COMMON_H_CONTENTS REGEX "#define[ \t]+GOOGLE_PROTOBUF_VERSION[ \t]+")
|
||||
if(_PROTOBUF_COMMON_H_CONTENTS MATCHES "#define[ \t]+GOOGLE_PROTOBUF_VERSION[ \t]+([0-9]+)")
|
||||
set(Protobuf_LIB_VERSION "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
unset(_PROTOBUF_COMMON_H_CONTENTS)
|
||||
math(EXPR _PROTOBUF_MAJOR_VERSION "${Protobuf_LIB_VERSION} / 1000000")
|
||||
math(EXPR _PROTOBUF_MINOR_VERSION "${Protobuf_LIB_VERSION} / 1000 % 1000")
|
||||
math(EXPR _PROTOBUF_SUBMINOR_VERSION "${Protobuf_LIB_VERSION} % 1000")
|
||||
set(Protobuf_VERSION "${_PROTOBUF_MAJOR_VERSION}.${_PROTOBUF_MINOR_VERSION}.${_PROTOBUF_SUBMINOR_VERSION}")
|
||||
endif()
|
||||
endif()
|
||||
if(Protobuf_FOUND AND CMAKE_CROSSCOMPILING)
|
||||
find_program(PROTOC_EXECUTABLE protoc
|
||||
|
Loading…
Reference in New Issue
Block a user