nightly.cmake 7.95 KB
Newer Older
1
2
3
4
5
6
7
8
9
# Driver instructions for Nightly build on a computer
# To configurat a Nightly build, create a cron job using a script that loads this ctest instruction (driver) using the 
# followind command line : ctest -S ctest-nightly-driver.cmake
#
# What this script does ?
# * INFORMATION STEP
#       Configure SITE and BUILD information to be correctly display on dashboard
#       Loads information from the CTestConfig.cmake file.
# * UPDATE STEP
10
#       use GIT to udpdate source code to the latest revision BEFORE Nightly start time, which is defined in the CTestConfig.cmake file.
11
12
13
14
15
16
17
# * CONFIGURE STEP
#       configure the whole CamiTK project and create a new build directory 
# * BUILD STEP 
#       build each subproject of CamiTK
# For each step a report is sent to the dashboard. This allows any developer to be informed (mailing list) of any problem, even BEFORE the script ends !

# Need to be defined, for the build to run.
18
if(NOT DEFINED CTEST_SOURCE_DIRECTORY)
19
    message(FATAL_ERROR "No source directory: please provide the path to the source directory with the CTEST_SOURCE_DIRECTORY argument")
20
endif()
21
if(NOT DEFINED CTEST_BINARY_DIRECTORY)
22
    message(FATAL_ERROR "No build directory: please provide the path to the build directory with the CTEST_BINARY_DIRECTORY argument")
23
endif()
24
25
26

# Script configuration, depending of the build, computer running the script
# Update to feat each computer which runs this script
27
28
29
30
31
32
33
34
35
36
37
38

# Get VM compilation information given by ctest call command
if(CAMITK_CONTINUOUS_INTEGRATION)
    string(REGEX REPLACE "^(.*)-.*-.*" "\\1" COMPILER "${CAMITK_CONTINUOUS_INTEGRATION}")
    string(REGEX REPLACE "^.*-(.*)-.*" "\\1" ARCH "${CAMITK_CONTINUOUS_INTEGRATION}")
    string(REGEX REPLACE "^.*-.*-(.*)" "\\1" BUILDTYPE "${CAMITK_CONTINUOUS_INTEGRATION}")
else()
    message(FATAL_ERROR "CAMITK_CONTINUOUS_INTEGRATION value must be given as option of the ctest command calling this script.")
endif()

# Compose with those variables the CTest required ones.
site_name(CTEST_SITE)
39

40
41
42
if(UNIX)
    set( CTEST_CMAKE_GENERATOR  "Unix Makefiles" )
elseif(WIN32)
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    if(COMPILER MATCHES "MinGW" OR "MINGW")
        set( CTEST_CMAKE_GENERATOR  "MinGW Makefiles" )
    elseif(COMPILER MATCHES "MSVC2008")
        set( CTEST_CMAKE_GENERATOR "Visual Studio 9 2008" )
    elseif(COMPILER MATCHES "MSVC2010" AND ARCH MATCHES "32bits")
        set( CTEST_CMAKE_GENERATOR  "Visual Studio 10" )
        set( CMAKE_MAKE_PROGRAM "C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/VCExpress.exe") # Do not use MSBuild.exe as it won't work
    elseif(COMPILER MATCHES "MSVC2010" AND ARCH MATCHES "64bits")
        set( CTEST_CMAKE_GENERATOR  "Visual Studio 10 Win64" )
        set( CMAKE_MAKE_PROGRAM "C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/VCExpress.exe") # Do not use MSBuild.exe as it won't work
    elseif(COMPILER MATCHES "MSVC2012" AND ARCH MATCHES "32bits")
        set( CTEST_CMAKE_GENERATOR  "Visual Studio 11" )
        set( CMAKE_MAKE_PROGRAM "C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/WDExpress.exe") # Do not use MSBuild.exe as it won't work
    elseif(COMPILER MATCHES "MSVC2012" AND ARCH MATCHES "64bits")
        set( CTEST_CMAKE_GENERATOR  "Visual Studio 11 Win64" )
        set( CMAKE_MAKE_PROGRAM "C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/WDExpress.exe") # Do not use MSBuild.exe as it won't work
    elseif(COMPILER MATCHES "MSVC2013" AND ARCH MATCHES "32bits")
        set( CTEST_CMAKE_GENERATOR  "Visual Studio 12" )
    elseif(COMPILER MATCHES "MSVC2013" AND ARCH MATCHES "64bits")
        set( CTEST_CMAKE_GENERATOR  "Visual Studio 12 Win64" )
63
64
    elseif(COMPILER MATCHES "MSVC2015" AND ARCH MATCHES "64bits")
        set( CTEST_CMAKE_GENERATOR  "Visual Studio 14 2015 Win64" )
65
66
    elseif(COMPILER MATCHES "MSVC2017" AND ARCH MATCHES "64bits")
        set( CTEST_CMAKE_GENERATOR "Visual Studio 15 2017 Win64" )
67
68
69
    else()
        message(FATAL_ERROR "CTEST COMPILER ERROR : No proper compiler found, please check ctest command syntax.")
    endif()
70
71
72
endif()

if(BUILDTYPE)
73
74
    set(CTEST_BUILD_CONFIGURATION ${BUILDTYPE})
    set(CTEST_CONFIGURATION_TYPE ${BUILDTYPE})
