-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
56 lines (49 loc) · 2.81 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
# MIT License
#
# Copyright (c) 2022 Erik Nikko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.10)
project(TDDD95)
enable_testing()
# Force to specify standard so that compile commands are correct
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_CXX_STANDARD 17)
set(KATTIS_CXX_FLAGS "-g -O2")
set(CXX_WARNING_FLAGS "-Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast")
set(CXX_SANITISER_FLAGS "-fno-omit-frame-pointer -fsanitize=signed-integer-overflow -fsanitize=undefined -fsanitize=bounds -fsanitize=float-divide-by-zero -fsanitize=integer-divide-by-zero -fsanitize=pointer-overflow")
set(CMAKE_CXX_FLAGS_DEBUG "${KATTIS_CXX_FLAGS} ${CXX_WARNING_FLAGS} ${CXX_SANITISER_FLAGS}")
set(CMAKE_CXX_FLAGS "${KATTIS_CXX_FLAGS} ${CXX_WARNING_FLAGS}")
include_directories(src/include)
function(add_lr_test PROBLEM)
add_test(
NAME ${PROBLEM}_local
COMMAND ${CMAKE_SOURCE_DIR}/bin/run_tests ${CMAKE_BINARY_DIR}/${PROBLEM} ${CMAKE_SOURCE_DIR}/src/problems/${PROBLEM}/tests/ ${CMAKE_BINARY_DIR}/Testing/Passed ${PROBLEM}_local)
add_test(
NAME ${PROBLEM}_remote
COMMAND ${CMAKE_SOURCE_DIR}/bin/make_delivery ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/Testing/Passed ${PROBLEM} ${PROBLEM}_remote)
set_tests_properties(${PROBLEM}_local PROPERTIES FIXTURES_SETUP ${PROBLEM}_local_passed)
set_tests_properties(${PROBLEM}_remote PROPERTIES FIXTURES_REQUIRED ${PROBLEM}_local_passed)
endfunction()
function(add_problem PROBLEM)
add_executable(${PROBLEM} "src/problems/${PROBLEM}/${PROBLEM}.cpp")
add_lr_test(${PROBLEM})
endfunction()