2014-07-23 11:41:36 +04:00
|
|
|
cmake_minimum_required(VERSION 2.8.8)
|
2014-07-01 11:56:20 +04:00
|
|
|
project( Caffe )
|
|
|
|
|
|
|
|
### Build Options ##########################################################################
|
|
|
|
|
2014-07-24 15:44:05 +04:00
|
|
|
option(CPU_ONLY "Build Caffe without GPU support" OFF)
|
2014-07-01 11:56:20 +04:00
|
|
|
option(BUILD_PYTHON "Build Python wrapper" OFF)
|
|
|
|
option(BUILD_MATLAB "Build Matlab wrapper" OFF)
|
|
|
|
option(BUILD_EXAMPLES "Build examples" ON)
|
|
|
|
option(BUILD_SHARED_LIBS "Build SHARED libs if ON and STATIC otherwise" OFF)
|
|
|
|
|
|
|
|
if(NOT BLAS)
|
|
|
|
set(BLAS atlas)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT CUDA_TEST_DEVICE)
|
|
|
|
set(CUDA_TEST_DEVICE -1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Install Prefix
|
|
|
|
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install path" FORCE )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
### Configuration ###########################################################################
|
|
|
|
# Compiler Flags
|
|
|
|
set(CMAKE_CXX_COMPILER_FLAGS ${CMAKE_CXX_COMPILER_FLAGS} -Wall)
|
2014-07-29 12:40:40 +04:00
|
|
|
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} )#set global flags here)
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} )#set debug flags here)
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )#set release flags here)
|
2014-07-01 11:56:20 +04:00
|
|
|
|
2014-07-24 15:58:37 +04:00
|
|
|
# Global Definitions
|
|
|
|
if(CPU_ONLY)
|
|
|
|
add_definitions(-DCPU_ONLY)
|
|
|
|
endif()
|
|
|
|
|
2014-07-01 11:56:20 +04:00
|
|
|
# Include Directories
|
|
|
|
set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include)
|
|
|
|
include_directories(${${PROJECT_NAME}_INCLUDE_DIRS})
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
|
|
|
|
2014-07-28 16:01:45 +04:00
|
|
|
# CMake Scripts dir
|
|
|
|
set(CMAKE_SCRIPT_DIR ${CMAKE_SOURCE_DIR}/CMakeScripts)
|
|
|
|
|
2014-07-01 11:56:20 +04:00
|
|
|
# CMake module path for custom module finding
|
2014-07-28 16:01:45 +04:00
|
|
|
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SCRIPT_DIR})
|
2014-07-01 11:56:20 +04:00
|
|
|
|
|
|
|
# CUDA is required globally
|
2014-07-24 15:58:37 +04:00
|
|
|
if(NOT CPU_ONLY)
|
|
|
|
find_package(CUDA 5.5 REQUIRED)
|
|
|
|
include_directories(${CUDA_INCLUDE_DIRS})
|
|
|
|
endif()
|
2014-07-01 11:56:20 +04:00
|
|
|
|
|
|
|
### Subdirectories ##########################################################################
|
|
|
|
|
|
|
|
add_subdirectory(src/gtest)
|
|
|
|
add_subdirectory(src/caffe)
|
|
|
|
add_subdirectory(tools)
|
|
|
|
|
|
|
|
if(BUILD_EXAMPLES)
|
|
|
|
message(STATUS "Examples enabled")
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BUILD_PYTHON)
|
|
|
|
message(STATUS "Python enabled")
|
|
|
|
add_subdirectory(python)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BUILD_MATLAB)
|
|
|
|
message(STATUS "Matlab enabled")
|
|
|
|
add_subdirectory(matlab)
|
|
|
|
endif()
|
|
|
|
|
2014-07-28 16:01:45 +04:00
|
|
|
### Lint Target Setup ##########################################################################
|
|
|
|
|
|
|
|
set(LINT_TARGET lint)
|
|
|
|
set(LINT_SCRIPT ${CMAKE_SCRIPT_DIR}/lint.cmake)
|
|
|
|
add_custom_target(
|
|
|
|
${LINT_TARGET}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${LINT_SCRIPT}
|
|
|
|
)
|
|
|
|
|
2014-07-01 11:56:20 +04:00
|
|
|
### Install #################################################################################
|
|
|
|
|
|
|
|
# Install Includes
|
|
|
|
file(GLOB folders ${${PROJECT_NAME}_INCLUDE_DIRS}/*)
|
|
|
|
install(DIRECTORY ${folders} DESTINATION include)
|
2014-07-28 16:01:45 +04:00
|
|
|
|
|
|
|
|