[2/N] Clean up CMake target linking (#109986)

This PR cleans up more CMake target linking.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/109986
Approved by: https://github.com/malfet
This commit is contained in:
cyy 2023-10-01 05:36:08 +00:00 committed by PyTorch MergeBot
parent 669faab0ad
commit ef5ff79019
2 changed files with 3 additions and 6 deletions

View File

@ -81,11 +81,11 @@ if(WERROR)
endif()
# ---[ Dependency of c10
if(${USE_GFLAGS})
if(C10_USE_GFLAGS)
target_link_libraries(c10 PUBLIC gflags)
endif()
if(${USE_GLOG})
if(C10_USE_GLOG)
target_link_libraries(c10 PUBLIC glog::glog)
endif()
target_link_libraries(c10 PRIVATE fmt::fmt-header-only)

View File

@ -127,10 +127,9 @@ endif()
find_package(Threads REQUIRED)
if(TARGET Threads::Threads)
list(APPEND Caffe2_DEPENDENCY_LIBS Threads::Threads)
add_library(caffe2::Threads ALIAS Threads::Threads)
else()
message(FATAL_ERROR
"Cannot find threading library. Caffe2 requires Threads to compile.")
"Cannot find threading library. PyTorch requires Threads to compile.")
endif()
if(USE_TBB)
@ -685,8 +684,6 @@ if(USE_GLOG)
include(${CMAKE_CURRENT_LIST_DIR}/public/glog.cmake)
if(TARGET glog::glog)
set(CAFFE2_USE_GOOGLE_GLOG 1)
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
list(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS glog::glog)
else()
message(WARNING
"glog is not found. Caffe2 will build without glog support but it is "