2023-03-31 11:23:31 +00:00
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# SPDX-FileCopyrightText: 2023 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause
if ( NOT GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION )
set ( GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.2" )
endif ( )
if ( NOT ZLIB_FOUND )
find_package ( ZLIB )
set_package_properties ( ZLIB PROPERTIES
U R L " h t t p s : / / w w w . z l i b . n e t / "
P U R P O S E " R e q u i r e d t o b u i l d P r o t o c o l B u f f e r s . "
T Y P E R E Q U I R E D
)
if ( ZLIB_FOUND AND ZLIB_VERSION_STRING )
set_package_properties ( ZLIB PROPERTIES
D E S C R I P T I O N " A M a s s i v e l y S p i f f y Y e t D e l i c a t e l y U n o b t r u s i v e C o m p r e s s i o n Library ( found: v ${ ZLIB_VERSION_STRING } ) "
)
else ( )
set_package_properties ( ZLIB PROPERTIES
D E S C R I P T I O N " A M a s s i v e l y S p i f f y Y e t D e l i c a t e l y U n o b t r u s i v e C o m p r e s s i o n L i b r a r y "
)
endif ( )
if ( ZLIB_FOUND )
set ( ZLIB_LIBRARIES_ ${ ZLIB_LIBRARIES } )
set ( USE_ZLIB -Dprotobuf_WITH_ZLIB=ON )
else ( )
set ( ZLIB_LIBRARIES_ "" )
set ( USE_ZLIB -Dprotobuf_WITH_ZLIB=OFF )
endif ( )
else ( )
set ( ZLIB_LIBRARIES_ ${ ZLIB_LIBRARIES } )
set ( USE_ZLIB -Dprotobuf_WITH_ZLIB=ON )
endif ( )
include ( GNUInstallDirs )
list ( APPEND UTF8_LIBRARIES
$ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ S T A T I C _ L I B R A R Y _ P R E F I X } u t f 8 _ v a l i d i t y $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
$ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ S T A T I C _ L I B R A R Y _ P R E F I X } u t f 8 _ r a n g e $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
)
# 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
c d $ { G N S S S D R _ B I N A R Y _ D I R } / t h i r d p a r t y / p r o t o b u f / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / s r c / g o o g l e / p r o t o b u f / & &
$ { P a t c h _ E X E C U T A B L E } $ { G N S S S D R _ B I N A R Y _ D I R } / t h i r d p a r t y / p r o t o b u f / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / s r c / g o o g l e / p r o t o b u f / p o r t . h < $ { G N S S S D R _ S O U R C E _ D I R } / s r c / t e s t s / d a t a / p r o t o b u f 2 2 . p a t c h
)
# 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 ( )
set ( PROTOBUF_PATCH_COMMAND "" )
endif ( )
else ( )
set ( PROTOBUF_PATCH_COMMAND "" )
endif ( )
ExternalProject_Add ( protobuf- ${ GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION }
P R E F I X $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N }
G I T _ R E P O S I T O R Y h t t p s : / / g i t h u b . c o m / p r o t o c o l b u f f e r s / p r o t o b u f
G I T _ T A G v $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N }
G I T _ P R O G R E S S O N
U P D A T E _ C O M M A N D " "
P A T C H _ C O M M A N D $ { P R O T O B U F _ P A T C H _ C O M M A N D }
S O U R C E _ D I R $ { G N S S S D R _ B I N A R Y _ D I R } / t h i r d p a r t y / p r o t o b u f / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N }
B I N A R Y _ D I R $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N }
C M A K E _ A R G S
- D C M A K E _ C X X _ C O M P I L E R = $ { C M A K E _ C X X _ C O M P I L E R }
- D C M A K E _ C _ C O M P I L E R = $ { C M A K E _ C _ C O M P I L E R }
- D B U I L D _ S H A R E D _ L I B S = O F F
- D C M A K E _ B U I L D _ T Y P E = $ < $ < C O N F I G : D e b u g > : D e b u g > $ < $ < C O N F I G : R e l e a s e > : R e l e a s e > $ < $ < C O N F I G : R e l W i t h D e b I n f o > : R e l W i t h D e b I n f o > $ < $ < C O N F I G : M i n S i z e R e l > : M i n S i z e R e l > $ < $ < C O N F I G : N o O p t W i t h A S M > : D e b u g > $ < $ < C O N F I G : C o v e r a g e > : D e b u g > $ < $ < C O N F I G : O 2 W i t h A S M > : R e l W i t h D e b I n f o > $ < $ < C O N F I G : O 3 W i t h A S M > : R e l W i t h D e b I n f o > $ < $ < C O N F I G : A S A N > : D e b u g >
- D C M A K E _ C X X _ V I S I B I L I T Y _ P R E S E T = h i d d e n
- D C M A K E _ V I S I B I L I T Y _ I N L I N E S _ H I D D E N = 1
- D C M A K E _ I N S T A L L _ P R E F I X = $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N }
- D p r o t o b u f _ B U I L D _ T E S T S = O F F
- D p r o t o b u f _ A B S L _ P R O V I D E R = p a c k a g e
$ { U S E _ Z L I B }
B U I L D _ C O M M A N D $ { C M A K E _ C O M M A N D }
" - - b u i l d " " $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } "
" - - c o n f i g " $ < $ < C O N F I G : D e b u g > : D e b u g > $ < $ < C O N F I G : R e l e a s e > : R e l e a s e > $ < $ < C O N F I G : R e l W i t h D e b I n f o > : R e l W i t h D e b I n f o > $ < $ < C O N F I G : M i n S i z e R e l > : M i n S i z e R e l > $ < $ < C O N F I G : N o O p t W i t h A S M > : D e b u g > $ < $ < C O N F I G : C o v e r a g e > : D e b u g > $ < $ < C O N F I G : O 2 W i t h A S M > : R e l W i t h D e b I n f o > $ < $ < C O N F I G : O 3 W i t h A S M > : R e l W i t h D e b I n f o > $ < $ < C O N F I G : A S A N > : D e b u g >
" - - t a r g e t " i n s t a l l
2023-04-04 12:02:06 +00:00
B U I L D _ B Y P R O D U C T S $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ F I N D _ L I B R A R Y _ P R E F I X E S } p r o t o b u f $ < $ < C O N F I G : D e b u g > : d > $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
2023-03-31 11:23:31 +00:00
$ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / b i n / p r o t o c
$ { A B S L _ L I B R A R I E S }
$ { U T F 8 _ L I B R A R I E S }
I N S T A L L _ C O M M A N D " "
)
file ( MAKE_DIRECTORY ${ GNSSSDR_BINARY_DIR } /protobuf- ${ GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION } /include )
file ( MAKE_DIRECTORY ${ GNSSSDR_BINARY_DIR } /protobuf- ${ GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION } / ${ CMAKE_INSTALL_LIBDIR } )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
find_library ( CoreFoundation CoreFoundation )
else ( )
set ( CoreFoundation "" )
endif ( )
set ( PROTOBUF_ABSL_USED_TARGETS
a b s l : : a b s l _ c h e c k
a b s l : : a b s l _ l o g
a b s l : : a l g o r i t h m
a b s l : : b a s e
a b s l : : b i n d _ f r o n t
a b s l : : b i t s
a b s l : : b t r e e
a b s l : : c l e a n u p
a b s l : : c o r d
a b s l : : c o r e _ h e a d e r s
a b s l : : d e b u g g i n g
a b s l : : d i e _ i f _ n u l l
a b s l : : d y n a m i c _ a n n o t a t i o n s
a b s l : : f l a g s
a b s l : : f l a t _ h a s h _ m a p
a b s l : : f l a t _ h a s h _ s e t
a b s l : : f u n c t i o n _ r e f
a b s l : : h a s h
a b s l : : l a y o u t
a b s l : : l o g _ i n i t i a l i z e
a b s l : : l o g _ s e v e r i t y
a b s l : : m e m o r y
a b s l : : n o d e _ h a s h _ m a p
a b s l : : n o d e _ h a s h _ s e t
a b s l : : o p t i o n a l
a b s l : : s p a n
a b s l : : s t a t u s
a b s l : : s t a t u s o r
a b s l : : s t r i n g s
a b s l : : s y n c h r o n i z a t i o n
a b s l : : t i m e
a b s l : : t y p e _ t r a i t s
a b s l : : u t i l i t y
a b s l : : v a r i a n t
)
if ( NOT TARGET protobuf::libprotobuf )
add_library ( protobuf::libprotobuf STATIC IMPORTED )
add_dependencies ( protobuf::libprotobuf protobuf- ${ GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION } )
set_target_properties ( protobuf::libprotobuf PROPERTIES
I M P O R T E D _ L I N K _ I N T E R F A C E _ L A N G U A G E S " C X X "
2023-04-04 12:02:06 +00:00
I M P O R T E D _ C O N F I G U R A T I O N S " N o n e ; D e b u g ; R e l e a s e ; R e l W i t h D e b I n f o ; M i n S i z e R e l "
M A P _ I M P O R T E D _ C O N F I G _ N O O P T W I T H A S M D e b u g
M A P _ I M P O R T E D _ C O N F I G _ C O V E R A G E D e b u g
M A P _ I M P O R T E D _ C O N F I G _ O 2 W I T H A S M R e l W i t h D e b I n f o
M A P _ I M P O R T E D _ C O N F I G _ O 3 W I T H A S M R e l W i t h D e b I n f o
M A P _ I M P O R T E D _ C O N F I G _ A S A N D e b u g
I M P O R T E D _ L O C A T I O N _ N O N E $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ F I N D _ L I B R A R Y _ P R E F I X E S } p r o t o b u f $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
I M P O R T E D _ L O C A T I O N _ D E B U G $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ F I N D _ L I B R A R Y _ P R E F I X E S } p r o t o b u f d $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
I M P O R T E D _ L O C A T I O N _ R E L E A S E $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ F I N D _ L I B R A R Y _ P R E F I X E S } p r o t o b u f $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
I M P O R T E D _ L O C A T I O N _ R E L W I T H D E B I N F O $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ F I N D _ L I B R A R Y _ P R E F I X E S } p r o t o b u f $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
I M P O R T E D _ L O C A T I O N _ M I N S I Z E R E L $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ F I N D _ L I B R A R Y _ P R E F I X E S } p r o t o b u f $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
I N T E R F A C E _ I N C L U D E _ D I R E C T O R I E S $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / i n c l u d e
I N T E R F A C E _ L I N K _ L I B R A R I E S " $ { Z L I B _ L I B R A R I E S _ } ; $ { C o r e F o u n d a t i o n } ; $ { U T F 8 _ L I B R A R I E S } ; $ { P R O T O B U F _ A B S L _ U S E D _ T A R G E T S } ; $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ F I N D _ L I B R A R Y _ P R E F I X E S } p r o t o b u f $ < $ < C O N F I G : D e b u g > : d > $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X } "
2023-03-31 11:23:31 +00:00
)
endif ( )
if ( NOT TARGET protobuf::protoc )
add_executable ( protobuf::protoc IMPORTED )
add_dependencies ( protobuf::protoc protobuf- ${ GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION } )
unset ( Protobuf_PROTOC_EXECUTABLE )
set ( PROTOBUF_PROTOC_EXECUTABLE "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc" )
set_target_properties ( protobuf::protoc PROPERTIES
I M P O R T E D _ L I N K _ I N T E R F A C E _ L A N G U A G E S " C X X "
2023-04-04 12:02:06 +00:00
I M P O R T E D _ L O C A T I O N $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / b i n / p r o t o c
I N T E R F A C E _ L I N K _ L I B R A R I E S $ { G N S S S D R _ B I N A R Y _ D I R } / p r o t o b u f - $ { G N S S S D R _ P R O T O C O L B U F F E R S _ L O C A L _ V E R S I O N } / $ { C M A K E _ I N S T A L L _ L I B D I R } / $ { C M A K E _ F I N D _ L I B R A R Y _ P R E F I X E S } p r o t o c $ < $ < C O N F I G : D e b u g > : d > $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X }
2023-03-31 11:23:31 +00:00
)
endif ( )