From 05349ce7a61a3b00f624966d32b86fa81fd46e62 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 25 Nov 2021 01:50:54 +0300 Subject: [PATCH] Do not build protobuf twice --- cmake/add_warning.cmake | 6 +++--- contrib/protobuf-cmake/CMakeLists.txt | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/add_warning.cmake b/cmake/add_warning.cmake index bc9642c9cc6..e7797fcc7a6 100644 --- a/cmake/add_warning.cmake +++ b/cmake/add_warning.cmake @@ -12,13 +12,13 @@ macro (add_warning flag) if (SUPPORTS_CXXFLAG_${underscored_flag}) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W${flag}") else () - message (WARNING "Flag -W${flag} is unsupported") + message (STATUS "Flag -W${flag} is unsupported") endif () if (SUPPORTS_CFLAG_${underscored_flag}) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W${flag}") else () - message (WARNING "Flag -W${flag} is unsupported") + message (STATUS "Flag -W${flag} is unsupported") endif () endmacro () @@ -39,7 +39,7 @@ macro (target_add_warning target flag) if (SUPPORTS_CXXFLAG_${underscored_flag}) target_compile_options (${target} PRIVATE "-W${flag}") else () - message (WARNING "Flag -W${flag} is unsupported") + message (STATUS "Flag -W${flag} is unsupported") endif () endmacro () diff --git a/contrib/protobuf-cmake/CMakeLists.txt b/contrib/protobuf-cmake/CMakeLists.txt index 82e212417ac..484524f4278 100644 --- a/contrib/protobuf-cmake/CMakeLists.txt +++ b/contrib/protobuf-cmake/CMakeLists.txt @@ -211,7 +211,9 @@ add_library(protobuf::libprotoc ALIAS libprotoc) set(protoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/main.cc) -if (NOT CMAKE_CROSSCOMPILING) +if (CMAKE_HOST_SYSTEM_NAME STREQUAL CMAKE_SYSTEM_NAME + AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL CMAKE_SYSTEM_PROCESSOR) + add_executable(protoc ${protoc_files}) target_link_libraries(protoc libprotoc libprotobuf pthread) add_executable(protobuf::protoc ALIAS protoc)