Skip to content

find_package(Caffe REQUIRED) fails because of 3rdparty libraries for Windows build #5674

@jasjuang

Description

@jasjuang

Your system configuration

Operating system: Windows 10
Compiler: Visual Studio 2015
CUDA version (if applicable): 8.0
CUDNN version (if applicable): Not applicable
BLAS: built in version enabled by -DBLAS=open in cmake
Python or MATLAB version (for pycaffe and matcaffe respectively): 2.7 for Python and no Matlab

Issue summary

find_package(Caffe REQUIRED) fails because of the 3rdparty libraries cannot be located by CMake.

Steps to reproduce

Build and Install Caffe from scratch,

git clone https://github.com/BVLC/caffe
cd caffe && mkdir build && cd build
git checkout windows
cmake -A x64 -DBLAS=open -DCMAKE_INSTALL_PREFIX="C:/Program Files/Caffe" ..
msbuild Caffe.sln /p:Configuration=Release
msbuild INSTALL.vcxproj /p:Configuration=Release

Now try to use Caffe with your own CMakeLists that looks like

cmake_minimum_required(VERSION 3.7)
project(CaffeExample)

set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/CaffeExample.cpp)

find_package( Caffe REQUIRED )

add_executable(${PROJECT_NAME} ${PROJECT_SRCS})

target_link_libraries(${PROJECT_NAME} ${Caffe_LIBRARIES})

CaffeExample.cpp can be any minimal code using Caffe. Now if I try to run cmake for my own code,

cd CaffeExample && mkdir build && cd build
cmake -A x64 ..

CMake Error at C:/externallibs/caffe/build/CaffeConfig.cmake:42 (find_package):
  Could not find a package configuration file provided by "gflags" with any
  of the following names:

    gflagsConfig.cmake
    gflags-config.cmake

  Add the installation prefix of "gflags" to CMAKE_PREFIX_PATH or set
  "gflags_DIR" to a directory containing one of the above files.  If "gflags"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CaffeExample/CMakeLists.txt:6 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/Users/jasju/Desktop/CaffeExample/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/jasju/Desktop/CaffeExample/build/CMakeFiles/CMakeError.log".

At the line 42 of CaffeConfig.cmake there is a find_package(gflags REQUIRED NO_MODULE), since only config mode is allowed, according to https://cmake.org/cmake/help/v3.0/command/find_package.html, it will only work if gflags happen to at one of the default locations it search for in config mode. But Caffe put the 3rd party libraries into C:\Users\jasju\.caffe\dependencies\libraries_v140_x64_py27_1.1.0\libraries\lib which is impossible to be discovered by CMake. It would be great if this problem can be fixed.

The exact same CMakeLists.txt and CaffeExample.cpp works without a problem on Ubuntu 16.04.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions