mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Removing extraneous cmake files
Leftover from Caffe cmake build system
This commit is contained in:
@ -1,119 +0,0 @@
|
||||
|
||||
################################################################################################
|
||||
# Helper function to fetch caffe includes which will be passed to dependent projects
|
||||
# Usage:
|
||||
# caffe_get_current_includes(<includes_list_variable>)
|
||||
function(caffe_get_current_includes includes_variable)
|
||||
get_property(current_includes DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
|
||||
caffe_convert_absolute_paths(current_includes)
|
||||
|
||||
# remove at most one ${PROJECT_BINARY_DIR} include added for caffe_config.h
|
||||
list(FIND current_includes ${PROJECT_BINARY_DIR} __index)
|
||||
list(REMOVE_AT current_includes ${__index})
|
||||
|
||||
# removing numpy includes (since not required for client libs)
|
||||
set(__toremove "")
|
||||
foreach(__i ${current_includes})
|
||||
if(${__i} MATCHES "python")
|
||||
list(APPEND __toremove ${__i})
|
||||
endif()
|
||||
endforeach()
|
||||
if(__toremove)
|
||||
list(REMOVE_ITEM current_includes ${__toremove})
|
||||
endif()
|
||||
|
||||
caffe_list_unique(current_includes)
|
||||
set(${includes_variable} ${current_includes} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Helper function to get all list items that begin with given prefix
|
||||
# Usage:
|
||||
# caffe_get_items_with_prefix(<prefix> <list_variable> <output_variable>)
|
||||
function(caffe_get_items_with_prefix prefix list_variable output_variable)
|
||||
set(__result "")
|
||||
foreach(__e ${${list_variable}})
|
||||
if(__e MATCHES "^${prefix}.*")
|
||||
list(APPEND __result ${__e})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${output_variable} ${__result} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Function for generation Caffe build- and install- tree export config files
|
||||
# Usage:
|
||||
# caffe_generate_export_configs()
|
||||
function(caffe_generate_export_configs)
|
||||
set(install_cmake_suffix "share/Caffe")
|
||||
|
||||
# ---[ Configure build-tree CaffeConfig.cmake file ]---
|
||||
caffe_get_current_includes(Caffe_INCLUDE_DIRS)
|
||||
|
||||
set(Caffe_DEFINITIONS "")
|
||||
if(NOT HAVE_CUDA)
|
||||
set(HAVE_CUDA FALSE)
|
||||
list(APPEND Caffe_DEFINITIONS -DCPU_ONLY)
|
||||
endif()
|
||||
|
||||
if(USE_OPENCV)
|
||||
list(APPEND Caffe_DEFINITIONS -DUSE_OPENCV)
|
||||
endif()
|
||||
|
||||
if(USE_LMDB)
|
||||
list(APPEND Caffe_DEFINITIONS -DUSE_LMDB)
|
||||
if (ALLOW_LMDB_NOLOCK)
|
||||
list(APPEND Caffe_DEFINITIONS -DALLOW_LMDB_NOLOCK)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_LEVELDB)
|
||||
list(APPEND Caffe_DEFINITIONS -DUSE_LEVELDB)
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_CUDNN)
|
||||
set(HAVE_CUDNN FALSE)
|
||||
else()
|
||||
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" "${PROJECT_BINARY_DIR}/CaffeConfig.cmake" @ONLY)
|
||||
|
||||
# Add targets to the build-tree export set
|
||||
export(TARGETS caffe proto FILE "${PROJECT_BINARY_DIR}/CaffeTargets.cmake")
|
||||
export(PACKAGE Caffe)
|
||||
|
||||
# ---[ Configure install-tree CaffeConfig.cmake file ]---
|
||||
|
||||
# remove source and build dir includes
|
||||
caffe_get_items_with_prefix(${PROJECT_SOURCE_DIR} Caffe_INCLUDE_DIRS __insource)
|
||||
caffe_get_items_with_prefix(${PROJECT_BINARY_DIR} Caffe_INCLUDE_DIRS __inbinary)
|
||||
list(REMOVE_ITEM Caffe_INCLUDE_DIRS ${__insource} ${__inbinary})
|
||||
|
||||
# add `install` include folder
|
||||
set(lines
|
||||
"get_filename_component(__caffe_include \"\${Caffe_CMAKE_DIR}/../../include\" ABSOLUTE)\n"
|
||||
"list(APPEND Caffe_INCLUDE_DIRS \${__caffe_include})\n"
|
||||
"unset(__caffe_include)\n")
|
||||
string(REPLACE ";" "" Caffe_INSTALL_INCLUDE_DIR_APPEND_COMMAND ${lines})
|
||||
|
||||
configure_file("cmake/Templates/CaffeConfig.cmake.in" "${PROJECT_BINARY_DIR}/cmake/CaffeConfig.cmake" @ONLY)
|
||||
|
||||
# Install the CaffeConfig.cmake and export set to use with install-tree
|
||||
install(FILES "${PROJECT_BINARY_DIR}/cmake/CaffeConfig.cmake" DESTINATION ${install_cmake_suffix})
|
||||
install(EXPORT CaffeTargets DESTINATION ${install_cmake_suffix})
|
||||
|
||||
# ---[ Configure and install version file ]---
|
||||
|
||||
# TODO: Lines below are commented because Caffe does't declare its version in headers.
|
||||
# When the declarations are added, modify `caffe_extract_caffe_version()` macro and uncomment
|
||||
|
||||
# configure_file(cmake/Templates/CaffeConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/CaffeConfigVersion.cmake" @ONLY)
|
||||
# install(FILES "${PROJECT_BINARY_DIR}/CaffeConfigVersion.cmake" DESTINATION ${install_cmake_suffix})
|
||||
endfunction()
|
||||
|
||||
|
@ -1,52 +0,0 @@
|
||||
# ---[ Configuration types
|
||||
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Possible configurations" FORCE)
|
||||
mark_as_advanced(CMAKE_CONFIGURATION_TYPES)
|
||||
|
||||
if(DEFINED CMAKE_BUILD_TYPE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})
|
||||
endif()
|
||||
|
||||
# --[ If user doesn't specify build type then assume release
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_COMPILER_IS_CLANGXX TRUE)
|
||||
endif()
|
||||
|
||||
# ---[ Solution folders
|
||||
caffe_option(USE_PROJECT_FOLDERS "IDE Solution folders" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) )
|
||||
|
||||
if(USE_PROJECT_FOLDERS)
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
|
||||
endif()
|
||||
|
||||
# ---[ Install options
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE PATH "Default install path" FORCE)
|
||||
endif()
|
||||
|
||||
# ---[ RPATH settings
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOLEAN "Use link paths for shared library rpath")
|
||||
set(CMAKE_MACOSX_RPATH TRUE)
|
||||
|
||||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/lib __is_systtem_dir)
|
||||
if(${__is_systtem_dir} STREQUAL -1)
|
||||
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
endif()
|
||||
|
||||
# ---[ Funny target
|
||||
if(UNIX OR APPLE)
|
||||
add_custom_target(symlink_to_build COMMAND "ln" "-sf" "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/build"
|
||||
COMMENT "Adding symlink: <caffe_root>/build -> ${PROJECT_BINARY_DIR}" )
|
||||
endif()
|
||||
|
||||
# ---[ Set debug postfix
|
||||
set(Caffe_DEBUG_POSTFIX "-d")
|
||||
|
||||
set(Caffe_POSTFIX "")
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
set(Caffe_POSTFIX ${Caffe_DEBUG_POSTFIX})
|
||||
endif()
|
@ -1,177 +0,0 @@
|
||||
################################################################################################
|
||||
# Caffe status report function.
|
||||
# Automatically align right column and selects text based on condition.
|
||||
# Usage:
|
||||
# caffe_status(<text>)
|
||||
# caffe_status(<heading> <value1> [<value2> ...])
|
||||
# caffe_status(<heading> <condition> THEN <text for TRUE> ELSE <text for FALSE> )
|
||||
function(caffe_status text)
|
||||
set(status_cond)
|
||||
set(status_then)
|
||||
set(status_else)
|
||||
|
||||
set(status_current_name "cond")
|
||||
foreach(arg ${ARGN})
|
||||
if(arg STREQUAL "THEN")
|
||||
set(status_current_name "then")
|
||||
elseif(arg STREQUAL "ELSE")
|
||||
set(status_current_name "else")
|
||||
else()
|
||||
list(APPEND status_${status_current_name} ${arg})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(DEFINED status_cond)
|
||||
set(status_placeholder_length 23)
|
||||
string(RANDOM LENGTH ${status_placeholder_length} ALPHABET " " status_placeholder)
|
||||
string(LENGTH "${text}" status_text_length)
|
||||
if(status_text_length LESS status_placeholder_length)
|
||||
string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text)
|
||||
elseif(DEFINED status_then OR DEFINED status_else)
|
||||
message(STATUS "${text}")
|
||||
set(status_text "${status_placeholder}")
|
||||
else()
|
||||
set(status_text "${text}")
|
||||
endif()
|
||||
|
||||
if(DEFINED status_then OR DEFINED status_else)
|
||||
if(${status_cond})
|
||||
string(REPLACE ";" " " status_then "${status_then}")
|
||||
string(REGEX REPLACE "^[ \t]+" "" status_then "${status_then}")
|
||||
message(STATUS "${status_text} ${status_then}")
|
||||
else()
|
||||
string(REPLACE ";" " " status_else "${status_else}")
|
||||
string(REGEX REPLACE "^[ \t]+" "" status_else "${status_else}")
|
||||
message(STATUS "${status_text} ${status_else}")
|
||||
endif()
|
||||
else()
|
||||
string(REPLACE ";" " " status_cond "${status_cond}")
|
||||
string(REGEX REPLACE "^[ \t]+" "" status_cond "${status_cond}")
|
||||
message(STATUS "${status_text} ${status_cond}")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "${text}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
################################################################################################
|
||||
# Function for fetching Caffe version from git and headers
|
||||
# Usage:
|
||||
# caffe_extract_caffe_version()
|
||||
function(caffe_extract_caffe_version)
|
||||
set(Caffe_GIT_VERSION "unknown")
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE Caffe_GIT_VERSION
|
||||
RESULT_VARIABLE __git_result)
|
||||
if(NOT ${__git_result} EQUAL 0)
|
||||
set(Caffe_GIT_VERSION "unknown")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(Caffe_GIT_VERSION ${Caffe_GIT_VERSION} PARENT_SCOPE)
|
||||
set(Caffe_VERSION "<TODO> (Caffe doesn't declare its version in headers)" PARENT_SCOPE)
|
||||
|
||||
# caffe_parse_header(${Caffe_INCLUDE_DIR}/caffe/version.hpp Caffe_VERSION_LINES CAFFE_MAJOR CAFFE_MINOR CAFFE_PATCH)
|
||||
# set(Caffe_VERSION "${CAFFE_MAJOR}.${CAFFE_MINOR}.${CAFFE_PATCH}" PARENT_SCOPE)
|
||||
|
||||
# or for #define Caffe_VERSION "x.x.x"
|
||||
# caffe_parse_header_single_define(Caffe ${Caffe_INCLUDE_DIR}/caffe/version.hpp Caffe_VERSION)
|
||||
# set(Caffe_VERSION ${Caffe_VERSION_STRING} PARENT_SCOPE)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
################################################################################################
|
||||
# Prints accumulated caffe configuration summary
|
||||
# Usage:
|
||||
# caffe_print_configuration_summary()
|
||||
|
||||
function(caffe_print_configuration_summary)
|
||||
caffe_extract_caffe_version()
|
||||
set(Caffe_VERSION ${Caffe_VERSION} PARENT_SCOPE)
|
||||
|
||||
caffe_merge_flag_lists(__flags_rel CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS)
|
||||
caffe_merge_flag_lists(__flags_deb CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS)
|
||||
|
||||
caffe_status("")
|
||||
caffe_status("******************* Caffe Configuration Summary *******************")
|
||||
caffe_status("General:")
|
||||
caffe_status(" Version : ${CAFFE_TARGET_VERSION}")
|
||||
caffe_status(" Git : ${Caffe_GIT_VERSION}")
|
||||
caffe_status(" System : ${CMAKE_SYSTEM_NAME}")
|
||||
caffe_status(" C++ compiler : ${CMAKE_CXX_COMPILER}")
|
||||
caffe_status(" Release CXX flags : ${__flags_rel}")
|
||||
caffe_status(" Debug CXX flags : ${__flags_deb}")
|
||||
caffe_status(" Build type : ${CMAKE_BUILD_TYPE}")
|
||||
caffe_status("")
|
||||
caffe_status(" BUILD_SHARED_LIBS : ${BUILD_SHARED_LIBS}")
|
||||
caffe_status(" BUILD_python : ${BUILD_python}")
|
||||
caffe_status(" BUILD_matlab : ${BUILD_matlab}")
|
||||
caffe_status(" BUILD_docs : ${BUILD_docs}")
|
||||
caffe_status(" CPU_ONLY : ${CPU_ONLY}")
|
||||
caffe_status(" USE_OPENCV : ${USE_OPENCV}")
|
||||
caffe_status(" USE_LEVELDB : ${USE_LEVELDB}")
|
||||
caffe_status(" USE_LMDB : ${USE_LMDB}")
|
||||
caffe_status(" ALLOW_LMDB_NOLOCK : ${ALLOW_LMDB_NOLOCK}")
|
||||
caffe_status("")
|
||||
caffe_status("Dependencies:")
|
||||
caffe_status(" BLAS : " APPLE THEN "Yes (vecLib)" ELSE "Yes (${BLAS})")
|
||||
caffe_status(" Boost : Yes (ver. ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION})")
|
||||
caffe_status(" glog : Yes")
|
||||
caffe_status(" gflags : Yes")
|
||||
caffe_status(" protobuf : " PROTOBUF_FOUND THEN "Yes (ver. ${PROTOBUF_VERSION})" ELSE "No" )
|
||||
if(USE_LMDB)
|
||||
caffe_status(" lmdb : " LMDB_FOUND THEN "Yes (ver. ${LMDB_VERSION})" ELSE "No")
|
||||
endif()
|
||||
if(USE_LEVELDB)
|
||||
caffe_status(" LevelDB : " LEVELDB_FOUND THEN "Yes (ver. ${LEVELDB_VERSION})" ELSE "No")
|
||||
caffe_status(" Snappy : " SNAPPY_FOUND THEN "Yes (ver. ${Snappy_VERSION})" ELSE "No" )
|
||||
endif()
|
||||
if(USE_OPENCV)
|
||||
caffe_status(" OpenCV : Yes (ver. ${OpenCV_VERSION})")
|
||||
endif()
|
||||
caffe_status(" CUDA : " HAVE_CUDA THEN "Yes (ver. ${CUDA_VERSION})" ELSE "No" )
|
||||
caffe_status("")
|
||||
if(HAVE_CUDA)
|
||||
caffe_status("NVIDIA CUDA:")
|
||||
caffe_status(" Target GPU(s) : ${CUDA_ARCH_NAME}" )
|
||||
caffe_status(" GPU arch(s) : ${NVCC_FLAGS_EXTRA_readable}")
|
||||
if(USE_CUDNN)
|
||||
caffe_status(" cuDNN : " HAVE_CUDNN THEN "Yes (ver. ${CUDNN_VERSION})" ELSE "Not found")
|
||||
else()
|
||||
caffe_status(" cuDNN : Disabled")
|
||||
endif()
|
||||
caffe_status("")
|
||||
endif()
|
||||
if(HAVE_PYTHON)
|
||||
caffe_status("Python:")
|
||||
caffe_status(" Interpreter :" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver. ${PYTHON_VERSION_STRING})" ELSE "No")
|
||||
caffe_status(" Libraries :" PYTHONLIBS_FOUND THEN "${PYTHON_LIBRARIES} (ver ${PYTHONLIBS_VERSION_STRING})" ELSE "No")
|
||||
caffe_status(" NumPy :" NUMPY_FOUND THEN "${NUMPY_INCLUDE_DIR} (ver ${NUMPY_VERSION})" ELSE "No")
|
||||
caffe_status("")
|
||||
endif()
|
||||
if(BUILD_matlab)
|
||||
caffe_status("Matlab:")
|
||||
caffe_status(" Matlab :" HAVE_MATLAB THEN "Yes (${Matlab_mex}, ${Matlab_mexext}" ELSE "No")
|
||||
caffe_status(" Octave :" Octave_compiler THEN "Yes (${Octave_compiler})" ELSE "No")
|
||||
if(HAVE_MATLAB AND Octave_compiler)
|
||||
caffe_status(" Build mex using : ${Matlab_build_mex_using}")
|
||||
endif()
|
||||
caffe_status("")
|
||||
endif()
|
||||
if(BUILD_docs)
|
||||
caffe_status("Documentaion:")
|
||||
caffe_status(" Doxygen :" DOXYGEN_FOUND THEN "${DOXYGEN_EXECUTABLE} (${DOXYGEN_VERSION})" ELSE "No")
|
||||
caffe_status(" config_file : ${DOXYGEN_config_file}")
|
||||
|
||||
caffe_status("")
|
||||
endif()
|
||||
caffe_status("Install:")
|
||||
caffe_status(" Install path : ${CMAKE_INSTALL_PREFIX}")
|
||||
caffe_status("")
|
||||
endfunction()
|
@ -1,174 +0,0 @@
|
||||
################################################################################################
|
||||
# Defines global Caffe_LINK flag, This flag is required to prevent linker from excluding
|
||||
# some objects which are not addressed directly but are registered via static constructors
|
||||
macro(caffe_set_caffe_link)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(Caffe_LINK caffe)
|
||||
else()
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(Caffe_LINK -Wl,-force_load caffe)
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(Caffe_LINK -Wl,--whole-archive caffe -Wl,--no-whole-archive)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
################################################################################################
|
||||
# Convenient command to setup source group for IDEs that support this feature (VS, XCode)
|
||||
# Usage:
|
||||
# caffe_source_group(<group> GLOB[_RECURSE] <globbing_expression>)
|
||||
function(caffe_source_group group)
|
||||
cmake_parse_arguments(CAFFE_SOURCE_GROUP "" "" "GLOB;GLOB_RECURSE" ${ARGN})
|
||||
if(CAFFE_SOURCE_GROUP_GLOB)
|
||||
file(GLOB srcs1 ${CAFFE_SOURCE_GROUP_GLOB})
|
||||
source_group(${group} FILES ${srcs1})
|
||||
endif()
|
||||
|
||||
if(CAFFE_SOURCE_GROUP_GLOB_RECURSE)
|
||||
file(GLOB_RECURSE srcs2 ${CAFFE_SOURCE_GROUP_GLOB_RECURSE})
|
||||
source_group(${group} FILES ${srcs2})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Collecting sources from globbing and appending to output list variable
|
||||
# Usage:
|
||||
# caffe_collect_sources(<output_variable> GLOB[_RECURSE] <globbing_expression>)
|
||||
function(caffe_collect_sources variable)
|
||||
cmake_parse_arguments(CAFFE_COLLECT_SOURCES "" "" "GLOB;GLOB_RECURSE" ${ARGN})
|
||||
if(CAFFE_COLLECT_SOURCES_GLOB)
|
||||
file(GLOB srcs1 ${CAFFE_COLLECT_SOURCES_GLOB})
|
||||
set(${variable} ${variable} ${srcs1})
|
||||
endif()
|
||||
|
||||
if(CAFFE_COLLECT_SOURCES_GLOB_RECURSE)
|
||||
file(GLOB_RECURSE srcs2 ${CAFFE_COLLECT_SOURCES_GLOB_RECURSE})
|
||||
set(${variable} ${variable} ${srcs2})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Short command getting caffe sources (assuming standard Caffe code tree)
|
||||
# Usage:
|
||||
# caffe_pickup_caffe_sources(<root>)
|
||||
function(caffe_pickup_caffe_sources root)
|
||||
# put all files in source groups (visible as subfolder in many IDEs)
|
||||
caffe_source_group("Include" GLOB "${root}/include/caffe/*.h*")
|
||||
caffe_source_group("Include\\Util" GLOB "${root}/include/caffe/util/*.h*")
|
||||
caffe_source_group("Include" GLOB "${PROJECT_BINARY_DIR}/caffe_config.h*")
|
||||
caffe_source_group("Source" GLOB "${root}/src/caffe/*.cpp")
|
||||
caffe_source_group("Source\\Util" GLOB "${root}/src/caffe/util/*.cpp")
|
||||
caffe_source_group("Source\\Layers" GLOB "${root}/src/caffe/layers/*.cpp")
|
||||
caffe_source_group("Source\\Cuda" GLOB "${root}/src/caffe/layers/*.cu")
|
||||
caffe_source_group("Source\\Cuda" GLOB "${root}/src/caffe/util/*.cu")
|
||||
caffe_source_group("Source\\Proto" GLOB "${root}/src/caffe/proto/*.proto")
|
||||
|
||||
# source groups for test target
|
||||
caffe_source_group("Include" GLOB "${root}/include/caffe/test/test_*.h*")
|
||||
caffe_source_group("Source" GLOB "${root}/src/caffe/test/test_*.cpp")
|
||||
caffe_source_group("Source\\Cuda" GLOB "${root}/src/caffe/test/test_*.cu")
|
||||
|
||||
# collect files
|
||||
file(GLOB test_hdrs ${root}/include/caffe/test/test_*.h*)
|
||||
file(GLOB test_srcs ${root}/src/caffe/test/test_*.cpp)
|
||||
file(GLOB_RECURSE hdrs ${root}/include/caffe/*.h*)
|
||||
file(GLOB_RECURSE srcs ${root}/src/caffe/*.cpp)
|
||||
list(REMOVE_ITEM hdrs ${test_hdrs})
|
||||
list(REMOVE_ITEM srcs ${test_srcs})
|
||||
|
||||
# adding headers to make the visible in some IDEs (Qt, VS, Xcode)
|
||||
list(APPEND srcs ${hdrs} ${PROJECT_BINARY_DIR}/caffe_config.h)
|
||||
list(APPEND test_srcs ${test_hdrs})
|
||||
|
||||
# collect cuda files
|
||||
file(GLOB test_cuda ${root}/src/caffe/test/test_*.cu)
|
||||
file(GLOB_RECURSE cuda ${root}/src/caffe/*.cu)
|
||||
list(REMOVE_ITEM cuda ${test_cuda})
|
||||
|
||||
# add proto to make them editable in IDEs too
|
||||
file(GLOB_RECURSE proto_files ${root}/src/caffe/*.proto)
|
||||
list(APPEND srcs ${proto_files})
|
||||
|
||||
# convet to absolute paths
|
||||
caffe_convert_absolute_paths(srcs)
|
||||
caffe_convert_absolute_paths(cuda)
|
||||
caffe_convert_absolute_paths(test_srcs)
|
||||
caffe_convert_absolute_paths(test_cuda)
|
||||
|
||||
# propogate to parent scope
|
||||
set(srcs ${srcs} PARENT_SCOPE)
|
||||
set(cuda ${cuda} PARENT_SCOPE)
|
||||
set(test_srcs ${test_srcs} PARENT_SCOPE)
|
||||
set(test_cuda ${test_cuda} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Short command for setting defeault target properties
|
||||
# Usage:
|
||||
# caffe_default_properties(<target>)
|
||||
function(caffe_default_properties target)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
DEBUG_POSTFIX ${Caffe_DEBUG_POSTFIX}
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
# make sure we build all external depepdencies first
|
||||
if (DEFINED external_project_dependencies)
|
||||
add_dependencies(${target} ${external_project_dependencies})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Short command for setting runtime directory for build target
|
||||
# Usage:
|
||||
# caffe_set_runtime_directory(<target> <dir>)
|
||||
function(caffe_set_runtime_directory target dir)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${dir}")
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Short command for setting solution folder property for target
|
||||
# Usage:
|
||||
# caffe_set_solution_folder(<target> <folder>)
|
||||
function(caffe_set_solution_folder target folder)
|
||||
if(USE_PROJECT_FOLDERS)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "${folder}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Reads lines from input file, prepends source directory to each line and writes to output file
|
||||
# Usage:
|
||||
# caffe_configure_testdatafile(<testdatafile>)
|
||||
function(caffe_configure_testdatafile file)
|
||||
file(STRINGS ${file} __lines)
|
||||
set(result "")
|
||||
foreach(line ${__lines})
|
||||
set(result "${result}${PROJECT_SOURCE_DIR}/${line}\n")
|
||||
endforeach()
|
||||
file(WRITE ${file}.gen.cmake ${result})
|
||||
endfunction()
|
||||
|
||||
################################################################################################
|
||||
# Filter out all files that are not included in selected list
|
||||
# Usage:
|
||||
# caffe_leave_only_selected_tests(<filelist_variable> <selected_list>)
|
||||
function(caffe_leave_only_selected_tests file_list)
|
||||
if(NOT ARGN)
|
||||
return() # blank list means leave all
|
||||
endif()
|
||||
string(REPLACE "," ";" __selected ${ARGN})
|
||||
list(APPEND __selected caffe_main)
|
||||
|
||||
set(result "")
|
||||
foreach(f ${${file_list}})
|
||||
get_filename_component(name ${f} NAME_WE)
|
||||
string(REGEX REPLACE "^test_" "" name ${name})
|
||||
list(FIND __selected ${name} __index)
|
||||
if(NOT __index EQUAL -1)
|
||||
list(APPEND result ${f})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${file_list} ${result} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
@ -1,60 +0,0 @@
|
||||
# Config file for the Caffe package.
|
||||
#
|
||||
# Note:
|
||||
# Caffe and this config file depends on opencv,
|
||||
# so put `find_package(OpenCV)` before searching Caffe
|
||||
# via `find_package(Caffe)`. All other lib/includes
|
||||
# dependencies are hard coded in the file
|
||||
#
|
||||
# After successful configuration the following variables
|
||||
# will be defined:
|
||||
#
|
||||
# Caffe_INCLUDE_DIRS - Caffe include directories
|
||||
# Caffe_LIBRARIES - libraries to link against
|
||||
# Caffe_DEFINITIONS - a list of definitions to pass to compiler
|
||||
#
|
||||
# Caffe_HAVE_CUDA - signals about CUDA support
|
||||
# Caffe_HAVE_CUDNN - signals about cuDNN support
|
||||
|
||||
|
||||
# OpenCV dependency (optional)
|
||||
|
||||
if(@USE_OPENCV@)
|
||||
if(NOT OpenCV_FOUND)
|
||||
set(Caffe_OpenCV_CONFIG_PATH "@OpenCV_CONFIG_PATH@")
|
||||
if(Caffe_OpenCV_CONFIG_PATH)
|
||||
get_filename_component(Caffe_OpenCV_CONFIG_PATH ${Caffe_OpenCV_CONFIG_PATH} ABSOLUTE)
|
||||
|
||||
if(EXISTS ${Caffe_OpenCV_CONFIG_PATH} AND NOT TARGET opencv_core)
|
||||
message(STATUS "Caffe: using OpenCV config from ${Caffe_OpenCV_CONFIG_PATH}")
|
||||
include(${Caffe_OpenCV_CONFIG_PATH}/OpenCVModules.cmake)
|
||||
endif()
|
||||
|
||||
else()
|
||||
find_package(OpenCV REQUIRED)
|
||||
endif()
|
||||
unset(Caffe_OpenCV_CONFIG_PATH)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Compute paths
|
||||
get_filename_component(Caffe_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
set(Caffe_INCLUDE_DIRS "@Caffe_INCLUDE_DIRS@")
|
||||
|
||||
@Caffe_INSTALL_INCLUDE_DIR_APPEND_COMMAND@
|
||||
|
||||
# Our library dependencies
|
||||
if(NOT TARGET caffe AND NOT caffe_BINARY_DIR)
|
||||
include("${Caffe_CMAKE_DIR}/CaffeTargets.cmake")
|
||||
endif()
|
||||
|
||||
# List of IMPORTED libs created by CaffeTargets.cmake
|
||||
set(Caffe_LIBRARIES caffe)
|
||||
|
||||
# Definitions
|
||||
set(Caffe_DEFINITIONS "@Caffe_DEFINITIONS@")
|
||||
|
||||
# Cuda support variables
|
||||
set(Caffe_CPU_ONLY @CPU_ONLY@)
|
||||
set(Caffe_HAVE_CUDA @HAVE_CUDA@)
|
||||
set(Caffe_HAVE_CUDNN @HAVE_CUDNN@)
|
@ -1,11 +0,0 @@
|
||||
set(PACKAGE_VERSION "@Caffe_VERSION@")
|
||||
|
||||
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
@ -1,38 +0,0 @@
|
||||
/* Sources directory */
|
||||
#define SOURCE_FOLDER "${PROJECT_SOURCE_DIR}"
|
||||
|
||||
/* Binaries directory */
|
||||
#define BINARY_FOLDER "${PROJECT_BINARY_DIR}"
|
||||
|
||||
/* NVIDA Cuda */
|
||||
#cmakedefine HAVE_CUDA
|
||||
|
||||
/* NVIDA cuDNN */
|
||||
#cmakedefine HAVE_CUDNN
|
||||
#cmakedefine USE_CUDNN
|
||||
|
||||
/* NVIDA cuDNN */
|
||||
#cmakedefine CPU_ONLY
|
||||
|
||||
/* Test device */
|
||||
#define CUDA_TEST_DEVICE ${CUDA_TEST_DEVICE}
|
||||
|
||||
/* Temporary (TODO: remove) */
|
||||
#if 1
|
||||
#define CMAKE_SOURCE_DIR SOURCE_FOLDER "/src/"
|
||||
#define EXAMPLES_SOURCE_DIR BINARY_FOLDER "/examples/"
|
||||
#define CMAKE_EXT ".gen.cmake"
|
||||
#else
|
||||
#define CMAKE_SOURCE_DIR "src/"
|
||||
#define EXAMPLES_SOURCE_DIR "examples/"
|
||||
#define CMAKE_EXT ""
|
||||
#endif
|
||||
|
||||
/* Matlab */
|
||||
#cmakedefine HAVE_MATLAB
|
||||
|
||||
/* IO libraries */
|
||||
#cmakedefine USE_OPENCV
|
||||
#cmakedefine USE_LEVELDB
|
||||
#cmakedefine USE_LMDB
|
||||
#cmakedefine ALLOW_LMDB_NOLOCK
|
@ -1,50 +0,0 @@
|
||||
|
||||
set(CMAKE_SOURCE_DIR ..)
|
||||
set(LINT_COMMAND ${CMAKE_SOURCE_DIR}/scripts/cpp_lint.py)
|
||||
set(SRC_FILE_EXTENSIONS h hpp hu c cpp cu cc)
|
||||
set(EXCLUDE_FILE_EXTENSTIONS pb.h pb.cc)
|
||||
set(LINT_DIRS include src/caffe examples tools python matlab)
|
||||
|
||||
cmake_policy(SET CMP0009 NEW) # suppress cmake warning
|
||||
|
||||
# find all files of interest
|
||||
foreach(ext ${SRC_FILE_EXTENSIONS})
|
||||
foreach(dir ${LINT_DIRS})
|
||||
file(GLOB_RECURSE FOUND_FILES ${CMAKE_SOURCE_DIR}/${dir}/*.${ext})
|
||||
set(LINT_SOURCES ${LINT_SOURCES} ${FOUND_FILES})
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
# find all files that should be excluded
|
||||
foreach(ext ${EXCLUDE_FILE_EXTENSTIONS})
|
||||
file(GLOB_RECURSE FOUND_FILES ${CMAKE_SOURCE_DIR}/*.${ext})
|
||||
set(EXCLUDED_FILES ${EXCLUDED_FILES} ${FOUND_FILES})
|
||||
endforeach()
|
||||
|
||||
# exclude generated pb files
|
||||
list(REMOVE_ITEM LINT_SOURCES ${EXCLUDED_FILES})
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LINT_COMMAND} ${LINT_SOURCES}
|
||||
ERROR_VARIABLE LINT_OUTPUT
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
string(REPLACE "\n" ";" LINT_OUTPUT ${LINT_OUTPUT})
|
||||
|
||||
list(GET LINT_OUTPUT -1 LINT_RESULT)
|
||||
list(REMOVE_AT LINT_OUTPUT -1)
|
||||
string(REPLACE " " ";" LINT_RESULT ${LINT_RESULT})
|
||||
list(GET LINT_RESULT -1 NUM_ERRORS)
|
||||
if(NUM_ERRORS GREATER 0)
|
||||
foreach(msg ${LINT_OUTPUT})
|
||||
string(FIND ${msg} "Done" result)
|
||||
if(result LESS 0)
|
||||
message(STATUS ${msg})
|
||||
endif()
|
||||
endforeach()
|
||||
message(FATAL_ERROR "Lint found ${NUM_ERRORS} errors!")
|
||||
else()
|
||||
message(STATUS "Lint did not find any errors!")
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user