2018-03-07 01:11:04 +00:00
|
|
|
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
2017-12-15 19:48:08 +00:00
|
|
|
#cmake_policy(SET CMP0022 NEW)
|
|
|
|
|
#cmake_policy(SET CMP0023 NEW)
|
2016-12-05 00:42:00 +00:00
|
|
|
|
2017-09-26 15:45:37 +00:00
|
|
|
# ---[ Project and semantic versioning.
|
2016-12-20 22:00:43 +00:00
|
|
|
project(Caffe2 CXX C)
|
2016-12-05 00:42:00 +00:00
|
|
|
|
2017-09-26 15:45:37 +00:00
|
|
|
set(CAFFE2_VERSION_MAJOR 0)
|
|
|
|
|
set(CAFFE2_VERSION_MINOR 8)
|
2018-03-14 01:07:07 +00:00
|
|
|
set(CAFFE2_VERSION_PATCH 2)
|
2017-09-26 15:45:37 +00:00
|
|
|
set(CAFFE2_VERSION
|
2017-10-19 16:55:56 +00:00
|
|
|
"${CAFFE2_VERSION_MAJOR}.${CAFFE2_VERSION_MINOR}.${CAFFE2_VERSION_PATCH}")
|
2016-12-06 16:39:15 +00:00
|
|
|
|
2018-03-01 20:01:44 +00:00
|
|
|
# One variable that determines whether the current cmake process is being run
|
|
|
|
|
# with the main Caffe2 library. This is useful for building modules - if
|
|
|
|
|
# modules are built with the main Caffe2 library then one does not need to do
|
|
|
|
|
# find caffe2 in the cmake script. One can usually guard it in some way like
|
|
|
|
|
# if (NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
|
|
|
|
# find_package(Caffe2 REQUIRED)
|
|
|
|
|
# endif()
|
|
|
|
|
set(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO ON)
|
|
|
|
|
|
2017-09-26 15:45:37 +00:00
|
|
|
# ---[ Options.
|
|
|
|
|
# Note to developers: if you add an option below, make sure you also add it to
|
|
|
|
|
# cmake/Summary.cmake so that the summary prints out the option values.
|
2018-01-29 18:00:43 +00:00
|
|
|
include(CMakeDependentOption)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(BUILD_BINARY "Build C++ binaries" ON)
|
2018-01-19 02:44:09 +00:00
|
|
|
option(BUILD_DOCS "Build documentation" OFF)
|
2018-04-03 13:50:14 +00:00
|
|
|
option(BUILD_CUSTOM_PROTOBUF "Build and use Caffe2's own protobuf under third_party" ON)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(BUILD_PYTHON "Build Python binaries" ON)
|
|
|
|
|
option(BUILD_SHARED_LIBS "Build libcaffe2.so" ON)
|
2018-03-19 21:36:53 +00:00
|
|
|
cmake_dependent_option(
|
|
|
|
|
CAFFE2_LINK_LOCAL_PROTOBUF "If set, build protobuf inside libcaffe2.so." ON
|
|
|
|
|
"BUILD_SHARED_LIBS AND BUILD_CUSTOM_PROTOBUF" OFF)
|
2018-01-29 18:00:43 +00:00
|
|
|
cmake_dependent_option(
|
|
|
|
|
CAFFE2_USE_MSVC_STATIC_RUNTIME "Using MSVC static runtime libraries" ON
|
|
|
|
|
"NOT BUILD_SHARED_LIBS" OFF)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(BUILD_TEST "Build C++ test binaries (need gtest and gbenchmark)" ON)
|
2018-02-24 02:09:05 +00:00
|
|
|
option(USE_ACL "Use ARM Compute Library" OFF)
|
2017-10-05 17:42:35 +00:00
|
|
|
option(USE_ASAN "Use Address Sanitizer" OFF)
|
2018-02-24 02:09:05 +00:00
|
|
|
option(USE_ATEN "Use ATen" OFF)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(USE_CUDA "Use Cuda" ON)
|
2018-04-25 23:22:54 +00:00
|
|
|
option(CAFFE2_STATIC_LINK_CUDA "Statically link CUDA libraries" OFF)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(USE_FFMPEG "Use ffmpeg" OFF)
|
2017-01-04 07:16:50 +00:00
|
|
|
option(USE_GFLAGS "Use GFLAGS" ON)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(USE_GLOG "Use GLOG" ON)
|
|
|
|
|
option(USE_GLOO "Use Gloo" ON)
|
2017-08-03 17:52:35 +00:00
|
|
|
option(USE_LEVELDB "Use LEVELDB" ON)
|
2017-04-16 23:39:39 +00:00
|
|
|
option(USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(USE_LMDB "Use LMDB" ON)
|
|
|
|
|
option(USE_METAL "Use Metal for iOS build" ON)
|
2018-02-02 02:12:43 +00:00
|
|
|
option(USE_MOBILE_OPENGL "Use OpenGL for mobile code" ON)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(USE_MPI "Use MPI" ON)
|
2018-01-22 21:47:44 +00:00
|
|
|
option(USE_NATIVE_ARCH "Use -march=native" OFF)
|
2017-02-13 17:42:48 +00:00
|
|
|
option(USE_NCCL "Use NCCL" ON)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(USE_NERVANA_GPU "Use Nervana GPU backend" OFF)
|
2018-02-09 02:57:48 +00:00
|
|
|
option(USE_NNAPI "Use NNAPI" OFF)
|
2017-03-27 15:42:36 +00:00
|
|
|
option(USE_NNPACK "Use NNPACK" ON)
|
2018-03-06 07:30:20 +00:00
|
|
|
option(USE_NUMA "Use NUMA (only available on Linux)" ON)
|
2018-03-06 22:45:21 +00:00
|
|
|
option(USE_OBSERVERS "Use observers module." OFF)
|
2018-04-20 18:31:21 +00:00
|
|
|
option(USE_OPENCL "Use OpenCL" OFF)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(USE_OPENCV "Use openCV" ON)
|
2017-11-14 21:10:41 +00:00
|
|
|
option(USE_OPENMP "Use OpenMP for parallel code" OFF)
|
2018-01-02 23:58:28 +00:00
|
|
|
option(USE_PROF "Use profiling" OFF)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(USE_REDIS "Use Redis" OFF)
|
2018-03-01 20:01:44 +00:00
|
|
|
option(USE_ROCKSDB "Use RocksDB" OFF)
|
2017-08-28 22:23:56 +00:00
|
|
|
option(USE_SNPE "Use Qualcomm's SNPE library" OFF)
|
2018-04-12 00:03:54 +00:00
|
|
|
option(USE_TENSORRT "Using Nvidia TensorRT library" OFF)
|
2017-08-09 16:16:46 +00:00
|
|
|
option(USE_ZMQ "Use ZMQ" OFF)
|
2017-11-14 06:01:07 +00:00
|
|
|
option(USE_ZSTD "Use ZSTD" OFF)
|
2018-04-25 01:32:35 +00:00
|
|
|
option(USE_IDEEP "Use IDEEP interface in MKL BLAS" ON)
|
|
|
|
|
option(USE_MKLML "Use MKLML interface in MKL BLAS" ON)
|
|
|
|
|
|
2018-05-03 02:33:31 +00:00
|
|
|
# ---[ Special code path for MKL module
|
2018-05-04 15:30:08 +00:00
|
|
|
if (NOT USE_ATEN)
|
|
|
|
|
set(USE_MKL_IDEEP_OR_MKLML ON)
|
|
|
|
|
endif()
|
2016-12-06 16:39:15 +00:00
|
|
|
|
2017-09-26 15:45:37 +00:00
|
|
|
# ---[ CMake scripts + modules
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
|
|
|
|
|
2018-01-29 18:00:43 +00:00
|
|
|
if (MSVC AND ${BUILD_SHARED_LIBS})
|
|
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
2017-10-26 19:20:50 +00:00
|
|
|
# ---[ CMake build directories
|
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
|
|
2017-09-26 15:45:37 +00:00
|
|
|
enable_testing()
|
|
|
|
|
|
2017-12-21 17:13:31 +00:00
|
|
|
# ---[ Misc checks to cope with various compiler modes
|
|
|
|
|
include(cmake/MiscCheck.cmake)
|
2018-02-28 04:42:37 +00:00
|
|
|
include(cmake/BuildVariables.cmake)
|
2017-12-21 17:13:31 +00:00
|
|
|
|
2017-04-16 23:39:39 +00:00
|
|
|
# External projects
|
|
|
|
|
include(ExternalProject)
|
|
|
|
|
|
2018-02-28 04:42:37 +00:00
|
|
|
# TODO: merge the following 3 files into cmake/public/utils.cmake.
|
2017-04-16 23:39:39 +00:00
|
|
|
include(cmake/Utils.cmake)
|
2018-02-28 04:42:37 +00:00
|
|
|
include(cmake/public/utils.cmake)
|
2017-04-16 23:39:39 +00:00
|
|
|
|
2017-05-24 17:02:14 +00:00
|
|
|
set(CAFFE2_WHITELIST "" CACHE STRING "A whitelist file of files that one should build.")
|
2017-01-30 17:39:25 +00:00
|
|
|
|
2017-01-09 18:49:51 +00:00
|
|
|
# Set default build type
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
message(STATUS "Build type not set - defaulting to Release")
|
|
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build from: Debug Release RelWithDebInfo MinSizeRel Coverage." FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
|
2016-12-06 16:39:15 +00:00
|
|
|
# ---[ Dependencies
|
|
|
|
|
include(cmake/Dependencies.cmake)
|
|
|
|
|
|
2017-03-29 15:45:19 +00:00
|
|
|
# ---[ Whitelist file if whitelist is specified
|
|
|
|
|
include(cmake/Whitelist.cmake)
|
|
|
|
|
|
2017-03-15 18:31:55 +00:00
|
|
|
# ---[ Set link flag, handle additional deps for gcc 4.8 and above
|
2017-03-17 22:01:55 +00:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8.0 AND NOT ANDROID)
|
2017-01-12 00:51:02 +00:00
|
|
|
message(STATUS "GCC ${CMAKE_CXX_COMPILER_VERSION}: Adding gcc and gcc_s libs to link line")
|
|
|
|
|
list(APPEND Caffe2_DEPENDENCY_LIBS gcc_s gcc)
|
2016-12-12 17:29:00 +00:00
|
|
|
endif()
|
|
|
|
|
|
2017-01-05 04:36:11 +00:00
|
|
|
# ---[ Build flags
|
2018-03-07 01:11:04 +00:00
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
Re-apply windows diff D4657831
Summary:
(Note: previous revert was due to a race condition between D4657831 and
D4659953 that I failed to catch.)
After this, we should have contbuild guarding the Windows build both with
and without CUDA.
This includes a series of changes that are needed to make Windows build,
specifically:
(1) Various flags that are needed in the cmake system, specially dealing
with /MD, /MT, cuda, cudnn, whole static linking, etc.
(2) Contbuild scripts based on appveyo.
(3) For Windows build, note that one will need to use "cmake --build" to
build stuff so that the build type is consistent between configuration and
actual build. see scripts\build_windows.bat for details.
(4) In logging.h, ERROR is already defined by Windows. I don't have a good
solution now, and as a result, LOG(ERROR) on windows is going to be
LOG(INFO).
(5) variable length array is not supported by MSVC (and it is not part of
C++ standard). As a result I replaced them with vectors.
(6) sched.h is not available on Windows, so akyrola 's awesome simple
async net might encounter some slowdown due to no affinity setting on
Windows.
(7) MSVC has a bug that does not work very well with template calls inide
a templated function call, which is a known issue that should be fixed in
MSVC 2017. However for now this means changes to conv_op_impl.h and
recurrent_net_op.h. No actual functionalities are changed.
(8) std host function calls are not supported in CUDA8+MSVC, so I changed
lp_pool (and maybe a few others) to use cuda device functions.
(9) The current Scale and Axpy has heavy templating that does not work
well with MSVC. As a result I reverted azzolini 's changes to the Scale
and Axpy interface, moved the fixed-length version to ScaleFixedSize and
AxpyFixedSize.
(10) CUDA + MSVC does not deal with Eigen well, so I guarded all Eigen
parts to only the non-CUDA part.
(11) In conclusion, it is fun but painful to deal with visual c++.
Differential Revision: D4666745
fbshipit-source-id: 3c9035083067bdb19a16d9c345c1ce66b6a86600
2017-03-07 18:56:26 +00:00
|
|
|
if(NOT MSVC)
|
2018-03-07 01:11:04 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -fPIC")
|
2017-02-13 17:42:48 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
|
2018-01-16 22:33:11 +00:00
|
|
|
# Eigen fails to build with some versions, so convert this to a warning
|
|
|
|
|
# Details at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1459
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization")
|
Re-apply windows diff D4657831
Summary:
(Note: previous revert was due to a race condition between D4657831 and
D4659953 that I failed to catch.)
After this, we should have contbuild guarding the Windows build both with
and without CUDA.
This includes a series of changes that are needed to make Windows build,
specifically:
(1) Various flags that are needed in the cmake system, specially dealing
with /MD, /MT, cuda, cudnn, whole static linking, etc.
(2) Contbuild scripts based on appveyo.
(3) For Windows build, note that one will need to use "cmake --build" to
build stuff so that the build type is consistent between configuration and
actual build. see scripts\build_windows.bat for details.
(4) In logging.h, ERROR is already defined by Windows. I don't have a good
solution now, and as a result, LOG(ERROR) on windows is going to be
LOG(INFO).
(5) variable length array is not supported by MSVC (and it is not part of
C++ standard). As a result I replaced them with vectors.
(6) sched.h is not available on Windows, so akyrola 's awesome simple
async net might encounter some slowdown due to no affinity setting on
Windows.
(7) MSVC has a bug that does not work very well with template calls inide
a templated function call, which is a known issue that should be fixed in
MSVC 2017. However for now this means changes to conv_op_impl.h and
recurrent_net_op.h. No actual functionalities are changed.
(8) std host function calls are not supported in CUDA8+MSVC, so I changed
lp_pool (and maybe a few others) to use cuda device functions.
(9) The current Scale and Axpy has heavy templating that does not work
well with MSVC. As a result I reverted azzolini 's changes to the Scale
and Axpy interface, moved the fixed-length version to ScaleFixedSize and
AxpyFixedSize.
(10) CUDA + MSVC does not deal with Eigen well, so I guarded all Eigen
parts to only the non-CUDA part.
(11) In conclusion, it is fun but painful to deal with visual c++.
Differential Revision: D4666745
fbshipit-source-id: 3c9035083067bdb19a16d9c345c1ce66b6a86600
2017-03-07 18:56:26 +00:00
|
|
|
else()
|
2017-07-26 07:17:19 +00:00
|
|
|
foreach(flag_var
|
|
|
|
|
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
|
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
2018-01-29 18:00:43 +00:00
|
|
|
if (${CAFFE2_USE_MSVC_STATIC_RUNTIME})
|
Re-apply windows diff D4657831
Summary:
(Note: previous revert was due to a race condition between D4657831 and
D4659953 that I failed to catch.)
After this, we should have contbuild guarding the Windows build both with
and without CUDA.
This includes a series of changes that are needed to make Windows build,
specifically:
(1) Various flags that are needed in the cmake system, specially dealing
with /MD, /MT, cuda, cudnn, whole static linking, etc.
(2) Contbuild scripts based on appveyo.
(3) For Windows build, note that one will need to use "cmake --build" to
build stuff so that the build type is consistent between configuration and
actual build. see scripts\build_windows.bat for details.
(4) In logging.h, ERROR is already defined by Windows. I don't have a good
solution now, and as a result, LOG(ERROR) on windows is going to be
LOG(INFO).
(5) variable length array is not supported by MSVC (and it is not part of
C++ standard). As a result I replaced them with vectors.
(6) sched.h is not available on Windows, so akyrola 's awesome simple
async net might encounter some slowdown due to no affinity setting on
Windows.
(7) MSVC has a bug that does not work very well with template calls inide
a templated function call, which is a known issue that should be fixed in
MSVC 2017. However for now this means changes to conv_op_impl.h and
recurrent_net_op.h. No actual functionalities are changed.
(8) std host function calls are not supported in CUDA8+MSVC, so I changed
lp_pool (and maybe a few others) to use cuda device functions.
(9) The current Scale and Axpy has heavy templating that does not work
well with MSVC. As a result I reverted azzolini 's changes to the Scale
and Axpy interface, moved the fixed-length version to ScaleFixedSize and
AxpyFixedSize.
(10) CUDA + MSVC does not deal with Eigen well, so I guarded all Eigen
parts to only the non-CUDA part.
(11) In conclusion, it is fun but painful to deal with visual c++.
Differential Revision: D4666745
fbshipit-source-id: 3c9035083067bdb19a16d9c345c1ce66b6a86600
2017-03-07 18:56:26 +00:00
|
|
|
if(${flag_var} MATCHES "/MD")
|
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
|
|
|
endif(${flag_var} MATCHES "/MD")
|
2018-01-29 18:00:43 +00:00
|
|
|
else()
|
|
|
|
|
if(${flag_var} MATCHES "/MT")
|
|
|
|
|
string(REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}")
|
|
|
|
|
endif()
|
2017-07-26 07:17:19 +00:00
|
|
|
endif()
|
|
|
|
|
set(${flag_var} "${${flag_var}} /MP /bigobj")
|
|
|
|
|
endforeach(flag_var)
|
2017-02-13 17:42:48 +00:00
|
|
|
endif()
|
2017-01-05 04:36:11 +00:00
|
|
|
|
2018-03-02 14:24:05 +00:00
|
|
|
if(ANDROID)
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s")
|
|
|
|
|
else()
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2017-05-22 17:21:13 +00:00
|
|
|
if(NOT APPLE AND UNIX)
|
|
|
|
|
list(APPEND Caffe2_DEPENDENCY_LIBS dl)
|
|
|
|
|
endif()
|
|
|
|
|
|
2017-08-30 17:12:35 +00:00
|
|
|
# Prefix path to Caffe2 headers.
|
|
|
|
|
# If a directory containing installed Caffe2 headers was inadvertently
|
|
|
|
|
# added to the list of include directories, prefixing
|
|
|
|
|
# PROJECT_SOURCE_DIR means this source tree always takes precedence.
|
|
|
|
|
include_directories(BEFORE ${PROJECT_SOURCE_DIR})
|
|
|
|
|
|
|
|
|
|
# Prefix path to generated Caffe2 headers.
|
|
|
|
|
# These need to take precedence over their empty counterparts located
|
|
|
|
|
# in PROJECT_SOURCE_DIR.
|
2017-01-26 22:29:51 +00:00
|
|
|
include_directories(BEFORE ${PROJECT_BINARY_DIR})
|
2017-01-12 00:51:02 +00:00
|
|
|
|
2016-12-12 17:29:00 +00:00
|
|
|
# ---[ Old caffe protobuf.
|
2016-12-05 00:42:00 +00:00
|
|
|
add_subdirectory(caffe/proto)
|
|
|
|
|
|
2016-12-12 17:29:00 +00:00
|
|
|
# ---[ Main build
|
2016-12-05 00:42:00 +00:00
|
|
|
add_subdirectory(caffe2)
|
2016-12-08 18:23:04 +00:00
|
|
|
|
2018-01-19 02:44:09 +00:00
|
|
|
# Documentation Option
|
|
|
|
|
if(BUILD_DOCS)
|
|
|
|
|
# check if Doxygen is installed
|
|
|
|
|
find_package(Doxygen)
|
|
|
|
|
if (DOXYGEN_FOUND)
|
|
|
|
|
message("Generating documentation")
|
|
|
|
|
|
2018-03-27 04:07:40 +00:00
|
|
|
set(DOXYGEN_C_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/caffe2/.Doxyfile-c)
|
|
|
|
|
set(DOXYGEN_C_OUT ${CMAKE_CURRENT_SOURCE_DIR}/docs/caffe2/Doxyfile-c)
|
|
|
|
|
set(DOXYGEN_P_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/caffe2/.Doxyfile-python)
|
|
|
|
|
set(DOXYGEN_P_OUT ${CMAKE_CURRENT_SOURCE_DIR}/docs/caffe2/Doxyfile-python)
|
2018-01-19 02:44:09 +00:00
|
|
|
|
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/docs)
|
|
|
|
|
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/docs)
|
|
|
|
|
endif (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/docs)
|
|
|
|
|
|
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs)
|
|
|
|
|
configure_file(${DOXYGEN_C_IN} ${DOXYGEN_C_OUT} @ONLY)
|
|
|
|
|
configure_file(${DOXYGEN_P_IN} ${DOXYGEN_P_OUT} @ONLY)
|
|
|
|
|
|
|
|
|
|
add_custom_target(doc_doxygen_c ALL
|
|
|
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_C_OUT}
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
|
COMMENT "Generating C++ API documentation with Doxygen"
|
|
|
|
|
VERBATIM)
|
|
|
|
|
|
|
|
|
|
add_custom_target(doc_doxygen_python ALL
|
|
|
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_P_OUT}
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
|
COMMENT "Generating Python API documentation with Doxygen"
|
|
|
|
|
VERBATIM)
|
|
|
|
|
else (DOXYGEN_FOUND)
|
|
|
|
|
message(FATAL_ERROR "Doxygen needs to be installed to generate the documentation")
|
|
|
|
|
endif (DOXYGEN_FOUND)
|
|
|
|
|
endif (BUILD_DOCS)
|
|
|
|
|
|
2017-10-19 16:55:56 +00:00
|
|
|
# ---[ CMake related files
|
|
|
|
|
# Uninistall option.
|
2018-01-29 18:00:43 +00:00
|
|
|
if(NOT TARGET caffe2_uninstall)
|
2017-08-09 05:01:09 +00:00
|
|
|
configure_file(
|
2017-09-05 16:48:36 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
|
2017-08-09 05:01:09 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
2018-01-29 18:00:43 +00:00
|
|
|
add_custom_target(caffe2_uninstall
|
2017-08-09 05:01:09 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -P
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
|
|
|
endif()
|
2017-10-19 16:55:56 +00:00
|
|
|
|
|
|
|
|
# ---[ Make configuration files for cmake to allow dependent libraries
|
|
|
|
|
# easier access to Caffe2.
|
|
|
|
|
|
2018-02-21 05:39:00 +00:00
|
|
|
if ((NOT USE_GLOG) OR (NOT USE_GFLAGS) OR BUILD_CUSTOM_PROTOBUF)
|
2017-10-19 16:55:56 +00:00
|
|
|
message(WARNING
|
2017-12-15 19:48:08 +00:00
|
|
|
"Generated cmake files are only fully tested if one builds "
|
2018-02-21 05:39:00 +00:00
|
|
|
"with system glog, gflags, and protobuf. Other settings may "
|
|
|
|
|
"generate files that are not well tested.")
|
2017-12-15 19:48:08 +00:00
|
|
|
endif()
|
2018-02-21 05:39:00 +00:00
|
|
|
|
2017-12-15 19:48:08 +00:00
|
|
|
if (USE_CUDA)
|
2018-02-22 20:54:34 +00:00
|
|
|
# TODO: check if we should include other cuda dependency libraries
|
|
|
|
|
# to the interface as well.
|
2018-02-28 04:42:37 +00:00
|
|
|
|
2017-10-19 16:55:56 +00:00
|
|
|
endif()
|
|
|
|
|
|
2017-12-15 19:48:08 +00:00
|
|
|
# Note(jiayq): when building static libraries, all PRIVATE dependencies
|
|
|
|
|
# will also become interface libraries, and as a result if there are any
|
|
|
|
|
# dependency libraries that are not exported, the following install export
|
|
|
|
|
# script will fail. As a result, we will only provide the targets cmake
|
|
|
|
|
# files for shared lib installation. For more info, read:
|
|
|
|
|
# https://cmake.org/pipermail/cmake/2016-May/063400.html
|
|
|
|
|
if (BUILD_SHARED_LIBS)
|
2017-10-19 16:55:56 +00:00
|
|
|
configure_file(
|
|
|
|
|
${PROJECT_SOURCE_DIR}/cmake/Caffe2ConfigVersion.cmake.in
|
|
|
|
|
${PROJECT_BINARY_DIR}/Caffe2ConfigVersion.cmake
|
|
|
|
|
@ONLY)
|
|
|
|
|
configure_file(
|
|
|
|
|
${PROJECT_SOURCE_DIR}/cmake/Caffe2Config.cmake.in
|
|
|
|
|
${PROJECT_BINARY_DIR}/Caffe2Config.cmake
|
|
|
|
|
@ONLY)
|
|
|
|
|
install(FILES
|
|
|
|
|
${PROJECT_BINARY_DIR}/Caffe2ConfigVersion.cmake
|
|
|
|
|
${PROJECT_BINARY_DIR}/Caffe2Config.cmake
|
|
|
|
|
DESTINATION share/cmake/Caffe2
|
|
|
|
|
COMPONENT dev)
|
2018-01-28 02:56:42 +00:00
|
|
|
install(FILES
|
2018-02-22 20:54:34 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/public/cuda.cmake
|
2018-01-29 01:48:59 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/public/glog.cmake
|
2018-01-28 02:56:42 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/public/gflags.cmake
|
2018-02-21 05:39:00 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/public/protobuf.cmake
|
2018-03-06 22:45:21 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/public/threads.cmake
|
2018-02-28 04:42:37 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/public/utils.cmake
|
2018-01-28 02:56:42 +00:00
|
|
|
DESTINATION share/cmake/Caffe2/public
|
|
|
|
|
COMPONENT dev)
|
2017-10-19 16:55:56 +00:00
|
|
|
install(EXPORT Caffe2Targets DESTINATION share/cmake/Caffe2
|
|
|
|
|
FILE Caffe2Targets.cmake
|
|
|
|
|
COMPONENT dev)
|
2017-12-15 19:48:08 +00:00
|
|
|
else()
|
|
|
|
|
message(WARNING
|
|
|
|
|
"Generated cmake files are only available when building "
|
|
|
|
|
"shared libs.")
|
2017-10-19 16:55:56 +00:00
|
|
|
endif()
|
2017-10-26 19:20:50 +00:00
|
|
|
|
|
|
|
|
# ---[ Modules
|
2018-01-03 14:14:04 +00:00
|
|
|
add_subdirectory(modules)
|
2018-03-01 20:01:44 +00:00
|
|
|
|
2018-03-06 22:45:21 +00:00
|
|
|
# ---[ Binaries
|
|
|
|
|
# Binaries will be built after the Caffe2 main libraries and the modules
|
|
|
|
|
# are built. For the binaries, they will be linked to the Caffe2 main
|
|
|
|
|
# libraries, as well as all the modules that are built with Caffe2 (the ones
|
|
|
|
|
# built in the previous Modules section above).
|
|
|
|
|
|
|
|
|
|
if (BUILD_BINARY)
|
|
|
|
|
add_subdirectory(binaries)
|
|
|
|
|
endif()
|
|
|
|
|
|
2018-03-01 20:01:44 +00:00
|
|
|
include(cmake/Summary.cmake)
|
|
|
|
|
caffe2_print_configuration_summary()
|