Debian Codegraph @

extra/protobuf/protobuf-24.4/cmake/protobuf-configure-target.cmake

raw
1 # Protocol Buffers - Google's data interchange format
2 # Copyright 2013 Google LLC All rights reserved.
3 # https://developers.google.com/protocol-buffers/
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
14 # distribution.
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 # Refactors configuration options set on all Protobuf targets
32 function(protobuf_configure_target target)
33 target_compile_features("${target}" PUBLIC cxx_std_17)
34 if (MSVC)
35 # Build with multiple processes
36 if (NOT WIN32_CLANG)
37 target_compile_options("${target}" PRIVATE /MP)
38 endif()
39 # Set source file and execution character sets to UTF-8
40 target_compile_options("${target}" PRIVATE /utf-8)
41 # MSVC warning suppressions
42 target_compile_options("${target}" PRIVATE
43 /wd4065 # switch statement contains 'default' but no 'case' labels
44 /wd4146 # unary minus operator applied to unsigned type
45 /wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
46 /wd4251 # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
47 /wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
48 /wd4305 # 'identifier' : truncation from 'type1' to 'type2'
49 /wd4307 # 'operator' : integral constant overflow
50 /wd4309 # 'conversion' : truncation of constant value
51 /wd4334 # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
52 /wd4355 # 'this' : used in base member initializer list
53 /wd4506 # no definition for inline function 'function'
54 /wd4800 # 'type' : forcing value to bool 'true' or 'false' (performance warning)
55 /wd4996 # The compiler encountered a deprecated declaration.
56 )
57 # Allow big object
58 target_compile_options("${target}" PRIVATE /bigobj)
59 endif ()
60 if (protobuf_UNICODE)
61 target_compile_definitions("${target}" PRIVATE -DUNICODE -D_UNICODE)
62 endif ()
63 target_compile_definitions("${target}" PRIVATE -DGOOGLE_PROTOBUF_CMAKE_BUILD)
64
65 if (protobuf_DISABLE_RTTI)
66 target_compile_definitions("${target}" PRIVATE -DGOOGLE_PROTOBUF_NO_RTTI=1)
67 endif()
68
69 # The Intel compiler isn't able to deal with noinline member functions of
70 # template classes defined in headers. As such it spams the output with
71 # warning #2196: routine is both "inline" and "noinline"
72 # This silences that warning.
73 if (CMAKE_CXX_COMPILER_ID MATCHES Intel)
74 target_compile_options("${target}" PRIVATE -diag-disable=2196)
75 endif()
76
77 if (HAVE_ZLIB)
78 target_compile_definitions("${target}" PRIVATE -DHAVE_ZLIB)
79 endif ()
80 endfunction ()