2018-06-25 18:21:42 +00:00
cmake_minimum_required(VERSION 3.5 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
2019-02-04 16:50:35 +00:00
# Use compiler ID "AppleClang" instead of "Clang" for XCode.
# Not setting this sometimes makes XCode C compiler gets detected as "Clang",
# even when the C++ one is detected as "AppleClang".
cmake_policy(SET CMP0025 NEW)
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
2018-10-05 22:55:01 +00:00
set(CMAKE_INSTALL_MESSAGE NEVER)
2018-09-24 18:02:46 +00:00
set(CMAKE_CXX_STANDARD 11)
if (NOT MSVC)
set(CMAKE_C_STANDARD 11)
endif()
2019-05-16 16:37:02 +00:00
if (DEFINED GLIBCXX_USE_CXX11_ABI)
if (${GLIBCXX_USE_CXX11_ABI} EQUAL 1)
set(CXX_STANDARD_REQUIRED ON)
2019-07-22 22:05:19 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=1")
2019-05-16 16:37:02 +00:00
endif()
endif()
2018-09-24 18:02:46 +00:00
2018-10-04 00:14:19 +00:00
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
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)
2018-05-30 18:44:23 +00:00
if(NOT DEFINED BLAS_SET_BY_USER)
if(DEFINED BLAS)
set(BLAS_SET_BY_USER TRUE)
else()
message(STATUS "Not forcing any particular BLAS to be found")
set(BLAS_SET_BY_USER FALSE)
endif()
set(BLAS_SET_BY_USER ${BLAS_SET_BY_USER} CACHE STRING "Marks whether BLAS was manually set by user or auto-detected")
2018-05-25 14:38:50 +00:00
endif()
2018-05-30 18:44:23 +00:00
2018-07-10 01:04:25 +00:00
# Apple specific
2018-06-05 17:37:05 +00:00
if(APPLE)
2018-07-10 01:04:25 +00:00
# These lines are an attempt to make find_package(cuda) pick up
# libcuda.dylib, and not cuda.framework. It doesn't work all
# the time, but it seems to help for some users.
# TODO: replace this with a more robust fix
2018-06-05 17:37:05 +00:00
set(CMAKE_FIND_FRAMEWORK LAST)
set(CMAKE_FIND_APPBUNDLE LAST)
2018-07-10 01:04:25 +00:00
# Get clang version on macOS
2018-06-12 02:45:40 +00:00
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
string(REGEX REPLACE "Apple LLVM version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
MESSAGE( STATUS "CLANG_VERSION_STRING: " ${CLANG_VERSION_STRING} )
2018-07-10 01:04:25 +00:00
# RPATH stuff
set(CMAKE_MACOSX_RPATH ON)
2018-06-12 02:45:40 +00:00
endif()
2019-06-27 17:17:55 +00:00
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "(x86_64|i[3-6]+86)")
set(CPU_INTEL ON)
else ()
set(CPU_INTEL OFF)
endif ()
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)
2018-08-20 22:38:31 +00:00
option(ATEN_NO_TEST "Do not build ATen test binaries" OFF)
2018-10-10 19:46:56 +00:00
option(BUILD_ATEN_ONLY "Build only a subset focused on ATen only" OFF)
2018-09-07 22:06:30 +00:00
option(BUILD_BINARY "Build C++ binaries" OFF)
2018-05-08 17:24:04 +00:00
option(BUILD_DOCS "Build Caffe2 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)
2018-09-11 00:11:16 +00:00
option(BUILD_CAFFE2_OPS "Build Caffe2 operators" ON)
2017-08-09 16:16:46 +00:00
option(BUILD_SHARED_LIBS "Build libcaffe2.so" ON)
2019-05-03 16:23:11 +00:00
option(BUILD_CAFFE2_MOBILE "Build libcaffe2 for mobile (deprecating)" ON)
2019-07-02 18:42:41 +00:00
option(BUILD_NAMEDTENSOR "Experimental: compile with namedtensor support" OFF)
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)
2018-08-31 20:08:20 +00:00
option(BUILD_TEST "Build C++ test binaries (need gtest and gbenchmark)" OFF)
2018-06-07 03:56:31 +00:00
cmake_dependent_option(
2018-12-11 17:59:28 +00:00
INSTALL_TEST "Install test binaries if BUILD_TEST is on" ON
2018-06-07 03:56:31 +00:00
"BUILD_TEST" OFF)
2019-05-24 16:12:27 +00:00
option(COLORIZE_OUTPUT "Colorize output during compilation" ON)
2017-10-05 17:42:35 +00:00
option(USE_ASAN "Use Address Sanitizer" OFF)
2018-05-08 17:24:04 +00:00
option(USE_CUDA "Use CUDA" ON)
2018-11-29 19:15:03 +00:00
option(USE_ROCM "Use ROCm" ON)
2018-04-25 23:22:54 +00:00
option(CAFFE2_STATIC_LINK_CUDA "Statically link CUDA libraries" OFF)
2018-05-08 17:24:04 +00:00
cmake_dependent_option(
USE_CUDNN "Use cuDNN" ON
2018-05-24 14:47:27 +00:00
"USE_CUDA" OFF)
2018-11-16 02:17:34 +00:00
option(USE_FBGEMM "Use FBGEMM (quantized 8-bit server operators)" OFF)
2017-08-09 16:16:46 +00:00
option(USE_FFMPEG "Use ffmpeg" OFF)
2019-02-06 13:09:09 +00:00
option(USE_GFLAGS "Use GFLAGS" OFF)
option(USE_GLOG "Use GLOG" OFF)
option(USE_LEVELDB "Use LEVELDB" OFF)
2017-04-16 23:39:39 +00:00
option(USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
2019-02-06 13:09:09 +00:00
option(USE_LMDB "Use LMDB" OFF)
2018-08-31 20:08:20 +00:00
option(USE_METAL "Use Metal for iOS build" ON)
2018-01-22 21:47:44 +00:00
option(USE_NATIVE_ARCH "Use -march=native" OFF)
Let CMake handle NCCL detection instead of our handcrafted Python script. (#22930)
Summary:
---
How does the current code subsume all detections in the deleted `nccl.py`?
- The dependency of `USE_NCCL` on the OS and `USE_CUDA` is handled as dependency options in `CMakeLists.txt`.
- The main NCCL detection happens in [FindNCCL.cmake](https://github.com/pytorch/pytorch/blob/8377d4b32c12206a0f9401e81a5e5796c8fc01a8/cmake/Modules/FindNCCL.cmake), which is called by [nccl.cmake](https://github.com/pytorch/pytorch/blob/8377d4b32c12206a0f9401e81a5e5796c8fc01a8/cmake/External/nccl.cmake). When `USE_SYSTEM_NCCL` is false, the previous Python code defer the detection to `find_package(NCCL)`. The change in `nccl.cmake` retains this.
- `USE_STATIC_NCCL` in the previous Python code simply changes the name of the detected library. This is done in `IF (USE_STATIC_NCCL)`.
- Now we only need to look at how the lines below line 20 in `nccl.cmake` are subsumed. These lines list paths to header and library directories that NCCL headers and libraries may reside in and try to search these directories for the key header and library files in turn. These are done by `find_path` for headers and `find_library` for the library files in `FindNCCL.cmake`.
* The call of [find_path](https://cmake.org/cmake/help/v3.8/command/find_path.html) (Search for `NO_DEFAULT_PATH` in the link) by default searches for headers in `<prefix>/include` for each `<prefix>` in `CMAKE_PREFIX_PATH` and `CMAKE_SYSTEM_PREFIX_PATH`. Like the Python code, this commit sets `CMAKE_PREFIX_PATH` to search for `<prefix>` in `NCCL_ROOT_DIR` and home to CUDA. `CMAKE_SYSTEM_PREFIX_PATH` includes the standard directories such as `/usr/local` and `/usr`. `NCCL_INCLUDE_DIR` is also specifically handled.
* Similarly, the call of [find_library](https://cmake.org/cmake/help/v3.8/command/find_library.html) (Search for `NO_DEFAULT_PATH` in the link) by default searches for libraries in directories including `<prefix>/lib` for each `<prefix>` in `CMAKE_PREFIX_PATH` and `CMAKE_SYSTEM_PREFIX_PATH`. But it also handles the edge cases intended to be solved in the Python code more properly:
- It only searches for `<prefix>/lib64` (and `<prefix>/lib32`) if it is appropriate on the system.
- It only searches for `<prefix>/lib/<arch>` for the right `<arch>`, unlike the Python code searches for `lib/<arch>` in a generic way (e.g., the Python code searches for `/usr/lib/x86_64-linux-gnu` but in reality systems have `/usr/lib/x86_64-some-customized-name-linux-gnu`, see https://unix.stackexchange.com/a/226180/38242 ).
---
Regarding for relevant issues:
- https://github.com/pytorch/pytorch/issues/12063 and https://github.com/pytorch/pytorch/issues/2877: These are properly handled, as explained in the updated comment.
- https://github.com/pytorch/pytorch/issues/2941 does not changes NCCL detection specifically for Windows (it changed CUDA detection).
- b7e258f81ef61d19b884194cdbcd6c7089636d46 A versioned library detection is added, but the order is reversed: The unversioned library becomes preferred. This is because normally unversioned libraries are linked to versioned libraries and preferred by users, and local installation by users are often unversioned. Like the document of [find_library](https://cmake.org/cmake/help/v3.8/command/find_library.html) suggests:
> When using this to specify names with and without a version suffix, we recommend specifying the unversioned name first so that locally-built packages can be found before those provided by distributions.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/22930
Differential Revision: D16440275
Pulled By: ezyang
fbshipit-source-id: 11fe80743d4fe89b1ed6f96d5d996496e8ec01aa
2019-07-23 15:35:59 +00:00
cmake_dependent_option(
USE_NCCL "Use NCCL" ON
"USE_CUDA;UNIX;NOT APPLE" OFF)
cmake_dependent_option(
USE_STATIC_NCCL "Use static NCCL" OFF
"USE_NCCL" OFF)
cmake_dependent_option(
USE_SYSTEM_NCCL "Use system-wide NCCL" OFF
"USE_NCCL" 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-06-13 17:25:32 +00:00
option(USE_NUMA "Use NUMA (only available on Linux)" ON)
2018-06-08 21:27:23 +00:00
cmake_dependent_option(
USE_NVRTC "Use NVRTC. Only available if USE_CUDA is on." OFF
"USE_CUDA" OFF)
2018-10-04 19:00:29 +00:00
option(USE_NUMPY "Use NumPy" 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)
2019-02-06 13:09:09 +00:00
option(USE_OPENCV "Use OpenCV" OFF)
2019-02-04 16:50:35 +00:00
option(USE_OPENMP "Use OpenMP for parallel code" ON)
2018-01-02 23:58:28 +00:00
option(USE_PROF "Use profiling" OFF)
2018-10-26 05:13:18 +00:00
option(USE_QNNPACK "Use QNNPACK (quantized 8-bit operators)" ON)
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-09-04 17:44:24 +00:00
option(USE_SYSTEM_EIGEN_INSTALL
"Use system Eigen instead of the one under third_party" 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)
2019-06-27 17:17:55 +00:00
cmake_dependent_option(
USE_MKLDNN "Use MKLDNN. Only available on x86 and x86_64." ON
"CPU_INTEL" OFF)
set(MKLDNN_ENABLE_CONCURRENT_EXEC ${USE_MKLDNN})
2019-07-02 19:22:20 +00:00
cmake_dependent_option(
USE_MKLDNN_CBLAS "Use CBLAS in MKLDNN" OFF
"USE_MKLDNN" OFF)
2018-09-06 15:40:57 +00:00
option(USE_DISTRIBUTED "Use distributed" ON)
2018-09-05 23:45:48 +00:00
cmake_dependent_option(
2018-09-12 01:24:55 +00:00
USE_MPI "Use MPI for Caffe2. Only available if USE_DISTRIBUTED is on." ON
2018-09-05 23:45:48 +00:00
"USE_DISTRIBUTED" OFF)
2018-09-06 15:40:57 +00:00
cmake_dependent_option(
USE_GLOO "Use Gloo. Only available if USE_DISTRIBUTED is on." ON
"USE_DISTRIBUTED" OFF)
cmake_dependent_option(
USE_GLOO_IBVERBS "Use Gloo IB verbs for distributed. Only available if USE_GLOO is on." OFF
"USE_GLOO" OFF)
2019-05-28 09:43:22 +00:00
option(USE_TBB "Use TBB" OFF)
2018-05-08 17:24:04 +00:00
2018-07-10 01:04:25 +00:00
# Used when building Caffe2 through setup.py
2019-06-24 14:06:53 +00:00
option(BUILDING_WITH_TORCH_LIBS "Tell cmake if Caffe2 is being built alongside torch libs" ON)
2018-07-10 01:04:25 +00:00
2019-04-03 15:19:45 +00:00
# /Z7 override option
# When generating debug symbols, CMake default to use the flag /Zi.
# However, it is not compatible with sccache. So we rewrite it off.
# But some users don't use sccache; this override is for them.
option(MSVC_Z7_OVERRIDE "Work around sccache bug by replacing /Zi and /ZI with /Z7 when using MSVC (if you are not using sccache, you can turn this OFF)" ON)
2019-06-24 14:06:53 +00:00
set(ONNX_NAMESPACE "onnx_torch" CACHE STRING "A namespace for ONNX; needed to build with other frameworks that share ONNX.")
2018-08-30 22:13:49 +00:00
2019-04-03 15:19:45 +00:00
# For MSVC,
# 1. Replace /Zi and /ZI with /Z7
# 2. Switch off incremental linking in debug builds
if (MSVC)
if(MSVC_Z7_OVERRIDE)
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/Z[iI]")
string(REGEX REPLACE "/Z[iI]" "/Z7" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/Z[iI]")
endforeach(flag_var)
endif(MSVC_Z7_OVERRIDE)
foreach(flag_var
CMAKE_SHARED_LINKER_FLAGS_DEBUG CMAKE_STATIC_LINKER_FLAGS_DEBUG
CMAKE_EXE_LINKER_FLAGS_DEBUG CMAKE_MODULE_LINKER_FLAGS_DEBUG)
if(${flag_var} MATCHES "/INCREMENTAL" AND NOT ${flag_var} MATCHES "/INCREMENTAL:NO")
string(REGEX REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" ${flag_var} "${${flag_var}}")
endif()
endforeach(flag_var)
2019-05-09 13:18:37 +00:00
# Turning off USE_DISTRIBUTED on default
set(USE_DISTRIBUTED OFF)
2019-04-03 15:19:45 +00:00
endif(MSVC)
2019-05-01 07:16:13 +00:00
# Set INTERN_BUILD_MOBILE for all mobile builds. Components that are not
# applicable to mobile are disabled by this variable.
2018-08-28 21:21:18 +00:00
if (ANDROID OR IOS)
2019-05-01 07:16:13 +00:00
set(INTERN_BUILD_MOBILE ON)
2018-05-08 17:24:04 +00:00
endif()
2018-04-25 01:32:35 +00:00
2019-05-03 16:23:11 +00:00
# INTERN_BUILD_ATEN_OPS is used to control whether to build ATen/TH operators.
# It's disabled for caffe2 mobile library.
if (INTERN_BUILD_MOBILE AND BUILD_CAFFE2_MOBILE)
set(INTERN_BUILD_ATEN_OPS OFF)
else()
set(INTERN_BUILD_ATEN_OPS ON)
endif()
# BUILD_CAFFE2_MOBILE is the master switch to choose between libcaffe2 v.s. libtorch mobile build.
# When it's enabled it builds original libcaffe2 mobile library without ATen/TH ops nor TorchScript support;
# When it's disabled it builds libtorch mobile library, which contains ATen/TH ops and native support for
# TorchScript model, but doesn't contain not-yet-unified caffe2 ops;
if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
set(BUILD_PYTHON OFF)
set(BUILD_CAFFE2_OPS OFF)
set(USE_DISTRIBUTED OFF)
set(FEATURE_TORCH_MOBILE ON)
endif()
2018-10-10 19:46:56 +00:00
if (BUILD_ATEN_ONLY)
set(BUILD_CAFFE2_OPS OFF)
set(BUILD_PYTHON OFF)
set(USE_NUMA OFF)
set(USE_LEVELDB OFF)
set(USE_GFLAGS OFF)
set(USE_GLOG OFF)
set(USE_NCCL OFF)
set(USE_NNPACK OFF)
set(USE_NUMPY OFF)
set(USE_OPENCV OFF)
2018-10-29 17:47:25 +00:00
set(USE_MKLDNN OFF)
2018-10-10 19:46:56 +00:00
set(USE_DISTRIBUTED OFF)
set(USE_LMDB OFF)
endif()
2018-09-26 15:43:38 +00:00
# ---[ Utils
# TODO: merge the following 3 files into cmake/public/utils.cmake.
include(cmake/Utils.cmake)
include(cmake/public/utils.cmake)
# ---[ Version numbers for generated libraries
2019-05-28 06:41:27 +00:00
set(TORCH_DEFAULT_VERSION "1.1.0")
2018-09-26 15:43:38 +00:00
set(TORCH_BUILD_VERSION "${TORCH_DEFAULT_VERSION}" CACHE STRING "Torch build version")
2019-05-28 06:41:27 +00:00
if (DEFINED ENV{PYTORCH_BUILD_VERSION})
set(TORCH_BUILD_VERSION "$ENV{PYTORCH_BUILD_VERSION}"
CACHE STRING "Torch build version" FORCE)
endif()
2018-09-26 15:43:38 +00:00
if (NOT TORCH_BUILD_VERSION)
# An empty string was specified so force version to the default
set(TORCH_BUILD_VERSION "${TORCH_DEFAULT_VERSION}"
CACHE STRING "Torch build version" FORCE)
endif()
caffe2_parse_version_str(TORCH ${TORCH_BUILD_VERSION})
caffe2_parse_version_str(CAFFE2 ${TORCH_BUILD_VERSION})
2017-09-26 15:45:37 +00:00
# ---[ CMake scripts + modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
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()
2018-05-24 14:47:27 +00:00
# ---[ Build variables set within the cmake tree
include(cmake/BuildVariables.cmake)
set(CAFFE2_WHITELIST "" CACHE STRING "A whitelist file of files that one should build.")
# 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()
2017-12-21 17:13:31 +00:00
# ---[ Misc checks to cope with various compiler modes
include(cmake/MiscCheck.cmake)
2017-04-16 23:39:39 +00:00
# External projects
include(ExternalProject)
2016-12-06 16:39:15 +00:00
# ---[ Dependencies
2019-03-13 10:43:58 +00:00
# ---[ FBGEMM doesn't work on x86 32bit and CMAKE_SYSTEM_PROCESSOR thinks its 64bit
if(USE_FBGEMM AND ((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_SIZEOF_VOID_P EQUAL 4) OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86"))
set(USE_FBGEMM OFF)
endif()
2016-12-06 16:39:15 +00:00
include(cmake/Dependencies.cmake)
2018-12-21 18:32:57 +00:00
if(USE_FBGEMM)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_FBGEMM")
endif()
2019-07-02 18:42:41 +00:00
if(BUILD_NAMEDTENSOR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_NAMEDTENSOR")
2019-05-09 16:05:14 +00:00
endif()
2019-07-08 21:18:00 +00:00
if(USE_QNNPACK)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_QNNPACK")
endif()
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
2018-05-31 04:59:04 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-type-limits")
2018-07-09 21:37:05 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-array-bounds")
2018-05-31 04:59:04 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
2018-06-04 08:01:59 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
2018-06-07 16:10:33 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
2018-06-04 08:01:59 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
2018-06-07 16:10:33 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result")
2018-07-19 21:06:53 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-overflow")
2018-07-09 21:37:05 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing")
2019-06-08 02:05:37 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
2018-08-28 21:21:18 +00:00
if (CMAKE_COMPILER_IS_GNUCXX AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow")
endif()
2018-08-31 20:08:20 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=redundant-decls")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=old-style-cast")
2018-06-26 15:09:25 +00:00
# These flags are not available in GCC-4.8.5. Set only when using clang.
# Compared against https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Option-Summary.html
2018-07-31 22:23:51 +00:00
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
2018-06-26 15:09:25 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-typedef-redefinition")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-aligned-allocation-unavailable")
2018-07-09 22:34:11 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++14-extensions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-constexpr-not-const")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces")
2018-07-31 22:23:51 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
2019-05-24 16:12:27 +00:00
if (${COLORIZE_OUTPUT})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
endif()
2019-05-21 17:26:17 +00:00
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
2019-05-24 16:12:27 +00:00
if (${COLORIZE_OUTPUT})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
2018-06-26 15:09:25 +00:00
endif()
2018-06-12 02:45:40 +00:00
if ((APPLE AND (NOT ("${CLANG_VERSION_STRING}" VERSION_LESS "9.0")))
2018-08-17 01:45:28 +00:00
OR (CMAKE_COMPILER_IS_GNUCXX
2018-07-09 22:34:11 +00:00
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0 AND NOT APPLE)))
2018-06-07 16:10:33 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new")
endif()
2019-01-29 04:51:52 +00:00
if (WERROR)
check_cxx_compiler_flag("-Werror" COMPILER_SUPPORT_WERROR)
if (NOT COMPILER_SUPPORT_WERROR)
set(WERROR FALSE)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
endif(WERROR)
2018-08-31 20:08:20 +00:00
if (NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
endif()
2019-04-01 14:23:06 +00:00
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -O0")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -O0")
2019-04-23 18:03:31 +00:00
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-math-errno")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math")
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
2019-05-17 14:14:53 +00:00
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_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()
2018-05-08 17:24:04 +00:00
# /bigobj increases number of sections in .obj file, which is needed to link
# against libaries in Python 2.7 under Windows
2017-07-26 07:17:19 +00:00
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-05-16 15:10:13 +00:00
if (USE_ASAN)
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} -fsanitize=address")
endif()
2018-05-07 22:26:51 +00:00
2018-08-31 20:08:20 +00:00
if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++14-extensions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-constexpr-not-const")
endif()
2018-10-10 19:46:56 +00:00
if (EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-function-declaration -DEMSCRIPTEN -s DISABLE_EXCEPTION_CATCHING=0")
endif()
2018-08-31 20:08:20 +00:00
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow")
endif()
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
2018-07-31 04:02:13 +00:00
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/aten/src/)
2016-12-12 17:29:00 +00:00
# ---[ Main build
2018-09-24 18:02:46 +00:00
add_subdirectory(c10)
2016-12-05 00:42:00 +00:00
add_subdirectory(caffe2)
2016-12-08 18:23:04 +00:00
2018-05-08 17:24:04 +00:00
# --[ Documentation
2018-01-19 02:44:09 +00:00
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)
2018-08-29 17:02:12 +00:00
endif()
2018-01-19 02:44:09 +00:00
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)
2018-08-29 17:02:12 +00:00
else()
2018-01-19 02:44:09 +00:00
message(FATAL_ERROR "Doxygen needs to be installed to generate the documentation")
2018-08-29 17:02:12 +00:00
endif()
endif()
2018-01-19 02:44:09 +00:00
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
2018-05-24 14:47:27 +00:00
if (USE_CUDA OR USE_ROCM)
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-09-06 16:05:07 +00:00
${PROJECT_SOURCE_DIR}/cmake/public/mkl.cmake
2018-11-08 19:16:33 +00:00
${PROJECT_SOURCE_DIR}/cmake/public/mkldnn.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)
2018-06-08 04:50:30 +00:00
install(DIRECTORY
${PROJECT_SOURCE_DIR}/cmake/Modules_CUDA_fix
DESTINATION share/cmake/Caffe2/
COMPONENT dev)
2019-05-10 16:44:49 +00:00
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-08-31 20:08:20 +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).
2018-08-31 20:08:20 +00:00
if (BUILD_BINARY)
add_subdirectory(binaries)
endif()
2018-03-06 22:45:21 +00:00
2018-03-01 20:01:44 +00:00
include(cmake/Summary.cmake)
caffe2_print_configuration_summary()