forked from bisegni/chaosframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
243 lines (206 loc) · 8.02 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
cmake_minimum_required(VERSION 2.8)
include(config/CMakeChaos.txt)
project(chaosframework)
include(ExternalProject)
#include(CTest)
#enable_testing()
#find git
find_package(Git REQUIRED)
#clear var
unset(CMAKE_CXX_COMPILER_WORKS CACHE)
unset(CMAKE_CXX_COMPILER_WORKS)
#specify option
option(USE_GPT "Uses Google Performance tool to perform analisys" OFF)
option(CLING_VIRTUAL_MACHINE_ENABLE "Enable cling for scripting" OFF)
option(CHAOS_ONLY_DEPENDECY "Download all the dependency" OFF)
option(CHAOS_ARCHITECTURE_TEST "Architecture tests" OFF)
option(CHAOS_CDS "Chaos Data Service" ON)
option(CHAOS_MDS "Chaos MetaData Service" ON)
option(CHAOS_AGENT "Chaos Agent Service" ON)
option(CHAOS_DATA_EXPORT "Chaos Data Export" ON)
option(CHAOS_EXAMPLES "Chaos Examples" ON)
option(CHAOS_CCS "Chaos CCS Compile needs qt5.6-static-x86_64 installed" OFF)
if(NOT QMAKE_PATH)
set(QMAKE_PATH /usr/local/chaos/qt-56/bin)
ENDIF()
EXECUTE_PROCESS(
COMMAND ./version.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/chaos/common/
RESULT_VARIABLE err
OUTPUT_VARIABLE out
)
if(err)
ERROR("CANNOT generate ${CMAKE_CURRENT_LIST_DIR}/chaos/common/version.h: ${out}")
ELSE()
MESG("created version.h")
ENDIF()
###### Required Libraries
CheckConfigureBuild(jsoncpp jsoncpp "-DJSONCPP_WITH_TESTS=OFF;-DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF" https://github.com/bisegni )
CheckConfigureBuild(mongoclient mongo-cxx-driver:legacy-1.0.0-rc0 "--extralib=boost_system;--disable-warnings-as-errors;install-mongoclient" https://github.com/mongodb)
#########
#IF(CHAOS_ARCHITECTURE_TEST)
# SET (CMAKE_BUILD_TYPE Debug)
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fprofile-arcs -ftest-coverage")
# set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
#ENDIF()
IF (CHAOS_ONLY_DEPENDECY OR
CHAOS_ARCHITECTURE_TEST)
#google test
MESG("Add google Test as external project")
ExternalProject_Add(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.0
PREFIX "${CMAKE_BINARY_DIR}/ext_dep/googletest-prefix"
SOURCE_DIR "${CMAKE_BINARY_DIR}/ext_dep/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/ext_dep/googletest-build"
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON)
# Specify include dir
ExternalProject_Get_Property(googletest source_dir)
set(GTEST_INCLUDE_DIR ${source_dir}/include)
# Library
ExternalProject_Get_Property(googletest binary_dir)
set(GTEST_LIBRARY_DIR ${binary_dir})
ExternalProject_Get_Property(googletest binary_dir)
set(GTEST_LIBRARY_PATH ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
MESG("${GTEST_INCLUDE_DIR}")
MESG("${GTEST_LIBRARY_DIR}")
MESG("${GTEST_LIBRARY_PATH}")
MESG("${GTEST_LIBRARY}")
ENDIF()
IF (USE_GPT)
#google performance tools
MESG("Add Google Performance Tools as external project")
ExternalProject_Add(
google_pt
GIT_REPOSITORY https://github.com/gperftools/gperftools.git
GIT_TAG master
PREFIX "${CMAKE_BINARY_DIR}/ext_dep/gpt-prefix"
SOURCE_DIR "${CMAKE_BINARY_DIR}/ext_dep/gpt-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/ext_dep/gpt-src"
CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/ext_dep/gpt-src/./autogen.sh COMMAND ${CMAKE_BINARY_DIR}/ext_dep/gpt-src/./configure --prefix=${CMAKE_INSTALL_PREFIX}
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON)
# Specify include dir
ExternalProject_Get_Property(google_pt source_dir)
set(GPT_INCLUDE_DIR ${google_pt_sdir}/include)
# Library
ExternalProject_Get_Property(google_pt binary_dir)
set(GPT_LIBRARY_DIR ${google_pt_bdir})
MESG("${GPT_INCLUDE_DIR}")
MESG("${GPT_LIBRARY_DIR}")
ENDIF()
SET( ${PROJECT_NAME}_MAJOR_VERSION 0 )
SET( ${PROJECT_NAME}_MINOR_VERSION 1 )
SET( ${PROJECT_NAME}_PATCH_LEVEL 0 )
# ADD_DEFINITIONS(-Wno-ignored-attributes)
INCLUDE_DIRECTORIES(. ../ ../../ ${CMAKE_INSTALL_PREFIX}/include)
LINK_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/lib)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
if(NOT CHAOS_ONLY_DEPENDECY)
MESG("Configure Common Layer")
ADD_SUBDIRECTORY(chaos/common)
MESG("Configure CUToolkit Layer")
ADD_SUBDIRECTORY(chaos/cu_toolkit)
MESG("Configure Chaos Metadata Service Client Library")
ADD_SUBDIRECTORY(chaos_metadata_service_client)
MESG("Configure Chaos Micro Unit Toolkit")
ADD_SUBDIRECTORY(chaos_micro_unit_toolkit)
endif()
IF (CHAOS_AGENT AND NOT CHAOS_ONLY_DEPENDECY)
MESG("Configure Chaos Agent Service")
ADD_SUBDIRECTORY(ChaosAgent)
ENDIF()
IF (CHAOS_MDS AND
NOT CHAOS_ONLY_DEPENDECY)
# IF("${CMAKE_CXX_COMPILE_FEATURES}" MATCHES "cxx_std_11")
MESG("Configure Chaos Data Service")
ADD_SUBDIRECTORY(ChaosMetadataService)
# ELSE()
# WARN("Chaos Data Service require a c11 compliant compiler")
# ENDIF()
ENDIF()
IF(NOT CHAOS_ONLY_DEPENDECY)
MESG("Configure Chaos Metadata Service Client Library Test Application")
ADD_SUBDIRECTORY(ChaosMetadataServiceClientTest)
IF (CHAOS_DATA_EXPORT)
MESG("Configure Chaos Data Export ")
ADD_SUBDIRECTORY(ChaosDataExport)
ENDIF()
IF(CHAOS_EXAMPLES)
MESG("Configure Chaos ChaosMDSCmd")
ADD_SUBDIRECTORY(example/ChaosMDSCmd)
ENDIF()
ENDIF()
IF (CHAOS_ARCHITECTURE_TEST)
#scan all subdirectory of test directory
MESG("Configure infrastructure tests")
set_directory_properties(PROPERTIES GTEST_INCLUDE_DIR ${GTEST_INCLUDE_DIR}
GTEST_LIBRARY_DIR ${GTEST_LIBRARY_DIR}
GTEST_LIBRARY_PATH ${GTEST_LIBRARY_PATH})
ADD_SUBDIRECTORY(CHAOSFrameworkTests/FrameworkTest)
# SET(CHAOS_TEST_DIRECTORY "CHAOSFrameworkTests")
# SUBDIRLIST(TEST_SUBDIRS ${CHAOS_TEST_DIRECTORY})
# FOREACH(_TEST_DIRECTORY ${TEST_SUBDIRS})
# IF(EXISTS "${_TEST_DIRECTORY}/CMakeLists.txt")
# #set the external project variable in subdirectory
# get_filename_component(_TEST_DIR_NAME ${_TEST_DIRECTORY} NAME)
# MESG("Configure ${_TEST_DIR_NAME} test")
# ADD_SUBDIRECTORY(${_TEST_DIRECTORY})
# ENDIF()
# ENDFOREACH()
ENDIF()
MESG("Done")
if( NOT ${CMAKE_INSTALL_PREFIX} MATCHES ${CMAKE_CURRENT_SOURCE_DIR}/usr/local)
IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/usr/local" )
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/usr)
MESG("linking ${CMAKE_INSTALL_PREFIX} ${CMAKE_CURRENT_SOURCE_DIR}/usr/local")
execute_process(
COMMAND ln -sf ${CMAKE_INSTALL_PREFIX} ${CMAKE_CURRENT_SOURCE_DIR}/usr/local
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE err
OUTPUT_VARIABLE out
)
IF(err)
ERROR("cannot create symlink ${CMAKE_INSTALL_PREFIX} ${CMAKE_CURRENT_SOURCE_DIR}/usr/local")
ELSE()
MESG("created symlink ${CMAKE_INSTALL_PREFIX}->${CMAKE_CURRENT_SOURCE_DIR}/usr/local")
ENDIF()
ENDIF()
ENDIF()
IF(CHAOS_CCS)
MESG("CCS compilation ENABLED.")
IF(EXISTS "${QMAKE_PATH}/qmake")
MESG("Found 'qmake' in ${QMAKE_PATH}")
execute_process(
COMMAND ${QMAKE_PATH}/qmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ccs
RESULT_VARIABLE err
OUTPUT_VARIABLE out
)
if( err)
ERROR("error generating QT stubs error: ${out}")
endif()
add_custom_target(ccs
COMMAND make -j ${PROCESSOR_COUNT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ccs
DEPENDS chaos_common
COMMENT "compiling CCS"
)
ELSE()
ERROR("missing ${QMAKE_PATH}/qmake")
ENDIF()
ENDIF()
IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ccs/ccs)
MESG("copying ccs to ${CMAKE_INSTALL_PREFIX}/bin")
FILE(GLOB exe ${CMAKE_CURRENT_SOURCE_DIR}/ccs/ccs.sh ${CMAKE_CURRENT_SOURCE_DIR}/ccs/ccs)
FILE(COPY ${exe} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
ENDIF()
INSTALL(DIRECTORY tools DESTINATION ${CMAKE_INSTALL_PREFIX} PATTERN "*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)
#add test