-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
151 lines (130 loc) · 6.63 KB
/
Copy pathCMakeLists.txt
File metadata and controls
151 lines (130 loc) · 6.63 KB
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
# --------------------------------------------------------------------------- #
# Main CMake file for SMS++ system tests #
# #
# This file allows one to build the tests using CMake. #
# Tests that should be supported by ctest executable must be added #
# with the add_test() command. #
# To do so, you can use the following commands: #
# #
# $ cmake -S <source-path> -B <build-path> #
# $ cmake --build <build-path> #
# #
# Donato Meoli #
# Dipartimento di Informatica #
# Universita' di Pisa #
# --------------------------------------------------------------------------- #
cmake_minimum_required(VERSION 3.21)
cmake_policy(VERSION 3.15)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DeriveVersion.cmake)
smspp_derive_version(SMSPP_MODULE_VERSION)
project(SMS++_tests
VERSION ${SMSPP_MODULE_VERSION}
DESCRIPTION "SMS++ tests"
HOMEPAGE_URL https://gitlab.com/smspp/tests
LANGUAGES C CXX)
# Find out if it's being called by the umbrella.
get_directory_property(hasParent PARENT_DIRECTORY)
# This adds the cmake directory to the module search paths,
# allowing us to use our modules.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# The per-module CI test-label map and the smspp_label_tests() helper that each
# test directory calls to tag its tests (see cmake/TestLabels.cmake).
include(TestLabels)
# Utility function to standardize installation and runtime dependency handling
# for SMS++ tests.
function(smspp_install target_name)
if (WIN32 AND BUILD_SHARED_LIBS AND NOT DEFINED ENV{CONDA_BUILD})
# On Windows with shared libraries enabled copies all runtime DLL
# dependencies next to the executable in the build directory
# (POST_BUILD), using CMake's TARGET_RUNTIME_DLLS generator expression
add_custom_command(TARGET ${target_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:${target_name}>
$<TARGET_FILE_DIR:${target_name}>
COMMAND_EXPAND_LISTS
COMMENT "Copying runtime DLLs next to ${target_name}.exe")
endif ()
#[[install(TARGETS ${target_name}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})]]
endfunction()
# Register a batch file as a ctest driving the given executable: every suite
# runs its batteries this way, each of them being a family of instances that
# the tester cross-checks all the Solver of its BlockSolverConfig on, so that
# they are independent and can be run, selected and timed one by one.
#
# A battery that the Solver of one tester do not cover alone runs every other
# tester that applies to its instances as well: those are named here after the
# first one and reach the battery as the arguments after it, in the order they
# are given and each of them only if it is in the build, an empty argument
# standing for the one that is not, which the battery then leaves out.
function(add_batch_test exe batch)
set(_others "")
foreach (_t IN LISTS ARGN)
if (TARGET ${_t})
# a generator expression, since a tester of another suite or of a
# module is built in another directory of the tree
list(APPEND _others "$<TARGET_FILE:${_t}>")
else ()
list(APPEND _others "")
endif ()
endforeach ()
if (UNIX)
add_test(NAME ${exe}/${batch}
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/${batch}
${CMAKE_CURRENT_BINARY_DIR}/${exe} ${_others}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
elseif (WIN32)
add_test(NAME ${exe}/${batch}
# using Git for Windows that includes Git Bash
COMMAND "C:/Program Files/Git/bin/bash.exe"
"${CMAKE_CURRENT_SOURCE_DIR}/${batch}"
"$<TARGET_FILE:${exe}>" ${_others}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif ()
endfunction()
# ----- Settings ------------------------------------------------------------ #
# This creates an ENABLE_TESTING option (default: ON) and enables the testing
# using the ctest executable.
# See: https://cmake.org/cmake/help/latest/manual/ctest.1.html
include(CTest)
# The classes of the modules register themselves in the factories from
# static objects, which nothing here names: a shared library is kept by
# what its module asks of the linker [see the CMakeLists.txt of the
# module], while an archive has to be taken whole.
if (NOT BUILD_SHARED_LIBS)
if (MSVC)
add_link_options("/WHOLEARCHIVE" "/FORCE:MULTIPLE")
else () # Unix
if (APPLE)
add_link_options("-Wl,-all_load")
else ()
add_link_options("-Wl,--whole-archive,--allow-multiple-definition")
endif ()
endif ()
endif ()
# ----- Tests --------------------------------------------------------------- #
# One directory per module the tests are posed on, named after it, since a
# suite here is what a module cannot test by itself: what it needs is either
# the cross-check machinery of common_utils or a module that is not one of its
# dependencies. The testers of the objects of the core library are therefore
# grouped under SMS++, those of a Block under the name of its module.
add_subdirectory(SMS++)
add_subdirectory(MILPSolver)
add_subdirectory(MCFBlock)
add_subdirectory(BinaryKnapsackBlock)
# before the suites whose batteries run its tester of the scenario reduction,
# which has to be a target when they are configured [see add_batch_test()]
add_subdirectory(TwoStageStochasticBlock)
add_subdirectory(CapacitatedFacilityLocationBlock)
add_subdirectory(MMCFBlock)
add_subdirectory(UCBlock)
add_subdirectory(InvestmentBlock)
add_subdirectory(MultiStageStochasticBlock)
add_subdirectory(LukFiBlock)
add_subdirectory(SVMBlock)
add_subdirectory(SingleFlowDCRBlock)
add_subdirectory(SATBlock)
# the one tester that is posed on no Block in particular: it reads whichever
# two the configurations name and compares the two formulations
add_subdirectory(compare_formulations)
# --------------------------------------------------------------------------- #