зеркало из https://github.com/microsoft/caffe.git
cmake 2.8.7. support
This commit is contained in:
Родитель
c0ae656c0e
Коммит
aea5dd674a
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 2.8.8)
|
||||
cmake_minimum_required(VERSION 2.8.7)
|
||||
|
||||
# ---[ Caffe project
|
||||
project(Caffe C CXX)
|
||||
|
@ -28,8 +28,9 @@ if(UNIX OR APLE)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
if(USE_libstdcpp)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
|
||||
message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")
|
||||
endif()
|
||||
|
||||
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE)
|
||||
|
|
|
@ -38,14 +38,21 @@ function(caffe_generate_export_configs)
|
|||
|
||||
# ---[ Configure build-tree CaffeConfig.cmake file ]---
|
||||
caffe_get_current_includes(Caffe_INCLUDE_DIRS)
|
||||
|
||||
set(Caffe_DEFINITIONS "")
|
||||
if(NOT HAVE_CUDA)
|
||||
set(HAVE_CUDA FALSE)
|
||||
set(Caffe_DEFINITIONS -DCPU_ONLY)
|
||||
list(APPEND Caffe_DEFINITIONS -DCPU_ONLY)
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_CUDNN)
|
||||
set(HAVE_CUDNN FALSE)
|
||||
else()
|
||||
set(Caffe_DEFINITIONS -DUSE_CUDNN)
|
||||
list(APPEND DEFINITIONS -DUSE_CUDNN)
|
||||
endif()
|
||||
|
||||
if(BLAS STREQUAL "MKL" OR BLAS STREQUAL "mkl")
|
||||
list(APPEND Caffe_DEFINITIONS -DUSE_MKL)
|
||||
endif()
|
||||
|
||||
configure_file("cmake/Templates/CaffeConfig.cmake.in" "${CMAKE_BINARY_DIR}/CaffeConfig.cmake" @ONLY)
|
||||
|
|
|
@ -194,6 +194,7 @@ endfunction()
|
|||
################################################################################################
|
||||
|
||||
find_package(CUDA 5.5 QUIET)
|
||||
find_cuda_helper_libs(curand) # cmake 2.8.7 compartibility which doesn't search for curand
|
||||
|
||||
if(NOT CUDA_FOUND)
|
||||
return()
|
||||
|
@ -241,3 +242,13 @@ endif()
|
|||
mark_as_advanced(CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD)
|
||||
mark_as_advanced(CUDA_SDK_ROOT_DIR CUDA_SEPARABLE_COMPILATION)
|
||||
|
||||
# Handle clang/libc++ issue
|
||||
if(APPLE)
|
||||
caffe_detect_darwin_version(OSX_VERSION)
|
||||
|
||||
# OSX 10.9 and higher uses clang/libc++ by default which is incompartible with old CUDA toolkits
|
||||
if(OSX_VERSION VERSION_GREATER 10.8)
|
||||
# enabled by default if and only if CUDA version is less than 7.0
|
||||
caffe_option(USE_libstdcpp "Use libstdc++ instead of libc++" (CUDA_VERSION VERSION_LESS 7.0))
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -68,7 +68,7 @@ message(STATUS "OpenCV found (${OpenCV_CONFIG_PATH})")
|
|||
# ---[ BLAS
|
||||
if(NOT APPLE)
|
||||
set(BLAS "Atlas" CACHE STRING "Selected BLAS library")
|
||||
set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MLK")
|
||||
set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MKL")
|
||||
|
||||
if(BLAS STREQUAL "Atlas" OR BLAS STREQUAL "atlas")
|
||||
find_package(Atlas REQUIRED)
|
||||
|
@ -78,10 +78,11 @@ if(NOT APPLE)
|
|||
find_package(OpenBLAS REQUIRED)
|
||||
include_directories(SYSTEM ${OpenBLAS_INCLUDE_DIR})
|
||||
list(APPEND Caffe_LINKER_LIBS ${OpenBLAS_LIB})
|
||||
elseif(BLAS STREQUAL "MLK" OR BLAS STREQUAL "mkl")
|
||||
elseif(BLAS STREQUAL "MKL" OR BLAS STREQUAL "mkl")
|
||||
find_package(MKL REQUIRED)
|
||||
include_directories(SYSTEM ${MKL_INCLUDE_DIR})
|
||||
list(APPEND Caffe_LINKER_LIBS ${MKL_LIBRARIES})
|
||||
add_definitions(-DUSE_MKL)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
find_package(vecLib REQUIRED)
|
||||
|
|
|
@ -34,8 +34,8 @@ set(CMAKE_MACOSX_RPATH TRUE)
|
|||
|
||||
# ---[ Funny target
|
||||
if(UNIX OR APPLE)
|
||||
add_custom_target(simlink_to_build COMMAND "ln" "-sf" "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/build"
|
||||
COMMENT "Adding simlink: <caffe_root>/build -> ${CMAKE_BINARY_DIR}" )
|
||||
add_custom_target(symlink_to_build COMMAND "ln" "-sf" "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/build"
|
||||
COMMENT "Adding symlink: <caffe_root>/build -> ${CMAKE_BINARY_DIR}" )
|
||||
endif()
|
||||
|
||||
# ---[ Set debug postfix
|
||||
|
|
|
@ -1,113 +1,110 @@
|
|||
# - Find Intel MKL
|
||||
# Find the MKL libraries
|
||||
#
|
||||
# Options:
|
||||
#
|
||||
# MKL_STATAIC : use static linking
|
||||
# MKL_MULTI_THREADED: use multi-threading
|
||||
# MKL_SDL : Single Dynamic Library interface
|
||||
# MKL_USE_SINGLE_DYNAMIC_LIBRARY : use single dynamic library interface
|
||||
# MKL_USE_STATIC_LIBS : use static libraries
|
||||
# MKL_MULTI_THREADED : use multi-threading
|
||||
#
|
||||
# This module defines the following variables:
|
||||
#
|
||||
# MKL_FOUND : True if MKL_INCLUDE_DIR are found
|
||||
# MKL_INCLUDE_DIR : where to find mkl.h, etc.
|
||||
# MKL_INCLUDE_DIRS : set when MKL_INCLUDE_DIR found
|
||||
# MKL_LIBRARIES : the library to link against.
|
||||
# MKL_FOUND : True mkl is found
|
||||
# MKL_INCLUDE_DIR : unclude directory
|
||||
# MKL_LIBRARIES : the libraries to link against.
|
||||
|
||||
|
||||
# ---[ Options
|
||||
caffe_option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" ON)
|
||||
caffe_option(MKL_USE_STATIC_LIBS "Use static libraries" OFF IF NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY)
|
||||
caffe_option(MKL_MULTI_THREADED "Use multi-threading" ON IF NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY)
|
||||
|
||||
# ---[ Root folders
|
||||
set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs")
|
||||
find_path(MKL_ROOT include/mkl.h PATHS $ENV{MKL_ROOT} ${INTEL_ROOT}/mkl
|
||||
DOC "Folder contains MKL")
|
||||
|
||||
# ---[ Find include dir
|
||||
find_path(MKL_INCLUDE_DIR mkl.h PATHS ${MKL_ROOT} PATH_SUFFIXES include)
|
||||
set(__looked_for MKL_INCLUDE_DIR)
|
||||
|
||||
# ---[ Find libraries
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(__path_suffixes lib lib/ia32)
|
||||
else()
|
||||
set(__path_suffixes lib lib/intel64)
|
||||
endif()
|
||||
|
||||
set(__mkl_libs "")
|
||||
if(MKL_USE_SINGLE_DYNAMIC_LIBRARY)
|
||||
list(APPEND __mkl_libs rt)
|
||||
else()
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
if(WIN32)
|
||||
list(APPEND __mkl_libs intel_c)
|
||||
else()
|
||||
list(APPEND __mkl_libs intel gf)
|
||||
endif()
|
||||
else()
|
||||
list(APPEND __mkl_libs intel_lp64 gf_lp64)
|
||||
endif()
|
||||
|
||||
if(MKL_MULTI_THREADED)
|
||||
list(APPEND __mkl_libs intel_thread)
|
||||
else()
|
||||
list(APPEND __mkl_libs sequential)
|
||||
endif()
|
||||
|
||||
list(APPEND __mkl_libs core cdft_core)
|
||||
endif()
|
||||
|
||||
|
||||
foreach (__lib ${__mkl_libs})
|
||||
set(__mkl_lib "mkl_${__lib}")
|
||||
string(TOUPPER ${__mkl_lib} __mkl_lib_upper)
|
||||
|
||||
if(MKL_USE_STATIC_LIBS)
|
||||
set(__mkl_lib "lib${__mkl_lib}.a")
|
||||
endif()
|
||||
|
||||
find_library(${__mkl_lib_upper}_LIBRARY
|
||||
NAMES ${__mkl_lib}
|
||||
PATHS ${MKL_ROOT} "${MKL_INCLUDE_DIR}/.."
|
||||
PATH_SUFFIXES ${__path_suffixes}
|
||||
DOC "The path to Intel(R) MKL ${__mkl_lib} library")
|
||||
mark_as_advanced(${__mkl_lib_upper}_LIBRARY)
|
||||
|
||||
list(APPEND __looked_for ${__mkl_lib_upper}_LIBRARY)
|
||||
list(APPEND MKL_LIBRARIES ${${__mkl_lib_upper}_LIBRARY})
|
||||
endforeach()
|
||||
|
||||
|
||||
if(NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY)
|
||||
if (MKL_USE_STATIC_LIBS)
|
||||
set(__iomp5_libs iomp5 libiomp5mt.lib)
|
||||
else()
|
||||
set(__iomp5_libs iomp5 libiomp5md.lib)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
find_path(INTEL_INCLUDE_DIR omp.h PATHS ${INTEL_ROOT} PATH_SUFFIXES include)
|
||||
list(APPEND __looked_for INTEL_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
find_library(MKL_RTL_LIBRARY ${__iomp5_libs}
|
||||
PATHS ${INTEL_RTL_ROOT} ${INTEL_ROOT}/compiler ${MKL_ROOT}/.. ${MKL_ROOT}/../compiler
|
||||
PATH_SUFFIXES ${__path_suffixes}
|
||||
DOC "Path to Path to OpenMP runtime library")
|
||||
|
||||
list(APPEND __looked_for MKL_RTL_LIBRARY)
|
||||
list(APPEND MKL_LIBRARIES ${MKL_RTL_LIBRARY})
|
||||
endif()
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs")
|
||||
set(MKL_ROOT ${INTEL_ROOT}/mkl CACHE PATH "Folder contains MKL")
|
||||
|
||||
# Find include dir
|
||||
find_path(MKL_INCLUDE_DIR mkl.h
|
||||
PATHS ${MKL_ROOT}/include)
|
||||
|
||||
# Find include directory
|
||||
# There is no include folder under linux
|
||||
if(WIN32)
|
||||
find_path(INTEL_INCLUDE_DIR omp.h
|
||||
PATHS ${INTEL_ROOT}/include)
|
||||
set(MKL_INCLUDE_DIR ${MKL_INCLUDE_DIR} ${INTEL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
# Find libraries
|
||||
|
||||
# Handle suffix
|
||||
set(_MKL_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
|
||||
if(WIN32)
|
||||
if(MKL_STATAIC)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib)
|
||||
else()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES _dll.lib)
|
||||
endif()
|
||||
else()
|
||||
if(MKL_STATAIC)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
||||
else()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# MKL is composed by four layers: Interface, Threading, Computational and RTL
|
||||
|
||||
if(MKL_SDL)
|
||||
find_library(MKL_LIBRARY mkl_rt
|
||||
PATHS ${MKL_ROOT}/lib/ia32/)
|
||||
|
||||
set(MKL_MINIMAL_LIBRARY ${MKL_LIBRARY})
|
||||
else()
|
||||
######################### Interface layer #######################
|
||||
if(WIN32)
|
||||
set(MKL_INTERFACE_LIBNAME mkl_intel_c)
|
||||
else()
|
||||
set(MKL_INTERFACE_LIBNAME mkl_intel)
|
||||
endif()
|
||||
|
||||
find_library(MKL_INTERFACE_LIBRARY ${MKL_INTERFACE_LIBNAME}
|
||||
PATHS ${MKL_ROOT}/lib/ia32/)
|
||||
|
||||
######################## Threading layer ########################
|
||||
if(MKL_MULTI_THREADED)
|
||||
set(MKL_THREADING_LIBNAME mkl_intel_thread)
|
||||
else()
|
||||
set(MKL_THREADING_LIBNAME mkl_sequential)
|
||||
endif()
|
||||
|
||||
find_library(MKL_THREADING_LIBRARY ${MKL_THREADING_LIBNAME}
|
||||
PATHS ${MKL_ROOT}/lib/ia32/)
|
||||
|
||||
####################### Computational layer #####################
|
||||
find_library(MKL_CORE_LIBRARY mkl_core
|
||||
PATHS ${MKL_ROOT}/lib/ia32/)
|
||||
find_library(MKL_FFT_LIBRARY mkl_cdft_core
|
||||
PATHS ${MKL_ROOT}/lib/ia32/)
|
||||
find_library(MKL_SCALAPACK_LIBRARY mkl_scalapack_core
|
||||
PATHS ${MKL_ROOT}/lib/ia32/)
|
||||
|
||||
############################ RTL layer ##########################
|
||||
if(WIN32)
|
||||
set(MKL_RTL_LIBNAME libiomp5md)
|
||||
else()
|
||||
set(MKL_RTL_LIBNAME libiomp5)
|
||||
endif()
|
||||
find_library(MKL_RTL_LIBRARY ${MKL_RTL_LIBNAME}
|
||||
PATHS ${INTEL_RTL_ROOT}/lib)
|
||||
|
||||
set(MKL_LIBRARY ${MKL_INTERFACE_LIBRARY} ${MKL_THREADING_LIBRARY} ${MKL_CORE_LIBRARY} ${MKL_FFT_LIBRARY} ${MKL_SCALAPACK_LIBRARY} ${MKL_RTL_LIBRARY})
|
||||
set(MKL_MINIMAL_LIBRARY ${MKL_INTERFACE_LIBRARY} ${MKL_THREADING_LIBRARY} ${MKL_CORE_LIBRARY} ${MKL_RTL_LIBRARY})
|
||||
endif()
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_MKL_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
|
||||
find_package_handle_standard_args(MKL DEFAULT_MSG
|
||||
MKL_INCLUDE_DIR MKL_LIBRARY MKL_MINIMAL_LIBRARY)
|
||||
find_package_handle_standard_args(MKL DEFAULT_MSG ${__looked_for})
|
||||
|
||||
if(MKL_FOUND)
|
||||
set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR})
|
||||
set(MKL_LIBRARIES ${MKL_LIBRARY})
|
||||
set(MKL_MINIMAL_LIBRARIES ${MKL_LIBRARY})
|
||||
message(STATUS "Found MKL (include: ${MKL_INCLUDE_DIR}, lib: ${MKL_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
caffe_clear_vars(__looked_for __mkl_libs __path_suffixes __lib_suffix __iomp5_libs)
|
||||
|
|
|
@ -140,8 +140,7 @@ function(caffe_configure_testdatafile file)
|
|||
set(result "")
|
||||
foreach(line ${__lines})
|
||||
set(result "${result}${CMAKE_SOURCE_DIR}/${line}\n")
|
||||
endforeach()
|
||||
dmsg(${result})
|
||||
endforeach()
|
||||
file(WRITE ${file}.gen.cmake ${result})
|
||||
endfunction()
|
||||
|
||||
|
|
|
@ -363,3 +363,19 @@ function(caffe_parse_linker_libs Caffe_LINKER_LIBS_variable folders_var flags_va
|
|||
set(${flags_var} ${libflags} PARENT_SCOPE)
|
||||
set(${frameworks_var} ${__framework} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Helper function to detect Darwin version, i.e. 10.8, 10.9, 10.10, ....
|
||||
# Usage:
|
||||
# caffe_detect_darwin_version(<version_variable>)
|
||||
function(caffe_detect_darwin_version output_var)
|
||||
if(APPLE)
|
||||
execute_process(COMMAND /usr/bin/sw_vers -productVersion
|
||||
RESULT_VARIABLE __sw_vers OUTPUT_VARIABLE __sw_vers_out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
set(${output_var} ${__sw_vers_out} PARENT_SCOPE)
|
||||
else()
|
||||
set(${output_var} "" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
|
@ -28,7 +28,7 @@ function(gather_readmes_as_prebuild_cmd target gathered_dir root)
|
|||
add_custom_command(TARGET ${target} PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${new_folder}
|
||||
COMMAND ln -sf ${root}/${file} ${new_filename}
|
||||
COMMENT "Creating simlink ${new_filename} -> ${root}/${file}"
|
||||
COMMENT "Creating symlink ${new_filename} -> ${root}/${file}"
|
||||
WORKING_DIRECTORY ${root} VERBATIM)
|
||||
endif()
|
||||
endforeach()
|
||||
|
@ -94,11 +94,11 @@ if(NOT IS_ABSOLUTE ${output_dir})
|
|||
get_filename_component(output_dir ${output_dir} ABSOLUTE)
|
||||
endif()
|
||||
|
||||
# creates simlink in docs subfolder to code documentation built by doxygen
|
||||
# creates symlink in docs subfolder to code documentation built by doxygen
|
||||
add_custom_command(TARGET docs POST_BUILD VERBATIM
|
||||
COMMAND ln -sfn "${output_dir}/html" doxygen
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs
|
||||
COMMENT "Creating simlink ${CMAKE_SOURCE_DIR}/docs/doxygen -> ${output_dir}/html")
|
||||
COMMENT "Creating symlink ${CMAKE_SOURCE_DIR}/docs/doxygen -> ${output_dir}/html")
|
||||
|
||||
# for quick launch of jekyll
|
||||
add_custom_target(jekyll COMMAND jekyll serve -w -s . -d _site --port=4000
|
||||
|
|
|
@ -35,7 +35,7 @@ file(GLOB Matlab_srcs caffe/matcaffe.cpp)
|
|||
set(Matlab_caffe_mex ${CMAKE_SOURCE_DIR}/matlab/caffe/caffe.mex)
|
||||
|
||||
caffe_get_current_cflags(cflags)
|
||||
caffe_parse_linker_libs(Caffe_LINKER_LIBS folders libflags macos_framewoks)
|
||||
caffe_parse_linker_libs(Caffe_LINKER_LIBS folders libflags macos_frameworks)
|
||||
set(folders $<TARGET_LINKER_FILE_DIR:caffe> ${folders})
|
||||
|
||||
# prepare linker flag lists
|
||||
|
|
|
@ -12,10 +12,13 @@ set_target_properties(pycaffe PROPERTIES PREFIX "" OUTPUT_NAME "_caffe")
|
|||
caffe_default_properties(pycaffe)
|
||||
|
||||
if(UNIX OR APPLE)
|
||||
set(__linkname "${CMAKE_SOURCE_DIR}/python/_caffe.so")
|
||||
set(__linkname "${CMAKE_SOURCE_DIR}/python/caffe/_caffe.so")
|
||||
add_custom_command(TARGET pycaffe POST_BUILD
|
||||
COMMAND ln -sf $<TARGET_LINKER_FILE:caffe> "${CMAKE_SOURCE_DIR}/python/_caffe.so"
|
||||
COMMENT "Creating simlink ${__linkname} -> ${CMAKE_BINARY_DIR}/lib/_caffe${CAffe_POSTFIX}.so")
|
||||
COMMAND ln -sf $<TARGET_LINKER_FILE:pycaffe> "${__linkname}"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/python/caffe/proto
|
||||
COMMAND touch ${CMAKE_SOURCE_DIR}/python/caffe/proto/__init__.py
|
||||
COMMAND cp ${proto_gen_folder}/*.py ${CMAKE_SOURCE_DIR}/python/caffe/proto/
|
||||
COMMENT "Creating symlink ${__linkname} -> ${CMAKE_BINARY_DIR}/lib/_caffe${CAffe_POSTFIX}.so")
|
||||
endif()
|
||||
|
||||
# ---[ Install
|
||||
|
|
Загрузка…
Ссылка в новой задаче