1*da0073e9SAndroid Build Coastguard Worker# - Config file for the Caffe2 package 2*da0073e9SAndroid Build Coastguard Worker# It defines the following variable(s) 3*da0073e9SAndroid Build Coastguard Worker# CAFFE2_INCLUDE_DIRS - include directories for FooBar 4*da0073e9SAndroid Build Coastguard Worker# as well as Caffe2 targets for other cmake libraries to use. 5*da0073e9SAndroid Build Coastguard Worker 6*da0073e9SAndroid Build Coastguard Worker# library version information 7*da0073e9SAndroid Build Coastguard Worker 8*da0073e9SAndroid Build Coastguard Worker# Utils functions. 9*da0073e9SAndroid Build Coastguard Workerinclude("${CMAKE_CURRENT_LIST_DIR}/public/utils.cmake") 10*da0073e9SAndroid Build Coastguard Worker 11*da0073e9SAndroid Build Coastguard Worker# Depending on whether Caffe2 uses gflags during compile time or 12*da0073e9SAndroid Build Coastguard Worker# not, invoke gflags. 13*da0073e9SAndroid Build Coastguard Workerif(@USE_GFLAGS@) 14*da0073e9SAndroid Build Coastguard Worker include("${CMAKE_CURRENT_LIST_DIR}/public/gflags.cmake") 15*da0073e9SAndroid Build Coastguard Worker if(NOT TARGET gflags) 16*da0073e9SAndroid Build Coastguard Worker message(FATAL_ERROR 17*da0073e9SAndroid Build Coastguard Worker "Your installed Caffe2 version uses gflags but the gflags library " 18*da0073e9SAndroid Build Coastguard Worker "cannot be found. Did you accidentally remove it, or have you set " 19*da0073e9SAndroid Build Coastguard Worker "the right CMAKE_PREFIX_PATH and/or GFLAGS_ROOT_DIR? If you do not " 20*da0073e9SAndroid Build Coastguard Worker "have gflags, you will need to install gflags and set the library " 21*da0073e9SAndroid Build Coastguard Worker "path accordingly.") 22*da0073e9SAndroid Build Coastguard Worker endif() 23*da0073e9SAndroid Build Coastguard Workerendif() 24*da0073e9SAndroid Build Coastguard Worker 25*da0073e9SAndroid Build Coastguard Worker# Depending on whether Caffe2 uses glog during compile time or 26*da0073e9SAndroid Build Coastguard Worker# not, invoke glog. 27*da0073e9SAndroid Build Coastguard Workerif(@USE_GLOG@) 28*da0073e9SAndroid Build Coastguard Worker include("${CMAKE_CURRENT_LIST_DIR}/public/glog.cmake") 29*da0073e9SAndroid Build Coastguard Worker if(NOT TARGET glog::glog) 30*da0073e9SAndroid Build Coastguard Worker message(FATAL_ERROR 31*da0073e9SAndroid Build Coastguard Worker "Your installed Caffe2 version uses glog but the glog library " 32*da0073e9SAndroid Build Coastguard Worker "cannot be found. Did you accidentally remove it, or have you set " 33*da0073e9SAndroid Build Coastguard Worker "the right CMAKE_PREFIX_PATH and/or GFLAGS_ROOT_DIR? If you do not " 34*da0073e9SAndroid Build Coastguard Worker "have glog, you will need to install glog and set the library " 35*da0073e9SAndroid Build Coastguard Worker "path accordingly.") 36*da0073e9SAndroid Build Coastguard Worker endif() 37*da0073e9SAndroid Build Coastguard Workerendif() 38*da0073e9SAndroid Build Coastguard Worker 39*da0073e9SAndroid Build Coastguard Worker# Protobuf 40*da0073e9SAndroid Build Coastguard Workerif(@CAFFE2_LINK_LOCAL_PROTOBUF@) 41*da0073e9SAndroid Build Coastguard Worker if(NOT TARGET protobuf::libprotobuf) 42*da0073e9SAndroid Build Coastguard Worker # Define protobuf::libprotobuf as a dummy target to resolve references to 43*da0073e9SAndroid Build Coastguard Worker # protobuf::libprotobuf in Caffe2Targets.cmake. 44*da0073e9SAndroid Build Coastguard Worker add_library(dummy INTERFACE) 45*da0073e9SAndroid Build Coastguard Worker add_library(protobuf::libprotobuf ALIAS dummy) 46*da0073e9SAndroid Build Coastguard Worker endif() 47*da0073e9SAndroid Build Coastguard Workerelse() 48*da0073e9SAndroid Build Coastguard Worker include("${CMAKE_CURRENT_LIST_DIR}/public/protobuf.cmake") 49*da0073e9SAndroid Build Coastguard Worker if(NOT TARGET protobuf::libprotobuf) 50*da0073e9SAndroid Build Coastguard Worker message(FATAL_ERROR 51*da0073e9SAndroid Build Coastguard Worker "Your installed Caffe2 version uses protobuf but the protobuf library " 52*da0073e9SAndroid Build Coastguard Worker "cannot be found. Did you accidentally remove it, or have you set " 53*da0073e9SAndroid Build Coastguard Worker "the right CMAKE_PREFIX_PATH? If you do not have protobuf, you will " 54*da0073e9SAndroid Build Coastguard Worker "need to install protobuf and set the library path accordingly.") 55*da0073e9SAndroid Build Coastguard Worker endif() 56*da0073e9SAndroid Build Coastguard Worker message(STATUS "Caffe2: Protobuf version " ${Protobuf_VERSION}) 57*da0073e9SAndroid Build Coastguard Worker # If during build time we know the protobuf version, we will also do a sanity 58*da0073e9SAndroid Build Coastguard Worker # check to ensure that the protobuf library that Caffe2 found is consistent 59*da0073e9SAndroid Build Coastguard Worker # with the compiled version. 60*da0073e9SAndroid Build Coastguard Worker if(@CAFFE2_KNOWN_PROTOBUF_VERSION@) 61*da0073e9SAndroid Build Coastguard Worker if(NOT (${Protobuf_VERSION} VERSION_EQUAL @Protobuf_VERSION@)) 62*da0073e9SAndroid Build Coastguard Worker message(FATAL_ERROR 63*da0073e9SAndroid Build Coastguard Worker "Your installed Caffe2 is built with protobuf " 64*da0073e9SAndroid Build Coastguard Worker "@Protobuf_VERSION@" 65*da0073e9SAndroid Build Coastguard Worker ", while your current cmake setting discovers protobuf version " 66*da0073e9SAndroid Build Coastguard Worker ${Protobuf_VERSION} 67*da0073e9SAndroid Build Coastguard Worker ". Please specify a protobuf version that is the same as the built " 68*da0073e9SAndroid Build Coastguard Worker "version.") 69*da0073e9SAndroid Build Coastguard Worker endif() 70*da0073e9SAndroid Build Coastguard Worker endif() 71*da0073e9SAndroid Build Coastguard Workerendif() 72*da0073e9SAndroid Build Coastguard Worker 73*da0073e9SAndroid Build Coastguard Workerif (@USE_ROCM@) 74*da0073e9SAndroid Build Coastguard Worker include("${CMAKE_CURRENT_LIST_DIR}/public/LoadHIP.cmake") 75*da0073e9SAndroid Build Coastguard Workerendif() 76*da0073e9SAndroid Build Coastguard Worker 77*da0073e9SAndroid Build Coastguard Workerif(@USE_CUDA@) 78*da0073e9SAndroid Build Coastguard Worker # The file public/cuda.cmake exclusively uses CAFFE2_USE_*. 79*da0073e9SAndroid Build Coastguard Worker # If Caffe2 was compiled with the libraries below, they must 80*da0073e9SAndroid Build Coastguard Worker # be found again when including the Caffe2 target. 81*da0073e9SAndroid Build Coastguard Worker set(CAFFE2_USE_CUDA @USE_CUDA@) 82*da0073e9SAndroid Build Coastguard Worker 83*da0073e9SAndroid Build Coastguard Worker # Add current directory to module path so we pick up FindCUDAToolkit.cmake 84*da0073e9SAndroid Build Coastguard Worker set(old_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}") 85*da0073e9SAndroid Build Coastguard Worker list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") 86*da0073e9SAndroid Build Coastguard Worker include("${CMAKE_CURRENT_LIST_DIR}/public/cuda.cmake") 87*da0073e9SAndroid Build Coastguard Worker set(CMAKE_MODULE_PATH "${old_CMAKE_MODULE_PATH}") 88*da0073e9SAndroid Build Coastguard Worker 89*da0073e9SAndroid Build Coastguard Worker if(@CAFFE2_USE_CUDA@ AND NOT CAFFE2_USE_CUDA) 90*da0073e9SAndroid Build Coastguard Worker message(FATAL_ERROR 91*da0073e9SAndroid Build Coastguard Worker "Your installed Caffe2 version uses CUDA but I cannot find the CUDA " 92*da0073e9SAndroid Build Coastguard Worker "libraries. Please set the proper CUDA prefixes and / or install " 93*da0073e9SAndroid Build Coastguard Worker "CUDA.") 94*da0073e9SAndroid Build Coastguard Worker endif() 95*da0073e9SAndroid Build Coastguard Workerendif() 96*da0073e9SAndroid Build Coastguard Worker 97*da0073e9SAndroid Build Coastguard Workerif(@USE_XPU@) 98*da0073e9SAndroid Build Coastguard Worker # Add current directory to module path so we pick up FindSYCLToolkit.cmake 99*da0073e9SAndroid Build Coastguard Worker set(old_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}") 100*da0073e9SAndroid Build Coastguard Worker list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") 101*da0073e9SAndroid Build Coastguard Worker include("${CMAKE_CURRENT_LIST_DIR}/public/xpu.cmake") 102*da0073e9SAndroid Build Coastguard Worker set(CMAKE_MODULE_PATH "${old_CMAKE_MODULE_PATH}") 103*da0073e9SAndroid Build Coastguard Workerendif() 104*da0073e9SAndroid Build Coastguard Worker 105*da0073e9SAndroid Build Coastguard Workerif(@CAFFE2_USE_MKL@) 106*da0073e9SAndroid Build Coastguard Worker include("${CMAKE_CURRENT_LIST_DIR}/public/mkl.cmake") 107*da0073e9SAndroid Build Coastguard Workerendif() 108*da0073e9SAndroid Build Coastguard Worker 109*da0073e9SAndroid Build Coastguard Workerif(@USE_MKLDNN@) 110*da0073e9SAndroid Build Coastguard Worker include("${CMAKE_CURRENT_LIST_DIR}/public/mkldnn.cmake") 111*da0073e9SAndroid Build Coastguard Workerendif() 112*da0073e9SAndroid Build Coastguard Worker 113*da0073e9SAndroid Build Coastguard Worker# import targets 114*da0073e9SAndroid Build Coastguard Workerinclude ("${CMAKE_CURRENT_LIST_DIR}/Caffe2Targets.cmake") 115*da0073e9SAndroid Build Coastguard Worker 116*da0073e9SAndroid Build Coastguard Worker# Interface libraries, that allows one to build proper link flags. 117*da0073e9SAndroid Build Coastguard Worker# We will also define a helper variable, Caffe2_MAIN_LIBS, that resolves to 118*da0073e9SAndroid Build Coastguard Worker# the main caffe2 libraries in cases of cuda presence / absence. 119*da0073e9SAndroid Build Coastguard Workerset(Caffe2_MAIN_LIBS torch_library) 120*da0073e9SAndroid Build Coastguard Worker 121*da0073e9SAndroid Build Coastguard Worker# include directory. 122*da0073e9SAndroid Build Coastguard Worker# 123*da0073e9SAndroid Build Coastguard Worker# Newer versions of CMake set the INTERFACE_INCLUDE_DIRECTORIES property 124*da0073e9SAndroid Build Coastguard Worker# of the imported targets. It is hence not necessary to add this path 125*da0073e9SAndroid Build Coastguard Worker# manually to the include search path for targets which link to gflags. 126*da0073e9SAndroid Build Coastguard Worker# The following lines are here for backward compatibility, in case one 127*da0073e9SAndroid Build Coastguard Worker# would like to use the old-style include path. 128*da0073e9SAndroid Build Coastguard Workerget_filename_component( 129*da0073e9SAndroid Build Coastguard Worker CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 130*da0073e9SAndroid Build Coastguard Worker# Note: the current list dir is _INSTALL_PREFIX/share/cmake/Gloo. 131*da0073e9SAndroid Build Coastguard Workerget_filename_component( 132*da0073e9SAndroid Build Coastguard Worker _INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) 133*da0073e9SAndroid Build Coastguard Workerset(CAFFE2_INCLUDE_DIRS "${_INSTALL_PREFIX}/include") 134