1 # /*-------------------------------------------------------------------------*\
3 # \\ / F ield | foam-extend: Open Source CFD
4 # \\ / O peration | Version: 3.2
5 # \\ / A nd | Web: http://www.foam-extend.org
6 # \\/ M anipulation | For copyright notice see file Copyright
7 # -----------------------------------------------------------------------------
9 # This file is part of foam-extend.
11 # foam-extend is free software: you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by the
13 # Free Software Foundation, either version 3 of the License, or (at your
14 # option) any later version.
16 # foam-extend is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 # General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 # CMakeLists.txt file for implementing a test harness for the compilation
26 # and test of foam-extend-3.2 using Kitware CTest/CMake/CDash
28 # The results will be submitted to the CDash server identified by the file
32 # Martin Beaudoin, Hydro-Quebec, 2010. All rights reserved
35 # \*-------------------------------------------------------------------------*/
37 cmake_minimum_required (VERSION 2.8)
39 PROJECT(foam-extend-3.2)
41 #-----------------------------------------------------------------------------
42 # Initialization of CTest specific variables
44 ## Run ctest in parallel if environment variable WM_NCOMPPROCS is set
45 IF (NOT $ENV{WM_NCOMPPROCS} STREQUAL "")
46 # Will run ctest in parallel over $WM_NCOMPPROCS processors
47 set(CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} --parallel $ENV{WM_NCOMPPROCS})
48 MESSAGE("Running tests in parallel using $ENV{WM_NCOMPPROCS} processors")
51 # Initialize the site name
53 IF (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
54 # We can override the site name with the environment variable
55 # $CDASH_SUBMIT_LOCAL_HOST_ID
57 SITENAME $ENV{CDASH_SUBMIT_LOCAL_HOST_ID}
58 CACHE STRING "Name of the local site"
60 ELSE (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
61 # Grab the hostname FQN; will be used for the sitename
64 OUTPUT_VARIABLE SITENAME
66 ENDIF (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
68 MESSAGE("Initializing the name of this local site to: ${SITENAME}")
72 CACHE STRING "Name of the local site"
75 #Grab the FOAM installation directory.
77 FOAM_ROOT $ENV{WM_PROJECT_DIR}
78 CACHE INTERNAL "FOAM root directory."
81 # Construct the build name.
82 # No need to add $WM_PROJECT_VERSION to the name of the build,
83 # the test harness name should have taken care of that.
85 BUILDNAME $ENV{WM_OPTIONS}
86 CACHE STRING "Build ID"
89 # We allow overriding the git branch and revision information with some
90 # user-supplied information using the CDASH_SCM_INFO environment variable.
92 # Mercurial or other SCM users should be using this environment variable
93 # in order to provide branch and revision information for the buildname.
95 # Git users should use this environment variable in order to provide
96 # additionnal information instead of just the branch and revision number.
98 # Otherwise, the buildname will be appended with the following information:
99 # -git-branch=the_git_branch_name-git-rev=the_git_revision_number
101 BUILDNAME_SCM_INFO $ENV{CDASH_SCM_INFO}
102 CACHE STRING "SCM info for CDash buildname"
105 # Find out the version of the compiler being used.
106 # Add this information to the buildname
107 # This is for gcc or icc because they both support the -dumpversion option
108 EXEC_PROGRAM($ENV{WM_CC}
110 OUTPUT_VARIABLE COMPILER_VERSION
112 SET(BUILDNAME "${BUILDNAME}-$ENV{WM_CC}${COMPILER_VERSION}")
114 # We will support more compilers eventually.
117 # Timeout for running every single test: 4 hours: 4 x 3600 seconds
119 # DART_TESTING_TIMEOUT 14400
120 # CACHE STRING "Maximum time allowed (4 hours) before CTest will kill the test."
122 # Timeout for running all this: 20 minutes : 1200 seconds (for debug)
124 DART_TESTING_TIMEOUT 1200
125 CACHE STRING "Maximum time allowed (20 minutes) before CTest will kill the test."
129 CMAKE_VERBOSE_MAKEFILE TRUE
134 #-----------------------------------------------------------------------------
135 set (UPDATE_TYPE git)
142 if(NOT BUILDNAME_SCM_INFO STREQUAL "")
143 SET(BUILDNAME "${BUILDNAME}-${BUILDNAME_SCM_INFO}")
146 message("The git command was found: ${GIT_EXECUTABLE}")
148 # Check if the source code is under a valid git repository
151 WORKING_DIRECTORY ${FOAM_ROOT}
152 OUTPUT_VARIABLE GIT_STATUS
153 RESULT_VARIABLE GIT_ECODE
158 # We have a valid git repository. Grab the branch and revision info.
159 # Add to the build name
161 ARGS branch --no-color 2> /dev/null | grep '*'| awk '{print $2}'
162 OUTPUT_VARIABLE GIT_BRANCH_NAME
164 message("Git branch: ${GIT_BRANCH_NAME}")
167 COMMAND git rev-parse --short=12 HEAD
168 OUTPUT_VARIABLE GIT_REV_NUMBER
170 message("Git revision: ${GIT_REV_NUMBER}")
172 SET(BUILDNAME "${BUILDNAME}-git-branch=${GIT_BRANCH_NAME}")
173 SET(BUILDNAME "${BUILDNAME}-git-rev=${GIT_REV_NUMBER}")
177 WORKING_DIRECTORY ${FOAM_ROOT}
178 OUTPUT_VARIABLE HG_STATUS
179 RESULT_VARIABLE HG_ECODE
183 # We have a valid git repository. Grab the branch and revision info.
184 # Add to the build name
185 message("No git-branch. Mercurial?")
188 OUTPUT_VARIABLE GIT_BRANCH_NAME
192 OUTPUT_VARIABLE GIT_REV_NUMBER
195 ARGS log --template='git_{gitnode|short}' -l 1
196 OUTPUT_VARIABLE GIT_REAL_REV_NUMBER
198 string(REPLACE " " "_" GIT_BRANCH_NAME ${GIT_BRANCH_NAME})
199 string(REPLACE "+" ":modified" GIT_REV_NUMBER ${GIT_REV_NUMBER})
200 SET(GIT_REV_NUMBER "${GIT_REV_NUMBER}_${GIT_REAL_REV_NUMBER}")
201 message("Git branch (mercurial): ${GIT_BRANCH_NAME} Revision: ${GIT_REV_NUMBER}")
203 SET(BUILDNAME "${BUILDNAME}-hg-branch=${GIT_BRANCH_NAME}")
204 SET(BUILDNAME "${BUILDNAME}-hg-rev=${GIT_REV_NUMBER}")
206 # Not a git or mercurial repository: no branch nor revision information available
207 SET(BUILDNAME "${BUILDNAME}-git-branch=unknown")
208 SET(BUILDNAME "${BUILDNAME}-git-rev=unknown")
212 # Git is not available: no branch nor revision information supplied
213 SET(BUILDNAME "${BUILDNAME}-git-branch=unknown")
214 SET(BUILDNAME "${BUILDNAME}-git-rev=unknown")
217 # Some last minute cleanup
218 # Seems like no '/' or ' 'are allowed in the BUILDNAME or in the SITE name
219 string(REPLACE "/" "_" BUILDNAME ${BUILDNAME})
220 string(REPLACE " " "_" BUILDNAME ${BUILDNAME})
221 string(REPLACE "/" "_" SITE ${SITE})
222 string(REPLACE " " "_" SITE ${SITE})
224 message("Build name: ${BUILDNAME}")
227 #-----------------------------------------------------------------------------
229 # Compile FOAM, libs and apps
230 add_custom_target (foam-extend-$ENV{WM_PROJECT_VERSION} ALL
231 ${FOAM_ROOT}/Allwmake
235 TARGET foam-extend-$ENV{WM_PROJECT_VERSION}
236 PROPERTY LABELS foam-extend-$ENV{WM_PROJECT_VERSION}
239 # Compile the FOAM unit tests located under applications/test
240 # This part will not be compiled and run by default.
241 # This would be a good candidate for a sub-project
242 add_custom_target (foam-extend-$ENV{WM_PROJECT_VERSION}_unitTests
243 wmake all ${FOAM_ROOT}/applications/test
247 #-----------------------------------------------------------------------------
249 #Enable testing and dashboard
253 SET (CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
256 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 1000
257 CACHE INTERNAL "Max number of errors"
260 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000
261 CACHE INTERNAL "Max number of warnings"
266 # Modify this variable if you want the full length test case simulations
267 # Beware, this might take a long time to execute.
268 # Otherwise, the default behaviour is to run each tutorial for 1 "timestep"
269 #SET(RUN_FROM_ONE_TIMESTEP 0)
270 SET(RUN_FROM_ONE_TIMESTEP 1)
272 IF(RUN_FROM_ONE_TIMESTEP)
273 SET(testIdSuffix "_oneTimeStep")
274 ENDIF(RUN_FROM_ONE_TIMESTEP)
276 # FOAM will run against this test suite:
278 # Add the suite of FOAM tutorials
280 INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/FOAM_Tutorials.cmake)
282 IF(RUN_FROM_ONE_TIMESTEP)
283 # Modify the cases controlDict file in order to run for only one time step
284 MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")
286 COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForOneTimeStep.sh ${TEST_CASE_DIR}
289 ENDIF(RUN_FROM_ONE_TIMESTEP)