Find Caffe as its own target.
This commit is contained in:
@@ -18,30 +18,14 @@ add_executable(fmri ${fmri_SRC})
|
|||||||
# Enable better warnings
|
# Enable better warnings
|
||||||
target_compile_options(fmri PRIVATE "-Wall" "-Wextra" "-pedantic")
|
target_compile_options(fmri PRIVATE "-Wall" "-Wextra" "-pedantic")
|
||||||
|
|
||||||
# Enable CUDA if available
|
|
||||||
find_package(CUDA QUIET)
|
|
||||||
if (CUDA_FOUND)
|
|
||||||
message("CUDA found, enabling support")
|
|
||||||
target_link_libraries(fmri PUBLIC CUDA::CUDA)
|
|
||||||
else()
|
|
||||||
message("No CUDA, compiling CPU-only mode")
|
|
||||||
add_definitions(-DCPU_ONLY)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Find dependencies
|
# Find dependencies
|
||||||
find_package(OpenCV REQUIRED)
|
|
||||||
find_package(Boost REQUIRED COMPONENTS system)
|
|
||||||
find_package(Caffe REQUIRED)
|
find_package(Caffe REQUIRED)
|
||||||
find_package(Glog REQUIRED)
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(GLUT REQUIRED)
|
find_package(GLUT REQUIRED)
|
||||||
find_package(png++ REQUIRED)
|
find_package(png++ REQUIRED)
|
||||||
|
|
||||||
target_link_libraries(fmri PUBLIC
|
target_link_libraries(fmri PUBLIC
|
||||||
${OpenCV_LIBS}
|
Caffe::Caffe
|
||||||
${Caffe_LIBRARIES}
|
|
||||||
Glog::Glog
|
|
||||||
Boost::system
|
|
||||||
GLUT::GLUT
|
GLUT::GLUT
|
||||||
OpenGL::GLU
|
OpenGL::GLU
|
||||||
png++::png++
|
png++::png++
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ set (Caffe_DIR "" CACHE STRING
|
|||||||
"Custom location of the root directory of a Caffe installation")
|
"Custom location of the root directory of a Caffe installation")
|
||||||
|
|
||||||
find_path(Caffe_INCLUDE_DIR
|
find_path(Caffe_INCLUDE_DIR
|
||||||
NAMES caffe.hpp
|
NAMES caffe/caffe.hpp
|
||||||
PATH_SUFFIXES include/caffe caffe
|
|
||||||
PATHS ${Caffe_DIR}
|
PATHS ${Caffe_DIR}
|
||||||
DOC "The directory where caffe.hpp resides")
|
DOC "The directory where caffe.hpp resides")
|
||||||
|
|
||||||
@@ -24,6 +23,19 @@ find_library(Caffe_LIBRARY
|
|||||||
PATHS ${Caffe_DIR}
|
PATHS ${Caffe_DIR}
|
||||||
DOC "The Caffe library")
|
DOC "The Caffe library")
|
||||||
|
|
||||||
|
find_package(OpenCV REQUIRED)
|
||||||
|
find_package(Glog REQUIRED)
|
||||||
|
find_package(Boost 1.55 REQUIRED COMPONENTS system)
|
||||||
|
|
||||||
|
find_package(CUDA)
|
||||||
|
if (CUDA_FOUND)
|
||||||
|
message("CUDA found, enabling support")
|
||||||
|
set(Caffe_ADDITIONAL_LIBS CUDA::CUDA)
|
||||||
|
else()
|
||||||
|
message("No CUDA, compiling CPU-only mode")
|
||||||
|
set(Caffe_DEFINITIONS "CPU_ONLY")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set CAFFE_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set CAFFE_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
@@ -33,8 +45,16 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Caffe
|
|||||||
Caffe_LIBRARY Caffe_INCLUDE_DIR)
|
Caffe_LIBRARY Caffe_INCLUDE_DIR)
|
||||||
|
|
||||||
if (CAFFE_FOUND)
|
if (CAFFE_FOUND)
|
||||||
set(Caffe_LIBRARIES ${Caffe_LIBRARY})
|
add_library(Caffe::Caffe UNKNOWN IMPORTED)
|
||||||
set(Caffe_INCLUDE_DIRS ${Caffe_INCLUDE_DIR})
|
set_target_properties(Caffe::Caffe PROPERTIES
|
||||||
|
INTERFACE_COMPILE_DEFINITIONS "${Caffe_DEFINITIONS}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${Caffe_INCLUDE_DIR};${OpenCV_INCLUDE_DIRS}"
|
||||||
|
IMPORTED_LOCATION "${Caffe_LIBRARY}"
|
||||||
|
INTERFACE_LINK_LIBRARIES "Glog::Glog;Boost::system;${OpenCV_LIBRARIES};${Caffe_ADDITIONAL_LIBS}"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(Caffe_LIBRARIES ${Caffe_LIBRARY})
|
||||||
|
set(Caffe_INCLUDE_DIRS ${Caffe_INCLUDE_DIR})
|
||||||
endif(CAFFE_FOUND)
|
endif(CAFFE_FOUND)
|
||||||
|
|
||||||
mark_as_advanced(
|
mark_as_advanced(
|
||||||
|
|||||||
Reference in New Issue
Block a user