DOC: Minor formatting problems in the UserGuide
[freefoam.git] / CMake / foam_apply_patch.cmake.in
blob2750bf80c0b06146644de191f7803f8a13b7eea7
1 # - Script file to apply a patch in a smart way to a external project
3 # The script will create a stamp file in the external projects source
4 # directory, thus making it possible to prevent re-applying of the same patch.
6 # It takes the variable PATCH_FILE as an argument.
9 #-------------------------------------------------------------------------------
10 #               ______                _     ____          __  __
11 #              |  ____|             _| |_  / __ \   /\   |  \/  |
12 #              | |__ _ __ ___  ___ /     \| |  | | /  \  | \  / |
13 #              |  __| '__/ _ \/ _ ( (| |) ) |  | |/ /\ \ | |\/| |
14 #              | |  | | |  __/  __/\_   _/| |__| / ____ \| |  | |
15 #              |_|  |_|  \___|\___|  |_|   \____/_/    \_\_|  |_|
17 #                   FreeFOAM: The Cross-Platform CFD Toolkit
19 # Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
20 #                         Gerber van der Graaf <gerber_graaf@users.sf.net>
21 #-------------------------------------------------------------------------------
22 # License
23 #   This file is part of FreeFOAM.
25 #   FreeFOAM is free software: you can redistribute it and/or modify it
26 #   under the terms of the GNU General Public License as published by the
27 #   Free Software Foundation, either version 3 of the License, or (at your
28 #   option) any later version.
30 #   FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
31 #   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
32 #   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
33 #   for more details.
35 #   You should have received a copy of the GNU General Public License
36 #   along with FreeFOAM.  If not, see <http://www.gnu.org/licenses/>.
38 # Description
39 #   Smart patching for external projects
41 #-------------------------------------------------------------------------------
43 if(NOT DEFINED PATCH_FILE)
44   message(FATAL_ERROR "Variable PATCH_FILE not defined")
45 elseif(NOT EXISTS "${PATCH_FILE}")
46   message(FATAL_ERROR "The file '${PATCH_FILE}' does not exist")
47 endif()
49 set(stamp _foam_patch.stamp)
50 if(NOT EXISTS ${stamp})
51   execute_process(
52     COMMAND "@PATCH_EXECUTABLE@" -p1 -N -i "${PATCH_FILE}"
53     RESULT_VARIABLE PATCH_RESULT
54     OUTPUT_VARIABLE PATCH_OUTPUT
55     )
56   if(PATCH_RESULT)
57     message(FATAL_ERROR "The patch program failed with:\n${PATCH_OUTPUT}")
58   endif()
59   execute_process(
60     COMMAND "@CMAKE_COMMAND@" -E touch ${stamp}
61     )
62 endif()