Improve caffe detection function.

This commit is contained in:
2017-10-09 14:42:30 +02:00
parent 87da22390b
commit 96b3b695ab
2 changed files with 41 additions and 13 deletions

View File

@@ -30,8 +30,8 @@ target_link_libraries(fmri ${Boost_LIBRARIES})
# Require Caffe
find_package(Caffe REQUIRED)
include_directories(${Caffe_INCLUDE_DIR})
target_link_libraries(fmri ${Caffe_LIBS})
include_directories(${Caffe_INCLUDE_DIRS})
target_link_libraries(fmri ${Caffe_LIBRARIES})
# Require glog
find_package(Glog REQUIRED)

View File

@@ -1,14 +1,42 @@
# Caffe package for CNN Triplet training
unset(Caffe_FOUND)
#
# Try to find the Caffe library and include path.
# Once done this will define
#
# CAFFE_FOUND
# Caffe_INCLUDE_DIRS
# Caffe_LIBRARIES
#
# A custom location can be specified for the library using Caffe_DIR
#
find_path(Caffe_INCLUDE_DIR NAMES caffe/caffe.hpp caffe/common.hpp caffe/net.hpp caffe/proto/caffe.pb.h caffe/util/io.hpp
HINTS
/usr/local/include)
set (Caffe_DIR "" CACHE STRING
"Custom location of the root directory of a Caffe installation")
find_library(Caffe_LIBS NAMES caffe
HINTS
/usr/local/lib)
find_path(Caffe_INCLUDE_DIR
NAMES caffe.hpp
PATH_SUFFIXES include/caffe caffe
PATHS ${Caffe_DIR}
DOC "The directory where caffe.hpp resides")
if(Caffe_LIBS AND Caffe_INCLUDE_DIR)
set(Caffe_FOUND 1)
endif()
find_library(Caffe_LIBRARY
NAMES caffe
PATH_SUFFIXES build/lib
PATHS ${Caffe_DIR}
DOC "The Caffe library")
# handle the QUIETLY and REQUIRED arguments and set CAFFE_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Caffe
"Could NOT find Caffe. Declare Caffe_DIR (either using -DCaffe_DIR=<path> flag or via CMakeGUI/ccmake) to point to root directory of library."
Caffe_LIBRARY Caffe_INCLUDE_DIR)
if (CAFFE_FOUND)
set(Caffe_LIBRARIES ${Caffe_LIBRARY})
set(Caffe_INCLUDE_DIRS ${Caffe_INCLUDE_DIR})
endif(CAFFE_FOUND)
mark_as_advanced(
Caffe_INCLUDE_DIR
Caffe_LIBRARY)