1 # /*-------------------------------------------------------------------------*\
3 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / A nd | Copyright held by original author
7 # -----------------------------------------------------------------------------
9 # This file is part of OpenFOAM.
11 # OpenFOAM 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 2 of the License, or (at your
14 # option) any later version.
16 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 # You should have received a copy of the GNU General Public License
22 # along with OpenFOAM; if not, write to the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 # CMakeLists.txt file for implementing a test harness for the compilation
27 # and test of OpenFOAM-1.6-ext using Kitware CTest./CMake/CDash
29 # The results will be submitted to the CDash server identified by the file
33 # Martin Beaudoin, Hydro-Quebec, 2010. All rights reserved
36 # \*-------------------------------------------------------------------------*/
38 cmake_minimum_required (VERSION 2.8)
40 PROJECT(OpenFOAM_1.6-ext)
42 #-----------------------------------------------------------------------------
43 # Initialization of CTest specific variables
45 # Initialize the site name
47 IF (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
48 # We can override the site name with the environment variable
49 # $CDASH_SUBMIT_LOCAL_HOST_ID
51 SITENAME $ENV{CDASH_SUBMIT_LOCAL_HOST_ID}
52 CACHE STRING "Name of the local site"
54 ELSE (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
55 # Grab the hostname FQN; will be used for the sitename
58 OUTPUT_VARIABLE SITENAME
60 ENDIF (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
62 MESSAGE("Initializing the name of this local site to: ${SITENAME}")
66 CACHE STRING "Name of the local site"
69 #Grab the OpenFOAM installation directory.
71 OF_ROOT $ENV{WM_PROJECT_DIR}
72 CACHE INTERNAL "OpenFOAM root directory."
75 # Construct the build name.
76 # No need to add $WM_PROJECT_VERSION to the name of the build,
77 # the test harness name should have taken care of that.
79 BUILDNAME $ENV{WM_OPTIONS}
80 CACHE STRING "Build ID"
83 # Find out the version of the compiler being used.
84 # Add this information to the buildname
85 # This is for gcc or icc because they both support the -dumpversion option
86 EXEC_PROGRAM($ENV{WM_CC}
88 OUTPUT_VARIABLE COMPILER_VERSION
90 SET(BUILDNAME "${BUILDNAME}-$ENV{WM_CC}${COMPILER_VERSION}")
92 # We will support more compilers eventually.
95 # Timeout for running every single test: 4 hours: 4 x 3600 seconds
97 # DART_TESTING_TIMEOUT 14400
98 # CACHE STRING "Maximum time allowed (4 hours) before CTest will kill the test."
100 # Timeout for running all this: 10 minutes : 600 seconds
102 DART_TESTING_TIMEOUT 600
103 CACHE STRING "Maximum time allowed (10 minutes) before CTest will kill the test."
107 CMAKE_VERBOSE_MAKEFILE TRUE
112 #-----------------------------------------------------------------------------
113 set (UPDATE_TYPE git)
120 message("Git was found: ${GIT_EXECUTABLE}")
122 # Adding the name of the git branch to the build name
124 ARGS branch --no-color 2> /dev/null | grep '*'| awk '{print $2}'
125 OUTPUT_VARIABLE GIT_BRANCH_NAME
127 message("Git branch: ${GIT_BRANCH_NAME}")
128 if (GIT_BRANCH_NAME STREQUAL "")
129 message("No git-branch. Mercurial?")
132 OUTPUT_VARIABLE GIT_BRANCH_NAME
134 message("Git branch (mercurial): ${GIT_BRANCH_NAME}")
136 SET(BUILDNAME "${BUILDNAME}-git-branch=${GIT_BRANCH_NAME}")
139 # Some last minute cleanup
140 # Seems like no '/' are allowed in the BUILDNAME or in the SITE name
141 string(REPLACE "/" "_" BUILDNAME ${BUILDNAME})
142 string(REPLACE "/" "_" SITE ${SITE})
146 #-----------------------------------------------------------------------------
148 # Compile OpenFOAM, libs and apps
149 add_custom_target (OpenFOAM-$ENV{WM_PROJECT_VERSION} ALL
154 TARGET OpenFOAM-$ENV{WM_PROJECT_VERSION}
155 PROPERTY LABELS OpenFOAM-$ENV{WM_PROJECT_VERSION}
158 # Compile the OpenFOAM unit tests located under applications/test
159 # This part will not be compiled and run by default.
160 # This would be a good candidate for a sub-project
161 add_custom_target (OpenFOAM-$ENV{WM_PROJECT_VERSION}_unitTests
162 wmake all ${OF_ROOT}/applications/test
166 #-----------------------------------------------------------------------------
168 #Enable testing and dashboard
172 SET (CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
175 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 1000
176 CACHE INTERNAL "Max number of errors"
179 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000
180 CACHE INTERNAL "Max number of warnings"
185 # Modify this variable if you want the full length test case simulations
186 # Beware, this might take a long time to execute.
187 # Otherwise, the default behaviour is to run each tutorial for 1 "timestep"
188 #SET(RUN_FROM_ONE_TIMESTEP 0)
189 SET(RUN_FROM_ONE_TIMESTEP 1)
191 IF(RUN_FROM_ONE_TIMESTEP)
192 SET(testIdSuffix "_oneTimeStep")
193 ENDIF(RUN_FROM_ONE_TIMESTEP)
195 # OpenFOAM will run against this test suite:
197 # Add the suite of OpenFOAM tutorials
199 INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/OpenFOAM_Tutorials.cmake)
201 # Add a dummy test (/bin/true, just for debugging)
203 OpenFOAM-$ENV{WM_PROJECT_VERSION}_Dummy_Test true
206 IF(RUN_FROM_ONE_TIMESTEP)
207 # Modify the cases controlDict file in order to run for only one time step
208 MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")
210 COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForOneTimeStep.sh ${TEST_CASE_DIR}
213 ENDIF(RUN_FROM_ONE_TIMESTEP)