Merge pull request #9307 from owent-contrib/fix_9306

[CMAKE] `protobuf::libprotoc` and `protobuf::protoc` should be optional in legacy `protobuf-module.cmake` when crossing compiling.
pull/9476/head
Joshua Haberman 3 years ago committed by GitHub
commit 3ea30d8084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      cmake/protobuf-module.cmake.in

@ -94,7 +94,7 @@ function(_protobuf_find_libraries name filename)
elseif(${name}_LIBRARY) elseif(${name}_LIBRARY)
# Honor cache entry used by CMake 3.5 and lower. # Honor cache entry used by CMake 3.5 and lower.
set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE) set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE)
else() elseif(TARGET protobuf::lib${filename})
get_target_property(${name}_LIBRARY_RELEASE protobuf::lib${filename} get_target_property(${name}_LIBRARY_RELEASE protobuf::lib${filename}
LOCATION_RELEASE) LOCATION_RELEASE)
get_target_property(${name}_LIBRARY_RELWITHDEBINFO protobuf::lib${filename} get_target_property(${name}_LIBRARY_RELWITHDEBINFO protobuf::lib${filename}
@ -134,23 +134,25 @@ get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf
INTERFACE_INCLUDE_DIRECTORIES) INTERFACE_INCLUDE_DIRECTORIES)
# Set the protoc Executable # Set the protoc Executable
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc if(NOT Protobuf_PROTOC_EXECUTABLE AND TARGET protobuf::protoc)
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_RELEASE) IMPORTED_LOCATION_RELEASE)
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_RELWITHDEBINFO) IMPORTED_LOCATION_RELWITHDEBINFO)
endif() endif()
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_MINSIZEREL) IMPORTED_LOCATION_MINSIZEREL)
endif() endif()
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_DEBUG) IMPORTED_LOCATION_DEBUG)
endif() endif()
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_NOCONFIG) IMPORTED_LOCATION_NOCONFIG)
endif()
endif() endif()
# Version info variable # Version info variable

Loading…
Cancel
Save