# #caffe - Neural network trainer # #The mess below is required because OpenCV wants to be able to install several #binary versions side-by-side under the same install prefix when working with #Visual Studio. Just a pain when building from the command line where we will #NOT be switching interactively between different versions of OpenCV. If we #use an IDE and want to switch between schisms, we can rely on multiple #prefixes built from the same source code and simply switch between workspaces #that each use a different prefix (thereby having one workspace per schism). if(MSVC) if(CMAKE_CL_64) set(OpenCV_ARCH x64) else() set(OpenCV_ARCH x86) endif() if(MSVC_VERSION EQUAL 1400) set(OpenCV_RUNTIME vc8) elseif(MSVC_VERSION EQUAL 1500) set(OpenCV_RUNTIME vc9) elseif(MSVC_VERSION EQUAL 1600) set(OpenCV_RUNTIME vc10) elseif(MSVC_VERSION EQUAL 1700) set(OpenCV_RUNTIME vc11) elseif(MSVC_VERSION EQUAL 1800) set(OpenCV_RUNTIME vc12) elseif(MSVC_VERSION EQUAL 1900) set(OpenCV_RUNTIME vc14) elseif(MSVC_VERSION EQUAL 1910 OR MSVC_VERSION EQUAL 1911) set(OpenCV_RUNTIME vc15) else () message (FATAL_ERROR "Unknown Visual Studio version for OpenCV_RUNTIME. MSVC_VERSION=\"" ${MSVC_VERSION} "\"") endif() #In line with the OSD design guidelines, use a static OpenCV library. #Would be "lib" if using a dynamic OpenCV library. set (OpenCV_LIB_SUBDIR staticlib) #Directory relative to the prefix where the OpenCV cmake config file is #stored. We must point out a single one due to the fact that several #compiled versions of OpenCV may be installed under the same prefix. We #would have liked OpenCV to rather have used one prefix for each "schism", #but then developers would not be able to switch interactively between #x64/x86/static/dynamic etc inside the MSVC IDE. We are concerned with #building a prefix per schism. We believe that in an IDE setting, switching #between schims (x64/x86/dynamic/static) should rather be done by opening a #different IDE workspace which uses a different prefix. Try telling that to #the OpenCV developers who have been tinkering this for a log time and want #to switch between schisms from inside the IDE. Just give them what they #want now, so we will not have to bother with their design choices later. set (OpenCV_CMAKE_CONFIG_SUBDIR lib/cmake/opencv/${OpenCV_ARCH}/${OpenCV_RUNTIME}/${OpenCV_LIB_SUBDIR}) else () #There are no known schisms on other platforms than MSVC. #Other platforms have a much longer tradition for using prefixes in the #spirit of the Filesystem Hierachy Standard (bin/lib/include layout). set (OpenCV_CMAKE_CONFIG_SUBDIR .) endif() ExternalProject_Add ( caffe PREFIX ${CMAKE_INSTALL_PREFIX} URL https://github.com/BVLC/caffe/archive/28ca814513b57fd7a10829ec65752892fb537e87.zip URL_MD5 f87799cbab022149d5ffa8990eea427f PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/patch . CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS:BOOL=OFF -DBoost_USE_STATIC_LIBS:BOOL=ON -DOpenCV_DIR:PATH=/${OpenCV_CMAKE_CONFIG_SUBDIR} -DBUILD_python:BOOL=OFF -DBUILD_matlab:BOOL=OFF -DBUILD_docs:BOOL=OFF -DBLAS:STRING=Open -DUSE_OPENCV:BOOL=ON -DUSE_LEVELDB:BOOL=ON -DUSE_LMDB:BOOL=ON -DCPU_ONLY:BOOL=ON -DCOPY_PREREQUISITES:BOOL=OFF -DINSTALL_PREREQUISITES:BOOL=OFF DEPENDS zlib gflags glog hdf5 boost leveldb lmdb opencv protobuf openblas snappy )