CMakeLists.txt 11.8 KB
Newer Older
1
2
# Let's use at least v3.1 for sanity's sake.
cmake_minimum_required(VERSION 3.1)
Olivier Richard's avatar
Olivier Richard committed
3

4
5
project("Batsim")

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Enable C++11
# Let's check that the used compiler handles c++11 correctly
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.1")
        message(FATAL_ERROR "Insufficient gcc version: 4.8.1 is needed to support C++11")
    elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5")
        message(WARNING "Old gcc version found: Using version 5 or greater is recommended")
    endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.3")
        message(FATAL_ERROR "Insufficient clang version: 3.3 is needed to support C++11")
    elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.4")
        message(WARNING "Old clang version found: Using version 3.4 or greater is recommended")
    endif()
else()
    message(WARNING "Unknown compiler. Make sure it fully supports C++11.")
endif()

# Let's enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Millian Poquet's avatar
Millian Poquet committed
28
29
30
31
# Options
option(enable_warnings "Enable compilation warnings" ON)
option(treat_warnings_as_errors "Treat compilation warnings as compilation errors" OFF)
option(ignore_assertions "Ignore assertions, which could make the simulation unstable, but could improve its performance" OFF)
Olivier Richard's avatar
Olivier Richard committed
32

33
34
35
36
37
38
39
40
41
42
# Build type
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to 'Debug' as none was specified.")
  set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
    "MinSizeRel" "RelWithDebInfo")
endif()

Millian Poquet's avatar
Millian Poquet committed
43
44
45
################
# Dependencies #
################
46
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
47

48
49
50
## SimGrid dependency
find_package(SimGrid REQUIRED)
include_directories(${SIMGRID_INCLUDE_DIR})
Millian Poquet's avatar
Millian Poquet committed
51

52
## Boost dependency
53
find_package(Boost 1.58 REQUIRED COMPONENTS system filesystem regex locale)
54
55
include_directories(${Boost_INCLUDE_DIR})

56
57
58
59
## GMP
find_package(GMP REQUIRED)
include_directories(${GMP_INCLUDE_DIR})

60
61
62
63
## Rapidjson dependency
find_package(rapidjson REQUIRED)
include_directories(${RAPIDJSON_INCLUDE_DIRS})

64
65
66
67
## OpenSSL dependency
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})

68
69
70
71
72
73
74
75
76
77
78
## Redox dependency
find_package(redox REQUIRED)
include_directories(${REDOX_INCLUDE_DIR})

## Redox sub dependencies
find_package(hiredis REQUIRED)
include_directories(${HIREDIS_INCLUDE_DIRS})

find_package(libev REQUIRED)
include_directories(${LIBEV_INCLUDE_DIRS})

79
80
81
82
# ZeroMQ dependency
find_package(ZMQ REQUIRED)
include_directories(${ZMQ_INCLUDE_DIRS})

83
84
85
##################
# Batsim version #
##################
86
set(default_batsim_version "v1.4.0")
87
88
89
90
91
92
93
94
95
96
97
98
99
include(GetGitRevisionDescription)
git_describe(batsim_version)
message(STATUS "Batsim version from git: ${batsim_version}")

if(NOT((${batsim_version} STREQUAL "GIT-NOTFOUND") OR
       (${batsim_version} STREQUAL "HEAD-HASH-NOTFOUND")))
    add_definitions(-DBATSIM_VERSION=${batsim_version})
else()
    message(WARNING "Cannot retrieve Batsim version from git. "
                    "Using default version ${default_batsim_version}")
    add_definitions(-DBATSIM_VERSION=${default_batsim_version})
endif()

Millian Poquet's avatar
Millian Poquet committed
100
101
102
################
# Source files #
################
Olivier Richard's avatar
Olivier Richard committed
103
104

## Batsim
105
106
file(GLOB batsim_SRC
    "src/*.hpp"
107
108
    "src/*.cpp"
    "src/pugixml-1.7/*.hpp"
109
110
    "src/pugixml-1.7/*.cpp"
    "src/docopt/*.cpp"
111
112
113
    "src/docopt/*.h"
    "src/unittest/*.hpp"
    "src/unittest/*.cpp")
114
115

# Executables
116
add_executable(batsim ${batsim_SRC})
Olivier Richard's avatar
Olivier Richard committed
117

