forked from xjqbest/gloo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
106 lines (88 loc) · 3.34 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
project(gloo CXX C)
set(GLOO_VERSION_MAJOR 0)
set(GLOO_VERSION_MINOR 5)
set(GLOO_VERSION_PATCH 0)
set(GLOO_VERSION
"${GLOO_VERSION_MAJOR}.${GLOO_VERSION_MINOR}.${GLOO_VERSION_PATCH}")
# Gloo assumes 64-bit and doesn't run builds/tests for anything else.
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
message(FATAL_ERROR "Gloo can only be built on 64-bit systems.")
endif()
# Local CMake modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
# Build target options
option(BUILD_TEST "Build test binary (requires gtest)" OFF)
option(BUILD_BENCHMARK "Build benchmark binary (requires hiredis)" OFF)
# Option defaults (so they can be overwritten before declaring the option)
set(USE_REDIS_DEFAULT OFF)
set(USE_IBVERBS_DEFAULT OFF)
set(USE_NCCL_DEFAULT OFF)
set(USE_RCCL_DEFAULT OFF)
set(USE_LIBUV_DEFAULT OFF)
# Options
option(USE_REDIS "Support using Redis for rendezvous" ${USE_REDIS_DEFAULT})
option(USE_IBVERBS "Support ibverbs transport" ${USE_IBVERBS_DEFAULT})
option(USE_NCCL "Support using NCCL for local collectives" ${USE_NCCL_DEFAULT})
option(USE_RCCL "Support using RCCL for local collectives" ${USE_RCCL_DEFAULT})
option(USE_LIBUV "Build libuv transport" ${USE_LIBUV_DEFAULT})
# Set default build type
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Build type not set -- defaulting to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
# Use CMAKE_<LANG>_COMPILER_LAUNCHER if available.
find_program(SCCACHE_EXECUTABLE sccache)
mark_as_advanced(SCCACHE_EXECUTABLE)
if(SCCACHE_EXECUTABLE)
foreach(LANG CXX C)
if(NOT DEFINED CMAKE_${LANG}_COMPILER_LAUNCHER AND NOT CMAKE_${LANG}_COMPILER MATCHES ".*/s?ccache$")
message(STATUS "Enabling sccache for ${LANG}")
set(CMAKE_${LANG}_COMPILER_LAUNCHER ${SCCACHE_EXECUTABLE} CACHE STRING "")
endif()
endforeach()
endif()
# Define sanitizer option, if specified.
if(SANITIZE)
add_definitions("-fsanitize=${SANITIZE}")
add_definitions("-fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${SANITIZE}")
endif()
# Add install targets by default (override from parent project)
set(GLOO_INSTALL ON CACHE BOOL "")
mark_as_advanced(GLOO_INSTALL)
# Build shared or static libraries (override from parent project)
if(BUILD_SHARED_LIBS)
set(GLOO_STATIC_OR_SHARED SHARED CACHE STRING "")
else()
set(GLOO_STATIC_OR_SHARED STATIC CACHE STRING "")
endif()
mark_as_advanced(GLOO_STATIC_OR_SHARED)
# Process dependencies
include(cmake/Dependencies.cmake)
# Use project root as default include directory
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_BINARY_DIR})
# Compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
# Recurse into main project directory
add_subdirectory(gloo)
# Finally, create the cmake configuration files.
configure_file(
${PROJECT_SOURCE_DIR}/cmake/GlooConfigVersion.cmake.in
${PROJECT_BINARY_DIR}/cmake/GlooConfigVersion.cmake
@ONLY)
configure_file(
${PROJECT_SOURCE_DIR}/cmake/GlooConfig.cmake.in
${PROJECT_BINARY_DIR}/cmake/GlooConfig.cmake
@ONLY)
if(GLOO_INSTALL)
install(FILES
${PROJECT_BINARY_DIR}/cmake/GlooConfig.cmake
${PROJECT_BINARY_DIR}/cmake/GlooConfigVersion.cmake
DESTINATION share/cmake/Gloo
COMPONENT dev)
install(EXPORT GlooTargets DESTINATION share/cmake/Gloo
FILE GlooTargets.cmake
COMPONENT dev)
endif()