-
Notifications
You must be signed in to change notification settings - Fork 4
/
ctest_osm2go.cmake
165 lines (140 loc) · 4.28 KB
/
ctest_osm2go.cmake
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
##
## OSM2go CTest script
##
## This will run a Nightly build on OSM2go
##
##
## What you need:
##
## All platforms:
## -cmake >= 3.8
## -git command line client
## -all the other stuff needed to build OSM2go like CURL, libXML2, compiler, ...
##
##
## How to setup:
##
## Write to a file my_osm2go.cmake:
##
## ######### begin file
## # the binary directory does not need to exist (but it's parent)
## # it will be deleted before use
## set(OSM2GO_BUILD_DIR "my/path/to/the/build/dir")
##
## # if you don't want to run a Nightly, but e.g. an Experimental build
## # set(dashboard_model "Experimental")
##
## # if your "git" executable can not be found by FindGit.cmake
## # set(GIT_EXECUTABLE "path/to/my/git")
##
## # if you only want to run the test, but not submit the results
## set(NO_SUBMIT TRUE)
##
## # if you are not on a openSUSE system the script currently doesn't
## # set a proper build name
## set(CTEST_BUILD_NAME "Fedora Core 14 x86_64")
##
## # add extra configure options
## # set(CONF_OPTIONS "-DPICKER_MENU=On")
##
## # This _*MUST*_ be the last command in this file!
## include(/path/to/osm2go/ctest_osm2go.cmake)
## ######### end file
##
## Then run this script with
## ctest -S my_osm2go_nightly.cmake -V
##
# Check for required variables.
foreach (req
OSM2GO_BUILD_DIR
)
if (NOT DEFINED ${req})
message(FATAL_ERROR "The containing script must set ${req}")
endif ()
endforeach ()
cmake_minimum_required(VERSION 3.13)
option(BUILD_WITH_QT "build the experimental Qt version" OFF)
if (NOT GIT_EXECUTABLE)
find_package(Git REQUIRED)
endif()
set(UpdateCommand ${GIT_EXECUTABLE})
set(CTEST_SOURCE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
set(CTEST_BINARY_DIRECTORY ${OSM2GO_BUILD_DIR})
# Select the model (Nightly, Experimental, Continuous).
if (NOT DEFINED dashboard_model)
set(dashboard_model Nightly)
endif()
if (NOT "${dashboard_model}" MATCHES "^(Nightly|Experimental|Continuous)$")
message(FATAL_ERROR "dashboard_model must be Nightly, Experimental, or Continuous")
endif()
if (NOT CTEST_CMAKE_GENERATOR)
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
endif ()
# set the site name
if (NOT CTEST_SITE)
execute_process(COMMAND hostname --fqdn
OUTPUT_VARIABLE CTEST_SITE
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
# set the build name
if (NOT CTEST_BUILD_NAME)
if (EXISTS /etc/SuSE-release)
file(STRINGS /etc/SuSE-release _SUSEVERSION LIMIT_COUNT 1)
string(REGEX REPLACE "[\\(\\)]" "" CTEST_BUILD_NAME "${_SUSEVERSION}")
unset(_SUSEVERSION)
elseif (EXISTS /etc/os-release)
file(STRINGS /etc/os-release _OSVERSION)
foreach(_OSVERSION_STRING ${_OSVERSION} REGEX "^(NAME|VERSION_ID)=")
if (_OSVERSION_STRING MATCHES "^NAME=\"?([^\"]*)\"?$")
set(_OSVER_NAME "${CMAKE_MATCH_1}")
elseif (_OSVERSION_STRING MATCHES "^VERSION_ID=\"?([^\"]*)\"?$")
set(_OSVER_VERSION "${CMAKE_MATCH_1}")
endif ()
endforeach()
unset(_OSVERSION)
if (_OSVER_NAME AND _OSVER_VERSION)
set(CTEST_BUILD_NAME "${_OSVER_NAME} ${_OSVER_VERSION}")
endif ()
endif ()
endif ()
if (NOT CTEST_BUILD_NAME)
message(FATAL_ERROR "CTEST_BUILD_NAME not set.\nPlease set this to a sensible value, preferably in the form \"distribution version architecture\", something like \"openSUSE 11.3 i586\"")
endif ()
find_program(CTEST_MEMORYCHECK_COMMAND valgrind)
if ($ENV{CC} MATCHES clang)
find_program(CTEST_COVERAGE_COMMAND llvm-cov)
set(CTEST_COVERAGE_EXTRA_FLAGS gcov)
else ()
find_program(CTEST_COVERAGE_COMMAND gcov)
endif ()
ctest_read_custom_files(${CMAKE_CURRENT_LIST_DIR})
if (BUILD_WITH_QT)
list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE "/src/platforms/gtk/")
else ()
list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE "/src/platforms/qt/")
endif ()
if (NOT IS_DIRECTORY ${CTEST_BINARY_DIRECTORY})
make_directory(${CTEST_BINARY_DIRECTORY})
endif ()
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
ctest_start(${dashboard_model})
ctest_update()
# get coverage: debug build
list(APPEND CONF_OPTIONS "-DCMAKE_BUILD_TYPE=Debug")
#forward this option
list(APPEND CONF_OPTIONS "-DBUILD_WITH_QT=${BUILD_WITH_QT}")
ctest_configure(
OPTIONS "${CONF_OPTIONS}"
)
ctest_build()
ctest_test()
if (CTEST_COVERAGE_COMMAND)
ctest_coverage()
endif ()
if (CTEST_MEMORYCHECK_COMMAND)
# set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "${CMAKE_CURRENT_LIST_DIR}/valgrind.supp")
ctest_memcheck()
endif ()
if (NOT NO_SUBMIT)
ctest_submit()
endif ()