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 # Initialize the site name
46 IF (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
47 # We can override the site name with the environment variable
48 # $CDASH_SUBMIT_LOCAL_HOST_ID
50 SITENAME $ENV{CDASH_SUBMIT_LOCAL_HOST_ID}
51 CACHE STRING "Name of the local site"
53 ELSE (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
54 # Grab the hostname FQN; will be used for the sitename
57 OUTPUT_VARIABLE SITENAME
59 ENDIF (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
61 MESSAGE("Initializing the name of this local site to: ${SITENAME}")
65 CACHE STRING "Name of the local site"
68 #Grab the FOAM installation directory.
70 OF_ROOT $ENV{WM_PROJECT_DIR}
71 CACHE INTERNAL "FOAM root directory."
74 # Construct the build name.
75 # No need to add $WM_PROJECT_VERSION to the name of the build,
76 # the test harness name should have taken care of that.
78 BUILDNAME $ENV{WM_OPTIONS}
79 CACHE STRING "Build ID"
82 # Find out the version of the compiler being used.
83 # Add this information to the buildname
84 # This is for gcc or icc because they both support the -dumpversion option
85 EXEC_PROGRAM($ENV{WM_CC}
87 OUTPUT_VARIABLE COMPILER_VERSION
89 SET(BUILDNAME "${BUILDNAME}-$ENV{WM_CC}${COMPILER_VERSION}")
91 # We will support more compilers eventually.
94 # Timeout for running every single test: 4 hours: 4 x 3600 seconds
96 # DART_TESTING_TIMEOUT 14400
97 # CACHE STRING "Maximum time allowed (4 hours) before CTest will kill the test."
99 # Timeout for running all this: 20 minutes : 1200 seconds (for debug)
101 DART_TESTING_TIMEOUT 1200
102 CACHE STRING "Maximum time allowed (20 minutes) before CTest will kill the test."
106 CMAKE_VERBOSE_MAKEFILE TRUE
111 #-----------------------------------------------------------------------------
112 set (UPDATE_TYPE git)
119 message("Git was found: ${GIT_EXECUTABLE}")
121 # Adding the name of the git branch to the build name
123 ARGS branch --no-color 2> /dev/null | grep '*'| awk '{print $2}'
124 OUTPUT_VARIABLE GIT_BRANCH_NAME
126 message("Git branch: ${GIT_BRANCH_NAME}")
128 # We also add the git rev number to the build name
130 ARGS rev-parse --short=12 HEAD
131 OUTPUT_VARIABLE GIT_REV_NUMBER
133 message("Git rev: ${GIT_REV_NUMBER}")
134 if (GIT_BRANCH_NAME STREQUAL "")
135 message("No git-branch. Mercurial?")
138 OUTPUT_VARIABLE GIT_BRANCH_NAME
140 string(REPLACE " " "_" GIT_BRANCH_NAME ${GIT_BRANCH_NAME})
141 string(REPLACE "+" "_modified" GIT_BRANCH_NAME ${GIT_BRANCH_NAME})
142 SET(GIT_BRANCH_NAME "hg_${GIT_BRANCH_NAME}")
143 message("Git branch (mercurial): ${GIT_BRANCH_NAME}")
145 SET(BUILDNAME "${BUILDNAME}-git-branch=${GIT_BRANCH_NAME}")
146 SET(BUILDNAME "${BUILDNAME}-git-rev=${GIT_REV_NUMBER}")
149 # Some last minute cleanup
150 # Seems like no '/' are allowed in the BUILDNAME or in the SITE name
151 string(REPLACE "/" "_" BUILDNAME ${BUILDNAME})
152 string(REPLACE "/" "_" SITE ${SITE})
155 #-----------------------------------------------------------------------------
157 # Compile FOAM, libs and apps
158 add_custom_target (foam-extend-$ENV{WM_PROJECT_VERSION} ALL
163 TARGET foam-extend-$ENV{WM_PROJECT_VERSION}
164 PROPERTY LABELS foam-extend-$ENV{WM_PROJECT_VERSION}
167 # Compile the FOAM unit tests located under applications/test
168 # This part will not be compiled and run by default.
169 # This would be a good candidate for a sub-project
170 add_custom_target (foam-extend-$ENV{WM_PROJECT_VERSION}_unitTests
171 wmake all ${OF_ROOT}/applications/test
175 #-----------------------------------------------------------------------------
177 #Enable testing and dashboard
181 SET (CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
184 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 1000
185 CACHE INTERNAL "Max number of errors"
188 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000
189 CACHE INTERNAL "Max number of warnings"
194 # Modify this variable if you want the full length test case simulations
195 # Beware, this might take a long time to execute.
196 # Otherwise, the default behaviour is to run each tutorial for 1 "timestep"
197 #SET(RUN_FROM_ONE_TIMESTEP 0)
198 SET(RUN_FROM_ONE_TIMESTEP 1)
200 IF(RUN_FROM_ONE_TIMESTEP)
201 SET(testIdSuffix "_oneTimeStep")
202 ENDIF(RUN_FROM_ONE_TIMESTEP)
204 # FOAM will run against this test suite:
206 # Add the suite of FOAM tutorials
208 INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/FOAM_Tutorials.cmake)
210 # Add a dummy test (/bin/true, just for debugging)
212 foam-extend-$ENV{WM_PROJECT_VERSION}_Dummy_Test true
215 IF(RUN_FROM_ONE_TIMESTEP)
216 # Modify the cases controlDict file in order to run for only one time step
217 MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")
219 COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForOneTimeStep.sh ${TEST_CASE_DIR}
222 ENDIF(RUN_FROM_ONE_TIMESTEP)