75
else()
76
    message(FATAL_ERROR "NO BUILD TYPE : Please provide a build type: Debug or Release")
77
endif()
78

79
80
81
82
83
84
85
86
# get the git hash
find_package(Git QUIET)
if(GIT_FOUND)
    include("${CTEST_SOURCE_DIRECTORY}/sdk/cmake/modules/macros/GetGitInfo.cmake")
else()
    message(FATAL_ERROR "Git command not found: please install git.")
endif()

87
88
89
90
91
92
# set the build name using the compiler and commit hash of the origin/develop branch
# CTEST_BUILD_NAME needs to be set before ctest_start, which in turns is called before ctest_update
# therefore the current git hash should be fetch fro origin/develop
get_git_info(${CTEST_SOURCE_DIRECTORY})
set(CTEST_BUILD_NAME ${CAMITK_CONTINUOUS_INTEGRATION}-${CAMITK_ORIGIN_DEVELOP_GIT_ABBREVIATED_HASH})

93
# Update source code and send reports
94
set(CTEST_GIT_COMMAND ${GIT_EXECUTABLE})
95
96

if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}")
97
  set(CTEST_CHECKOUT_COMMAND "${GIT_EXECUTABLE} clone https://gricad-gitlab.univ-grenoble-alpes.fr/CamiTK/CamiTK.git ${CTEST_SOURCE_DIRECTORY}")
98
99
endif()

100
set(CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
101
102

# CMake configuration (put here all the configure flags)
103
104
set(CTEST_CONFIGURE_COMMAND "${CMAKE_COMMAND} -Wno-dev -G \"${CTEST_CMAKE_GENERATOR}\"")
set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION}")
105
if(COMPILER MATCHES "MSVC2010" AND ARCH MATCHES "64bits") # Do not compile MML and PhysicalModel until libxml2 MSVC2010 x64 bug remains.
106
    set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DACTION_MML=FALSE -DCOMPONENT_MML=FALSE -DCOMPONENT_PHYSICALMODEL=FALSE")
107
endif()
108
set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DCEP_IMAGING=TRUE -DCEP_MODELING=TRUE -DCEP_TUTORIALS=TRUE -DAPIDOC_SDK=TRUE -DCAMITK_DISABLE_TRANSLATION=TRUE ${CTEST_SOURCE_DIRECTORY}")
109
110
111
112
113
114
115
116
117
118
# -DCAMITK_INSTALL_ROOT=${CTEST_BINARY_DIRECTORY}

# to get CDash server configuration :
include("${CTEST_SOURCE_DIRECTORY}/CTestConfig.cmake")

# The type of build that this script will make 
# For this script we use Nightly build has it is designed to be run once a day
ctest_start(Nightly)

# Update source code
119
ctest_update(SOURCE ${CTEST_SOURCE_DIRECTORY} RETURN_VALUE count)
120

121
122
if(count GREATER 0)
    # We only show update when there is change (avoid the CDash u=1 bug with no errors report)
123
    ctest_submit(PARTS Update Notes)
124
endif()
125
126
127
128

# Configure whole project
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
ctest_configure()
129
ctest_submit(PARTS Configure)
130

131
132
133
134
135
136
137
138
139
140
141
142
143
#Empty local installation directory
if(WIN32)
    # %APPDATA%\MySoft\Star Runner.ini
    set(CAMITK_USER_BASE_DIR_WINDOWS $ENV{APPDATA})
    file(TO_CMAKE_PATH "${CAMITK_USER_BASE_DIR_WINDOWS}" CAMITK_USER_BASE_DIR)
else()
    # (UNIX OR APPLE)
    # $HOME/.config/MySoft/Star Runner.ini 
    set(CAMITK_USER_BASE_DIR "$ENV{HOME}/.config")
endif()
set(CAMITK_USER_DIR "${CAMITK_USER_BASE_DIR}/CamiTK")
file(REMOVE_RECURSE ${CAMITK_USER_DIR})

144
# to get subprojects listing (automatically created at configuration step)
145
146
147
148
149
include("${CTEST_BINARY_DIRECTORY}/Subprojects.cmake")

# Update CDash configuration to the server
# Project.xml file is automatically generated. If someone added an extension to CamiTK, CDash will automatically be updated according to it.
# To do this, send this file to the server
150
ctest_submit(FILES "${CTEST_BINARY_DIRECTORY}/Project.xml") 
151
152
153
154
155
156
157
158
159
160

# Build each subprojects
foreach(subproject ${CAMITK_SUBPROJECTS})
        # tag sub project
        set_property(GLOBAL PROPERTY SubProject ${subproject})
        set_property(GLOBAL PROPERTY Label ${subproject})

        # build each sub project
        set(CTEST_BUILD_TARGET ${subproject})
        ctest_build()
161
        ctest_submit(PARTS Build)
162
163
164

        # Run tests
        ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" INCLUDE_LABEL "${subproject}")
165
        ctest_submit(PARTS Test)
166
167
168
169
endforeach() 

# Install locally this build version of CamiTK
set(CTEST_BUILD_TARGET sdk_local_install)
170
ctest_build()
171
ctest_submit(PARTS Install)