1 # /*-------------------------------------------------------------------------*\
3 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / A nd | 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.0 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.0)
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}")
127 if (GIT_BRANCH_NAME STREQUAL "")
128 message("No git-branch. Mercurial?")
131 OUTPUT_VARIABLE GIT_BRANCH_NAME
133 string(REPLACE " " "_" GIT_BRANCH_NAME ${GIT_BRANCH_NAME})
134 string(REPLACE "+" "_modified" GIT_BRANCH_NAME ${GIT_BRANCH_NAME})
135 SET(GIT_BRANCH_NAME "hg_${GIT_BRANCH_NAME}")
136 message("Git branch (mercurial): ${GIT_BRANCH_NAME}")
138 SET(BUILDNAME "${BUILDNAME}-git-branch=${GIT_BRANCH_NAME}")
141 # Some last minute cleanup
142 # Seems like no '/' are allowed in the BUILDNAME or in the SITE name
143 string(REPLACE "/" "_" BUILDNAME ${BUILDNAME})
144 string(REPLACE "/" "_" SITE ${SITE})
147 #-----------------------------------------------------------------------------
149 # Compile FOAM, libs and apps
150 add_custom_target (foam-extend-$ENV{WM_PROJECT_VERSION} ALL
155 TARGET foam-extend-$ENV{WM_PROJECT_VERSION}
156 PROPERTY LABELS foam-extend-$ENV{WM_PROJECT_VERSION}
159 # Compile the FOAM unit tests located under applications/test
160 # This part will not be compiled and run by default.
161 # This would be a good candidate for a sub-project
162 add_custom_target (foam-extend-$ENV{WM_PROJECT_VERSION}_unitTests
163 wmake all ${OF_ROOT}/applications/test
167 #-----------------------------------------------------------------------------
169 #Enable testing and dashboard
173 SET (CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
176 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 1000
177 CACHE INTERNAL "Max number of errors"
180 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000
181 CACHE INTERNAL "Max number of warnings"
186 # Modify this variable if you want the full length test case simulations
187 # Beware, this might take a long time to execute.
188 # Otherwise, the default behaviour is to run each tutorial for 1 "timestep"
189 #SET(RUN_FROM_ONE_TIMESTEP 0)
190 SET(RUN_FROM_ONE_TIMESTEP 1)
192 IF(RUN_FROM_ONE_TIMESTEP)
193 SET(testIdSuffix "_oneTimeStep")
194 ENDIF(RUN_FROM_ONE_TIMESTEP)
196 # FOAM will run against this test suite:
198 # Add the suite of FOAM tutorials
200 INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/FOAM_Tutorials.cmake)
202 # Add a dummy test (/bin/true, just for debugging)
204 foam-extend-$ENV{WM_PROJECT_VERSION}_Dummy_Test true
207 IF(RUN_FROM_ONE_TIMESTEP)
208 # Modify the cases controlDict file in order to run for only one time step
209 MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")
211 COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForOneTimeStep.sh ${TEST_CASE_DIR}
214 ENDIF(RUN_FROM_ONE_TIMESTEP)