118
# Libraries to link
119
120
target_link_libraries(batsim
                      ${HAVE_SIMGRID_LIB}
121
                      ${GMP_LIBRARIES}
122
                      ${Boost_FILESYSTEM_LIBRARY_DEBUG}
123
                      ${Boost_LOCALE_LIBRARY_DEBUG}
Millian Poquet's avatar
Millian Poquet committed
124
                      ${Boost_REGEX_LIBRARY_DEBUG}
125
                      ${Boost_SYSTEM_LIBRARY_DEBUG}
126
                      ${OPENSSL_LIBRARIES}
127
128
                      ${REDOX_LIBRARY}
                      ${LIBEV_LIBRARY}
129
130
                      ${HIREDIS_LIBRARY}
                      ${ZMQ_LIBRARIES})
Olivier Richard's avatar
Olivier Richard committed
131

Millian Poquet's avatar
Millian Poquet committed
132
133
134
135
136
################
# Installation #
################
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/batsim
        DESTINATION bin)
137

Millian Poquet's avatar
Millian Poquet committed
138
139
# Let's enable warnings if needed
if (enable_warnings)
140
    set(warning_flags " -Wall -Wextra")
Millian Poquet's avatar
Millian Poquet committed
141
142

    if (treat_warnings_as_errors)
143
        set(warning_flags "${warning_flags} -Werror")
Millian Poquet's avatar
Millian Poquet committed
144
145
146
    endif()

    if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
147
        set_property(TARGET batsim APPEND_STRING PROPERTY COMPILE_FLAGS ${warning_flags})
Millian Poquet's avatar
Millian Poquet committed
148
    elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
149
        set_property(TARGET batsim APPEND_STRING PROPERTY COMPILE_FLAGS ${warning_flags})
Millian Poquet's avatar
Millian Poquet committed
150
151
    else()
        message(WARNING "Unknown compiler. Warnings should not be enabled correctly.")
152
        set_property(TARGET batsim APPEND_STRING PROPERTY COMPILE_FLAGS ${warning_flags})
Millian Poquet's avatar
Millian Poquet committed
153
154
155
    endif()
endif()

156
# Let's ignore assertions if needed (might improve performance but can be dangerous)
Millian Poquet's avatar
Millian Poquet committed
157
158
if (ignore_assertions)
    target_compile_definitions(batsim PRIVATE NDEBUG)
159
endif()
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178

###########
# Testing #
###########
enable_testing()

# Execution scripts tests
add_test(exec1_tiny
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_one_instance.py
         ${CMAKE_SOURCE_DIR}/tools/experiments/instance_examples/pybatsim_filler_tiny.yaml
         -od /tmp/batsim_tools_tests/exec1/out/instance_examples/pftiny
         -wd ${CMAKE_SOURCE_DIR})

add_test(exec1_medium
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_one_instance.py
         ${CMAKE_SOURCE_DIR}/tools/experiments/instance_examples/pybatsim_filler_medium.yaml
         -od /tmp/batsim_tools_tests/exec1/out/instance_examples/pfmedium
         -wd ${CMAKE_SOURCE_DIR})

179
add_test(execN
180
181
182
183
184
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/tools/experiments/instances_examples/pyfiller_tiny_medium_mixed.yaml
         -bod /tmp/batsim_tools_tests/execN
         -bwd ${CMAKE_SOURCE_DIR})

185
add_test(execN_np2
186
187
188
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_no_energy.yaml
         -bwd ${CMAKE_SOURCE_DIR}
189
190
         -bod /tmp/batsim_tools_tests/execN_np2
         --nb_workers_per_host 2)
191

192
add_test(execN_np4
193
194
195
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_no_energy.yaml
         -bwd ${CMAKE_SOURCE_DIR}
196
197
         -bod /tmp/batsim_tools_tests/execN_np4
         --nb_workers_per_host 4)
198

199
add_test(execN_np4_remote
200
201
202
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_no_energy.yaml
         -bwd ${CMAKE_SOURCE_DIR}
203
         -bod /tmp/batsim_tools_tests/execN_np4_remote
204
205
206
207
208
209
210
         --mpi_hostfile ${CMAKE_SOURCE_DIR}/test/mpi_hostfile_localhost
         --nb_workers_per_host 4)

# Batsim tests
add_test(no_energy
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_no_energy.yaml
Millian Poquet's avatar
Millian Poquet committed
211
         -bod /tmp/batsim_tests/no_energy
212
213
214
215
216
         -bwd ${CMAKE_SOURCE_DIR})

add_test(energy
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_energy.yaml
Millian Poquet's avatar
Millian Poquet committed
217
         -bod /tmp/batsim_tests/energy
218
219
220
221
222
         -bwd ${CMAKE_SOURCE_DIR})

