BlockMatrixAgglomeration
[foam-extend-3.0.git] / CMakeLists.txt
blobe95ddf7039c0395e941667821560f6e9eacfa8c4
1 # /*-------------------------------------------------------------------------*\
2 #   =========                 |
3 #   \\      /  F ield         | foam-extend: Open Source CFD
4 #    \\    /   O peration     |
5 #     \\  /    A nd           | For copyright notice see file Copyright
6 #      \\/     M anipulation  |
7 # -----------------------------------------------------------------------------
8 # License
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/>.
24 # Description
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
29 #     CTestConfig.cmake
31 # Author
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
49     SET(
50           SITENAME $ENV{CDASH_SUBMIT_LOCAL_HOST_ID}
51           CACHE STRING "Name of the local site"
52     )
53 ELSE (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
54     # Grab the hostname FQN; will be used for the sitename
55     execute_process(
56         COMMAND         hostname -f
57         OUTPUT_VARIABLE SITENAME
58     )
59 ENDIF  (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
61 MESSAGE("Initializing the name of this local site to:  ${SITENAME}")
63 SET(
64     SITE ${SITENAME}
65     CACHE STRING "Name of the local site"
68 #Grab the FOAM installation directory.
69 SET(
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.
77 SET(
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}
86   ARGS -dumpversion
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
95 #SET(
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
100 SET(
101     DART_TESTING_TIMEOUT 600
102     CACHE STRING "Maximum time allowed (10 minutes) before CTest will kill the test."
105 SET(
106     CMAKE_VERBOSE_MAKEFILE TRUE
110 # Update section
111 #-----------------------------------------------------------------------------
112 set (UPDATE_TYPE git)
115 # Using GIT as SCM
117 find_package(Git)
118 if(GIT_FOUND)
119     message("Git was found: ${GIT_EXECUTABLE}")
121     # Adding the name of the git branch to the build name
122     EXEC_PROGRAM(git
123       ARGS branch --no-color 2> /dev/null | grep '*'| awk '{print $2}'
124       OUTPUT_VARIABLE GIT_BRANCH_NAME
125     )
126     message("Git branch: ${GIT_BRANCH_NAME}")
127     if (GIT_BRANCH_NAME STREQUAL "")
128        message("No git-branch. Mercurial?")
129        EXEC_PROGRAM(hg
130          ARGS branch
131          OUTPUT_VARIABLE GIT_BRANCH_NAME
132        )
133        message("Git branch (mercurial): ${GIT_BRANCH_NAME}")
134     endif()
135     SET(BUILDNAME "${BUILDNAME}-git-branch=${GIT_BRANCH_NAME}")
136 endif()
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})
144 # Build section
145 #-----------------------------------------------------------------------------
147 # Compile FOAM, libs and apps
148 add_custom_target (foam-extend-$ENV{WM_PROJECT_VERSION} ALL
149   ${OF_ROOT}/Allwmake
152 set_property(
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
164 # Test section
165 #-----------------------------------------------------------------------------
167 #Enable testing and dashboard
168 ENABLE_TESTING()
169 INCLUDE(CTest)
171 SET (CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
173 SET(
174     CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 1000
175     CACHE INTERNAL "Max number of errors"
177 SET(
178     CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000
179     CACHE INTERNAL "Max number of warnings"
182 IF(BUILD_TESTING)
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
197     #
198     INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/FOAM_Tutorials.cmake)
200     # Add a dummy test (/bin/true, just for debugging)
201     ADD_TEST(
202         foam-extend-$ENV{WM_PROJECT_VERSION}_Dummy_Test true
203     )
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}")
208         EXECUTE_PROCESS(
209             COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForOneTimeStep.sh ${TEST_CASE_DIR}
210             WORKING_DIRECTORY .
211             )
212     ENDIF(RUN_FROM_ONE_TIMESTEP)
214 ENDIF(BUILD_TESTING)
216 # That's it.