|
1 | 1 | # Copyright The OpenTelemetry Authors |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | | -cmake_minimum_required(VERSION 3.9) |
| 4 | +cmake_minimum_required(VERSION 3.10) |
5 | 5 |
|
6 | | -# See https://cmake.org/cmake/help/v3.3/policy/CMP0057.html required by certain |
7 | | -# versions of gtest |
8 | | -cmake_policy(SET CMP0057 NEW) |
9 | | - |
10 | | -# See https://cmake.org/cmake/help/v3.12/policy/CMP0074.html required by certain |
11 | | -# version of zlib which CURL depends on. |
| 6 | +# See https://cmake.org/cmake/help/latest/policy/CMP0074.html required by |
| 7 | +# certain version of zlib which CURL depends on. |
12 | 8 | if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12") |
13 | 9 | cmake_policy(SET CMP0074 NEW) |
14 | 10 | endif() |
15 | 11 |
|
| 12 | +# Allow to use normal variable for option() |
| 13 | +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13") |
| 14 | + cmake_policy(SET CMP0077 NEW) |
| 15 | +endif() |
| 16 | + |
16 | 17 | # Prefer CMAKE_MSVC_RUNTIME_LIBRARY if possible |
17 | 18 | if(POLICY CMP0091) |
18 | 19 | cmake_policy(SET CMP0091 NEW) |
19 | 20 | endif() |
20 | 21 |
|
| 22 | +# MSVC RTTI flag /GR should not be not added to CMAKE_CXX_FLAGS by default. @see |
| 23 | +# https://cmake.org/cmake/help/latest/policy/CMP0117.html |
| 24 | +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0") |
| 25 | + cmake_policy(SET CMP0117 NEW) |
| 26 | +endif() |
| 27 | + |
21 | 28 | project(opentelemetry-cpp) |
22 | 29 |
|
23 | 30 | # Mark variables as used so cmake doesn't complain about them |
@@ -421,12 +428,16 @@ if(WITH_OTLP_GRPC |
421 | 428 | endif() |
422 | 429 | # Latest Protobuf imported targets and without legacy module support |
423 | 430 | if(TARGET protobuf::protoc) |
424 | | - project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE |
425 | | - protobuf::protoc) |
426 | | - # If protobuf::protoc is not a imported target, then we use the target |
427 | | - # directly for fallback |
428 | | - if(NOT PROTOBUF_PROTOC_EXECUTABLE) |
429 | | - set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) |
| 431 | + if(CMAKE_CROSSCOMPILING AND Protobuf_PROTOC_EXECUTABLE) |
| 432 | + set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) |
| 433 | + else() |
| 434 | + project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE |
| 435 | + protobuf::protoc) |
| 436 | + # If protobuf::protoc is not a imported target, then we use the target |
| 437 | + # directly for fallback |
| 438 | + if(NOT PROTOBUF_PROTOC_EXECUTABLE) |
| 439 | + set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) |
| 440 | + endif() |
430 | 441 | endif() |
431 | 442 | elseif(Protobuf_PROTOC_EXECUTABLE) |
432 | 443 | # Some versions of FindProtobuf.cmake uses mixed case instead of uppercase |
|
0 commit comments