add_test(walltime
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_walltime.yaml
Millian Poquet's avatar
Millian Poquet committed
223
         -bod /tmp/batsim_tests/walltime
224
225
226
227
228
         -bwd ${CMAKE_SOURCE_DIR})

add_test(long_simulation_time
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_long_simulation_time.yaml
Millian Poquet's avatar
Millian Poquet committed
229
         -bod /tmp/batsim_tests/long_simulation_time
230
231
         -bwd ${CMAKE_SOURCE_DIR})

232
add_test(time_sharing
233
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
234
235
         ${CMAKE_SOURCE_DIR}/test/test_time_sharing.yaml
         -bod /tmp/batsim_tests/time_sharing
236
237
238
239
240
         -bwd ${CMAKE_SOURCE_DIR})

add_test(smpi
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_smpi.yaml
Millian Poquet's avatar
Millian Poquet committed
241
         -bod /tmp/batsim_tests/smpi
242
243
         -bwd ${CMAKE_SOURCE_DIR})

244
245
246
247
248
249
add_test(smpi_mapping
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_smpi_mapping.yaml
         -bod /tmp/batsim_tests/smpi_mapping
         -bwd ${CMAKE_SOURCE_DIR})

250
251
252
253
254
255
add_test(smpi_batexec
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_smpi_batexec.yaml
         -bod /tmp/batsim_tests/smpi_batexec
         -bwd ${CMAKE_SOURCE_DIR})

256
257
258
add_test(batexec
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_batexec.yaml
Millian Poquet's avatar
Millian Poquet committed
259
         -bod /tmp/batsim_tests/batexec
260
261
         -bwd ${CMAKE_SOURCE_DIR})

Millian Poquet's avatar
Millian Poquet committed
262
263
264
265
266
267
add_test(reject
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_reject.yaml
         -bod /tmp/batsim_tests/reject
         -bwd ${CMAKE_SOURCE_DIR})

Millian Poquet's avatar
Millian Poquet committed
268
269
270
271
272
273
add_test(pfs0
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_pfs0.yaml
         -bod /tmp/batsim_tests/pfs0
         -bwd ${CMAKE_SOURCE_DIR})

274
275
276
277
278
add_test(same_submit_time
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_same_submit_time.yaml
         -bod /tmp/batsim_tests/same_submit_time
         -bwd ${CMAKE_SOURCE_DIR})
279

280
281
282
283
284
285
add_test(sequence_delay
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_sequence_delay.yaml
         -bod /tmp/batsim_tests/sequence_delay
         -bwd ${CMAKE_SOURCE_DIR})

286
add_test(redis_enabled
287
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
288
289
290
291
292
293
294
295
         ${CMAKE_SOURCE_DIR}/test/test_redis_enabled.yaml
         -bod /tmp/batsim_tests/redis_enabled
         -bwd ${CMAKE_SOURCE_DIR})

add_test(redis_disabled
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_redis_disabled.yaml
         -bod /tmp/batsim_tests/redis_disabled
296
297
298
299
300
301
         -bwd ${CMAKE_SOURCE_DIR})

add_test(dynamic_submit
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_dynamic_submit.yaml
         -bod /tmp/batsim_tests/dynamic_submit
302
303
         -bwd ${CMAKE_SOURCE_DIR}
         --nb_workers_per_host 2)
304

305
306
307
308
309
310
add_test(kill
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_kill.yaml
         -bod /tmp/batsim_tests/kill
         -bwd ${CMAKE_SOURCE_DIR})

311
312
313
314
315
316
add_test(kill_multiple
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_kill_multiple.yaml
         -bod /tmp/batsim_tests/kill_multiple
         -bwd ${CMAKE_SOURCE_DIR})

317
318
319
320
321
322
add_test(kill_progress
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_kill_progress.yaml
         -bod /tmp/batsim_tests/kill_progress
         -bwd ${CMAKE_SOURCE_DIR})

323
324
325
326
327
add_test(pybatsim_tests
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/pybatsim_tests.yaml
         -bod /tmp/pybatsim_tests
         -bwd ${CMAKE_SOURCE_DIR})
328
329
330
331

add_test(fewer_resources
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_fewer_resources.yaml
332
333
334
335
336
337
338
         -bod /tmp/batsim_tests/fewer_resources
         -bwd ${CMAKE_SOURCE_DIR})

add_test(set_job_metadata
         ${CMAKE_SOURCE_DIR}/tools/experiments/execute_instances.py
         ${CMAKE_SOURCE_DIR}/test/test_set_job_metadata.yaml
         -bod /tmp/batsim_tests/set_job_metadata
339
         -bwd ${CMAKE_SOURCE_DIR})