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.5-dev 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.5-dev)
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 all this: 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 SET(BUILDNAME "${BUILDNAME}-git-branch:${GIT_BRANCH_NAME}")
131 # Some last minute cleanup
132 # Seems like no '/' are allowed in the BUILDNAME or in the SITE name
133 string(REPLACE "/" "_" BUILDNAME ${BUILDNAME})
134 string(REPLACE "/" "_" SITE ${SITE})
138 #-----------------------------------------------------------------------------
140 # Compile OpenFOAM, libs and apps
141 add_custom_target (OpenFOAM-$ENV{WM_PROJECT_VERSION} ALL
146 TARGET OpenFOAM-$ENV{WM_PROJECT_VERSION}
147 PROPERTY LABELS OpenFOAM-$ENV{WM_PROJECT_VERSION}
150 # Compile the OpenFOAM unit tests located under applications/test
151 # This part will not be compiled and run by default.
152 # This would be a good candidate for a sub-project
153 add_custom_target (OpenFOAM-$ENV{WM_PROJECT_VERSION}_unitTests
154 wmake all ${OF_ROOT}/applications/test
158 #-----------------------------------------------------------------------------
160 #Enable testing and dashboard
164 SET (CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
167 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 1000
168 CACHE INTERNAL "Max number of errors"
171 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000
172 CACHE INTERNAL "Max number of warnings"
177 # Modify this variable if you want the full length test case simulations
178 # Beware, this might take a long time to execute.
179 # Otherwise, the default behaviour is to run each tutorial for 1 "timestep"
180 #SET(RUN_FROM_ONE_TIMESTEP 0)
181 SET(RUN_FROM_ONE_TIMESTEP 1)
183 IF(RUN_FROM_ONE_TIMESTEP)
184 SET(testIdSuffix "_oneTimeStep")
185 ENDIF(RUN_FROM_ONE_TIMESTEP)
187 # OpenFOAM will run against this test suite:
189 # Add the suite of OpenFOAM tutorials
191 INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/OpenFOAM_Tutorials.cmake)
193 # Add a dummy test (/bin/true, just for debugging)
195 OpenFOAM-$ENV{WM_PROJECT_VERSION}_Dummy_Test true
198 IF(RUN_FROM_ONE_TIMESTEP)
199 # Modify the cases controlDict file in order to run for only one time step
200 MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")
202 COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForOneTimeStep.sh ${TEST_CASE_DIR}
205 ENDIF(RUN_FROM_ONE_TIMESTEP)