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: 10 minutes : 600 seconds
101 DART_TESTING_TIMEOUT 600
102 CACHE STRING "Maximum time allowed (10 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 message("Git branch (mercurial): ${GIT_BRANCH_NAME}")
135 SET(BUILDNAME "${BUILDNAME}-git-branch=${GIT_BRANCH_NAME}")
138 # Some last minute cleanup
139 # Seems like no '/' are allowed in the BUILDNAME or in the SITE name
140 string(REPLACE "/" "_" BUILDNAME ${BUILDNAME})
141 string(REPLACE "/" "_" SITE ${SITE})
145 #-----------------------------------------------------------------------------
147 # Compile FOAM, libs and apps
148 add_custom_target (foam-extend-$ENV{WM_PROJECT_VERSION} ALL
153 TARGET foam-extend-$ENV{WM_PROJECT_VERSION}
154 PROPERTY LABELS foam-extend-$ENV{WM_PROJECT_VERSION}
157 # Compile the FOAM unit tests located under applications/test
158 # This part will not be compiled and run by default.
159 # This would be a good candidate for a sub-project
160 add_custom_target (foam-extend-$ENV{WM_PROJECT_VERSION}_unitTests
161 wmake all ${OF_ROOT}/applications/test
165 #-----------------------------------------------------------------------------
167 #Enable testing and dashboard
171 SET (CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
174 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 1000
175 CACHE INTERNAL "Max number of errors"
178 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000
179 CACHE INTERNAL "Max number of warnings"
184 # Modify this variable if you want the full length test case simulations
185 # Beware, this might take a long time to execute.
186 # Otherwise, the default behaviour is to run each tutorial for 1 "timestep"
187 #SET(RUN_FROM_ONE_TIMESTEP 0)
188 SET(RUN_FROM_ONE_TIMESTEP 1)
190 IF(RUN_FROM_ONE_TIMESTEP)
191 SET(testIdSuffix "_oneTimeStep")
192 ENDIF(RUN_FROM_ONE_TIMESTEP)
194 # FOAM will run against this test suite:
196 # Add the suite of FOAM tutorials
198 INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/FOAM_Tutorials.cmake)
200 # Add a dummy test (/bin/true, just for debugging)
202 foam-extend-$ENV{WM_PROJECT_VERSION}_Dummy_Test true
205 IF(RUN_FROM_ONE_TIMESTEP)
206 # Modify the cases controlDict file in order to run for only one time step
207 MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")
209 COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForOneTimeStep.sh ${TEST_CASE_DIR}
212 ENDIF(RUN_FROM_ONE_TIMESTEP)