ThirdParty packages: modification for calling make another compiler than gcc
[openfoam-extend-OpenFOAM-1.6-ext.git] / CMakeLists.txt
blobaac37fb6ddf43f172843fcf70183c4a946c13e8e
1 # /*-------------------------------------------------------------------------*\
2 #   =========                 |
3 #   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4 #    \\    /   O peration     |
5 #     \\  /    A nd           | Copyright held by original author
6 #      \\/     M anipulation  |
7 # -----------------------------------------------------------------------------
8 # License
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
19 #     for more details.
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
25 # Description
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
30 #     CTestConfig.cmake
32 # Author
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
50     SET(
51           SITENAME $ENV{CDASH_SUBMIT_LOCAL_HOST_ID}
52           CACHE STRING "Name of the local site"
53     )
54 ELSE (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
55     # Grab the hostname FQN; will be used for the sitename
56     execute_process(
57         COMMAND         hostname -f
58         OUTPUT_VARIABLE SITENAME
59     )
60 ENDIF  (NOT $ENV{CDASH_SUBMIT_LOCAL_HOST_ID} STREQUAL "")
62 MESSAGE("Initializing the name of this local site to:  ${SITENAME}")
64 SET(
65     SITE ${SITENAME}
66     CACHE STRING "Name of the local site"
69 #Grab the OpenFOAM installation directory.
70 SET(
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.
78 SET(
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}
87   ARGS -dumpversion
88   OUTPUT_VARIABLE COMPILER_VERSION
90 SET(BUILDNAME "${BUILDNAME}-$ENV{WM_CC}${COMPILER_VERSION}")  
92 # We will support more compilers eventually.
93
95 # Timeout for running every single test: 4 hours: 4 x 3600 seconds
96 #SET(
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
101 SET(
102     DART_TESTING_TIMEOUT 600
103     CACHE STRING "Maximum time allowed (10 minutes) before CTest will kill the test."
106 SET(
107     CMAKE_VERBOSE_MAKEFILE TRUE
111 # Update section
112 #-----------------------------------------------------------------------------
113 set (UPDATE_TYPE git)
116 # Using GIT as SCM
118 find_package(Git)
119 if(GIT_FOUND)
120     message("Git was found: ${GIT_EXECUTABLE}")
122     # Adding the name of the git branch to the build name
123     EXEC_PROGRAM(git
124       ARGS branch --no-color 2> /dev/null | grep '*'| awk '{print $2}'
125       OUTPUT_VARIABLE GIT_BRANCH_NAME
126     )
127     message("Git branch: ${GIT_BRANCH_NAME}")
128     if (GIT_BRANCH_NAME STREQUAL "")
129        message("No git-branch. Mercurial?")
130        EXEC_PROGRAM(hg
131          ARGS branch
132          OUTPUT_VARIABLE GIT_BRANCH_NAME
133        )
134        message("Git branch (mercurial): ${GIT_BRANCH_NAME}")
135     endif()
136     SET(BUILDNAME "${BUILDNAME}-git-branch=${GIT_BRANCH_NAME}")  
137 endif()
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})
145 # Build section
146 #-----------------------------------------------------------------------------
148 # Compile OpenFOAM, libs and apps
149 add_custom_target (OpenFOAM-$ENV{WM_PROJECT_VERSION} ALL
150   ${OF_ROOT}/Allwmake
153 set_property(
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
165 # Test section
166 #-----------------------------------------------------------------------------
168 #Enable testing and dashboard
169 ENABLE_TESTING()
170 INCLUDE(CTest)
172 SET (CTEST_UPDATE_COMMAND ${GIT_EXECUTABLE})
174 SET(
175     CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 1000
176     CACHE INTERNAL "Max number of errors"
178 SET(
179     CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000
180     CACHE INTERNAL "Max number of warnings"
183 IF(BUILD_TESTING)
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
198     #
199     INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/OpenFOAM_Tutorials.cmake)
201     # Add a dummy test (/bin/true, just for debugging)
202     ADD_TEST(
203         OpenFOAM-$ENV{WM_PROJECT_VERSION}_Dummy_Test true
204     )
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}")
209         EXECUTE_PROCESS(
210             COMMAND $ENV{FOAM_TEST_HARNESS_DIR}/scripts/prepareCasesForOneTimeStep.sh ${TEST_CASE_DIR}
211             WORKING_DIRECTORY .
212             )
213     ENDIF(RUN_FROM_ONE_TIMESTEP)
215 ENDIF(BUILD_TESTING)
217 # That's it.