|
1 |
| -macro(check_append_cxx_compiler_flag OUTPUT_VAR) |
2 |
| - foreach(CHECK_FLAG ${ARGN}) |
3 |
| - check_cxx_compiler_flag(${CHECK_FLAG} |
4 |
| - "check_cxx_compiler_flag_${CHECK_FLAG}") |
5 |
| - if(check_cxx_compiler_flag_${CHECK_FLAG}) |
6 |
| - list(APPEND ${OUTPUT_VAR} ${CHECK_FLAG}) |
7 |
| - endif() |
8 |
| - endforeach() |
9 |
| -endmacro() |
10 |
| - |
11 |
| -if(NOT PATCH_PROTOBUF_SOURCES_OPTIONS_SET) |
12 |
| - if(MSVC) |
13 |
| - unset(PATCH_PROTOBUF_SOURCES_OPTIONS CACHE) |
14 |
| - set(PATCH_PROTOBUF_SOURCES_OPTIONS /wd4244 /wd4251 /wd4267 /wd4309) |
15 |
| - |
16 |
| - if(MSVC_VERSION GREATER_EQUAL 1922) |
17 |
| - # see |
18 |
| - # https://docs.microsoft.com/en-us/cpp/overview/cpp-conformance-improvements?view=vs-2019#improvements_162 |
19 |
| - # for detail |
20 |
| - list(APPEND PATCH_PROTOBUF_SOURCES_OPTIONS /wd5054) |
21 |
| - endif() |
22 |
| - |
23 |
| - if(MSVC_VERSION GREATER_EQUAL 1925) |
24 |
| - list(APPEND PATCH_PROTOBUF_SOURCES_OPTIONS /wd4996) |
25 |
| - endif() |
26 |
| - |
27 |
| - if(MSVC_VERSION LESS 1910) |
28 |
| - list(APPEND PATCH_PROTOBUF_SOURCES_OPTIONS /wd4800) |
29 |
| - endif() |
30 |
| - else() |
31 |
| - unset(PATCH_PROTOBUF_SOURCES_OPTIONS CACHE) |
32 |
| - include(CheckCXXCompilerFlag) |
33 |
| - check_append_cxx_compiler_flag( |
34 |
| - PATCH_PROTOBUF_SOURCES_OPTIONS -Wno-type-limits |
35 |
| - -Wno-deprecated-declarations -Wno-unused-parameter) |
36 |
| - endif() |
37 |
| - set(PATCH_PROTOBUF_SOURCES_OPTIONS_SET TRUE) |
38 |
| - if(PATCH_PROTOBUF_SOURCES_OPTIONS) |
39 |
| - set(PATCH_PROTOBUF_SOURCES_OPTIONS |
40 |
| - ${PATCH_PROTOBUF_SOURCES_OPTIONS} |
41 |
| - CACHE INTERNAL |
42 |
| - "Options to disable warning of generated protobuf sources" FORCE) |
43 |
| - endif() |
44 |
| -endif() |
45 |
| - |
46 |
| -function(patch_protobuf_sources) |
47 |
| - if(PATCH_PROTOBUF_SOURCES_OPTIONS) |
48 |
| - foreach(PROTO_SRC ${ARGN}) |
49 |
| - unset(PROTO_SRC_OPTIONS) |
50 |
| - get_source_file_property(PROTO_SRC_OPTIONS ${PROTO_SRC} COMPILE_OPTIONS) |
51 |
| - if(PROTO_SRC_OPTIONS) |
52 |
| - list(APPEND PROTO_SRC_OPTIONS ${PATCH_PROTOBUF_SOURCES_OPTIONS}) |
53 |
| - else() |
54 |
| - set(PROTO_SRC_OPTIONS ${PATCH_PROTOBUF_SOURCES_OPTIONS}) |
55 |
| - endif() |
56 |
| - |
57 |
| - set_source_files_properties( |
58 |
| - ${PROTO_SRC} PROPERTIES COMPILE_OPTIONS "${PROTO_SRC_OPTIONS}") |
59 |
| - endforeach() |
60 |
| - unset(PROTO_SRC) |
61 |
| - unset(PROTO_SRC_OPTIONS) |
62 |
| - endif() |
63 |
| -endfunction() |
64 |
| - |
65 |
| -function(patch_protobuf_targets) |
66 |
| - if(PATCH_PROTOBUF_SOURCES_OPTIONS) |
67 |
| - foreach(PROTO_TARGET ${ARGN}) |
68 |
| - unset(PROTO_TARGET_OPTIONS) |
69 |
| - get_target_property(PROTO_TARGET_OPTIONS ${PROTO_TARGET} COMPILE_OPTIONS) |
70 |
| - if(PROTO_TARGET_OPTIONS) |
71 |
| - list(APPEND PROTO_TARGET_OPTIONS ${PATCH_PROTOBUF_SOURCES_OPTIONS}) |
72 |
| - else() |
73 |
| - set(PROTO_TARGET_OPTIONS ${PATCH_PROTOBUF_SOURCES_OPTIONS}) |
74 |
| - endif() |
75 |
| - |
76 |
| - set_target_properties( |
77 |
| - ${PROTO_TARGET} PROPERTIES COMPILE_OPTIONS "${PROTO_TARGET_OPTIONS}") |
78 |
| - endforeach() |
79 |
| - unset(PROTO_TARGET) |
80 |
| - unset(PROTO_TARGET_OPTIONS) |
81 |
| - endif() |
82 |
| -endfunction() |
| 1 | +include(${PROJECT_SOURCE_DIR}/cmake/proto-options-patch.cmake) |
83 | 2 |
|
84 | 3 | set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")
|
85 | 4 |
|
|
0 commit comments