]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - jacinto-ai/caffe-jacinto.git/blob - CMakeLists.txt
Merge branch 'orig-caffe-0.16' into nvcaffe-0.16-synced-shuffled
[jacinto-ai/caffe-jacinto.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.7)
2 if(POLICY CMP0046)
3   cmake_policy(SET CMP0046 NEW)
4 endif()
5 if(POLICY CMP0054)
6   cmake_policy(SET CMP0054 NEW)
7 endif()
9 # ---[ Caffe project
10 project(Caffe C CXX)
12 # ---[ Caffe version
13 set(CAFFE_TARGET_VERSION "0.16.1")
14 set(CAFFE_TARGET_SOVERSION "0.16")
15 add_definitions(-DCAFFE_VERSION=${CAFFE_TARGET_VERSION})
17 # ---[ Using cmake scripts and modules
18 list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
20 include(ExternalProject)
22 include(cmake/Utils.cmake)
23 include(cmake/Targets.cmake)
24 include(cmake/Misc.cmake)
25 include(cmake/Summary.cmake)
26 include(cmake/ConfigGen.cmake)
28 # ---[ Options
29 caffe_option(CPU_ONLY  "Build Caffe without CUDA support" OFF) # TODO: rename to USE_CUDA
30 caffe_option(USE_CUDNN "Build Caffe with cuDNN library support" ON IF NOT CPU_ONLY)
32 # USE_NCCL: Build Caffe with NCCL Library support
33 # Regular ON/OFF option doesn't work here because we need to recognize 3 states:
34 # 1. User didn't set USE_NCCL option =>
35 #   1.1 If CPU_ONLY is ON we do nothing.
36 #   1.2 If CPU_ONLY is OFF we *quietly* try to find it and use if found; do nothing otherwise.
37 # 2. User explicitly set USE_NCCL=ON option =>
38 #   1.1 If CPU_ONLY is ON we do nothing (it's higher priority).
39 #   2.1 If CPU_ONLY is OFF we try to find it with *required* option, thus CMake fails if not found. 
40 # 3. User explicitly set USE_NCCL=OFF option => we do nothing.
41 SET(USE_NCCL)
42 if(DEFINED USE_NCCL)
43   STRING(TOUPPER "${USE_NCCL}" USE_NCCL)
44 endif()
46 caffe_option(BUILD_SHARED_LIBS "Build shared libraries" ON)
47 caffe_option(BUILD_python "Build Python wrapper" ON)
48 set(python_version "2" CACHE STRING "Specify which Python version to use")
49 caffe_option(BUILD_matlab "Build Matlab wrapper" OFF IF UNIX OR APPLE)
50 caffe_option(BUILD_docs   "Build documentation" ON IF UNIX OR APPLE)
51 caffe_option(BUILD_python_layer "Build the Caffe Python layer" ON)
52 caffe_option(USE_OPENCV "Build with OpenCV support" ON)
53 caffe_option(USE_LEVELDB "Build with levelDB" ON)
54 caffe_option(USE_LMDB "Build with lmdb" ON)
55 caffe_option(ALLOW_LMDB_NOLOCK "Allow MDB_NOLOCK when reading LMDB files (only if necessary)" OFF)
56 caffe_option(TEST_FP16 "Build Caffe Tests with 16 bit mode included" OFF)
57 caffe_option(NO_NVML "Build Caffe Tests without NVML (i.e. no CPU affinity)" OFF)
59 # ---[ Dependencies
60 include(cmake/Dependencies.cmake)
62 # ---[ Flags
63 if(UNIX OR APPLE)
64   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++11")
65 endif()
67 caffe_set_caffe_link()
69 if(USE_libstdcpp)
70   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
71   message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")
72 endif()
74 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
76 add_definitions(-DGTEST_USE_OWN_TR1_TUPLE)
78 # ---[ Warnings
79 caffe_warnings_disable(CMAKE_CXX_FLAGS -Wno-sign-compare -Wno-uninitialized)
81 # ---[ Config generation
82 configure_file(cmake/Templates/caffe_config.h.in "${PROJECT_BINARY_DIR}/caffe_config.h")
84 # ---[ Includes
85 set(Caffe_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
86 set(THIRDPARTY_DIR ${PROJECT_SOURCE_DIR}/3rdparty)
87 include_directories(${Caffe_INCLUDE_DIR} ${PROJECT_BINARY_DIR} ${THIRDPARTY_DIR})
88 include_directories(BEFORE src) # This is needed for gtest.
90 # ---[ Subdirectories
91 add_subdirectory(src/gtest)
92 add_subdirectory(src/caffe)
93 add_subdirectory(tools)
94 add_subdirectory(examples)
95 add_subdirectory(python)
96 add_subdirectory(matlab)
97 add_subdirectory(docs)
99 # ---[ Linter target
100 add_custom_target(lint COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/lint.cmake)
102 # ---[ pytest target
103 if(BUILD_python)
104   add_custom_target(pytest COMMAND python${python_version} -m unittest discover -s caffe/test WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python )
105   add_dependencies(pytest pycaffe)
106 endif()
108 # ---[ Configuration summary
109 caffe_print_configuration_summary()
111 # ---[ Export configs generation
112 caffe_generate_export_configs()