forked from chanzuckerberg/shasta
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
144 lines (94 loc) · 4.36 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
cmake_minimum_required(VERSION 3.16)
project(shasta)
# This is the top level cmake file for a Shasta build.
# Before starting a build,
# run shasta/scripts/InstallPrerequisites-Ubuntu.sh
# or shasta/scripts/InstallPrerequisites-macOS.sh
# Use "cmake -D" to modify the options defined below
# in each "option" line. For example, to turn off
# building the dynamic executable use
# cmake -DBUILD_DYNAMIC_EXECUTABLE=OFF
# Figure out if we are on Intel (as opposed to ARM).
set(X86_64 OFF)
if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "x86_64")
set(X86_64 ON)
endif()
# Figure out if we are on macOS.
set(MACOS OFF)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOS ON)
endif()
# Summarize the environment.
message(STATUS "Processor architecture is " ${CMAKE_HOST_SYSTEM_PROCESSOR})
message(STATUS "CMAKE_SYSTEM_NAME is " ${CMAKE_SYSTEM_NAME})
message(STATUS "MACOS is " ${MACOS})
# Decide what we want to build.
if(MACOS)
# For MacOS, only do the static builds.
option(BUILD_STATIC_LIBRARY "Build the static library." ON)
option(BUILD_STATIC_EXECUTABLE "Build the static executable." ON)
option(BUILD_DYNAMIC_LIBRARY "Build the shared library." OFF)
option(BUILD_DYNAMIC_EXECUTABLE "Build the dynamic executable." OFF)
option(BUILD_WITH_HTTP_SERVER "Build with embedded HTTP server for debugging." ON)
else(MACOS)
# For Linux, build everything except the AppImage.
option(BUILD_STATIC_LIBRARY "Build the static library." ON)
option(BUILD_STATIC_EXECUTABLE "Build the static executable." ON)
option(BUILD_DYNAMIC_LIBRARY "Build the shared library." ON)
option(BUILD_DYNAMIC_EXECUTABLE "Build the dynamic executable." OFF)
option(BUILD_WITH_HTTP_SERVER "Build with embedded HTTP server for debugging." ON)
endif(MACOS)
# To build the static executable, we also need the static library.
if(BUILD_STATIC_EXECUTABLE AND NOT BUILD_STATIC_LIBRARY)
set(BUILD_STATIC_LIBRARY ON)
message(STATUS "Turned on BUILD_STATIC_LIBRARY because it is needed for BUILD_STATIC_EXECUTABLE.")
endif(BUILD_STATIC_EXECUTABLE AND NOT BUILD_STATIC_LIBRARY)
# To build the dynamic executable, we also need the dynamic library.
if(BUILD_DYNAMIC_EXECUTABLE AND NOT BUILD_DYNAMIC_LIBRARY)
set(BUILD_DYNAMIC_LIBRARY ON)
message(STATUS "Turned on BUILD_DYNAMIC_LIBRARY because it is needed for BUILD_DYNAMIC_EXECUTABLE.")
endif(BUILD_DYNAMIC_EXECUTABLE AND NOT BUILD_DYNAMIC_LIBRARY)
# Write out what we will actually build.
message(STATUS "BUILD_STATIC_LIBRARY is " ${BUILD_STATIC_LIBRARY})
message(STATUS "BUILD_STATIC_EXECUTABLE is " ${BUILD_STATIC_EXECUTABLE})
message(STATUS "BUILD_DYNAMIC_LIBRARY is " ${BUILD_DYNAMIC_LIBRARY})
message(STATUS "BUILD_DYNAMIC_EXECUTABLE is " ${BUILD_DYNAMIC_EXECUTABLE})
# Option to build with -march=native.
option(BUILD_NATIVE "Build with -march=native." OFF)
message(STATUS "BUILD_NATIVE is " ${BUILD_NATIVE})
# Option to request a debug build.
option(BUILD_DEBUG "Make a debuggable build." OFF)
message(STATUS "BUILD_DEBUG is " ${BUILD_DEBUG})
# The BUILD_ID can be specified to identify the build
# This is normally used only when building a new GitHub release,
# in which case we use the following option when running Cmake:
# -DBUILD_ID="Shasta Release X.Y.Z"
# BUILD_ID should not contain a comma, otherwise the C preprocessor does not handle it correctly.
if(NOT DEFINED BUILD_ID)
set(BUILD_ID "Shasta development build. This is not a released version.")
endif(NOT DEFINED BUILD_ID)
message(STATUS "BUILD_ID is: " ${BUILD_ID})
# Add the subdirectories we need.
if(BUILD_STATIC_LIBRARY)
add_subdirectory(staticLibrary)
endif(BUILD_STATIC_LIBRARY)
if(BUILD_STATIC_EXECUTABLE)
add_subdirectory(staticExecutable)
endif(BUILD_STATIC_EXECUTABLE)
if(BUILD_DYNAMIC_LIBRARY)
add_subdirectory(dynamicLibrary)
endif(BUILD_DYNAMIC_LIBRARY)
if(BUILD_DYNAMIC_EXECUTABLE)
add_subdirectory(dynamicExecutable)
endif(BUILD_DYNAMIC_EXECUTABLE)
# Install to the shasta-install directory.
set(CMAKE_INSTALL_PREFIX .)
# Install the scripts.
file(GLOB SCRIPTS scripts/*.py scripts/*.sh)
install(PROGRAMS ${SCRIPTS} DESTINATION shasta-install/bin)
# Install the configuration files.
install(DIRECTORY conf DESTINATION shasta-install USE_SOURCE_PERMISSIONS)
# Install the docs directory.
install(DIRECTORY docs DESTINATION shasta-install)
# The targets built in each subdirectory are
# installed by the cmake file of each subdirectory.