Only add aliasing to targets if the corresponding package was found (#9404)

This commit is contained in:
Stella Stamenova 2021-10-20 11:32:08 -07:00 committed by GitHub
parent f1123c2fb3
commit 9fc53df33a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -739,8 +739,7 @@ if(onnxruntime_PREFER_SYSTEM_LIB)
find_package(Protobuf)
endif()
if(Protobuf_FOUND OR Protobuf_FOUND)
if (Protobuf_FOUND)
message("Use protobuf from preinstalled system lib")
if (onnxruntime_USE_FULL_PROTOBUF)
set(PROTOBUF_LIB protobuf::libprotobuf)
@ -825,11 +824,12 @@ get_filename_component(ORTTRAINING_ROOT "${ORTTRAINING_ROOT}" ABSOLUTE)
get_filename_component(REPO_ROOT "${REPO_ROOT}" ABSOLUTE)
set(ONNXRUNTIME_INCLUDE_DIR ${REPO_ROOT}/include/onnxruntime)
if(onnxruntime_PREFER_SYSTEM_LIB)
if (onnxruntime_PREFER_SYSTEM_LIB)
find_package(date)
add_library(date_interface ALIAS date::date)
endif()
if(NOT TARGET date::date)
if (date_FOUND)
add_library(date_interface ALIAS date::date)
else()
add_subdirectory(external/date EXCLUDE_FROM_ALL)
endif()
@ -1417,11 +1417,12 @@ set(FLATBUFFERS_INSTALL OFF CACHE BOOL "FLATBUFFERS_INSTALL" FORCE)
set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATHASH" FORCE)
set(FLATBUFFERS_BUILD_FLATLIB ON CACHE BOOL "FLATBUFFERS_BUILD_FLATLIB" FORCE)
set_msvc_c_cpp_compiler_warning_level(4)
if(onnxruntime_PREFER_SYSTEM_LIB)
if (onnxruntime_PREFER_SYSTEM_LIB)
find_package(Flatbuffers)
add_library(flatbuffers ALIAS flatbuffers::flatbuffers)
endif()
if(NOT TARGET flatbuffers::flatbuffers)
if (Flatbuffers_FOUND)
add_library(flatbuffers ALIAS flatbuffers::flatbuffers)
else()
add_subdirectory(external/flatbuffers EXCLUDE_FROM_ALL)
endif()
set_msvc_c_cpp_compiler_warning_level(3)