FIX: New a2x (since 8.6.7) options in doxyToX.py
[freefoam.git] / data / utilities / wmakeToCMake.cmake.in
blob3161de7dac0f318c3c7c0df5f9af096c54455ec7
1 #!@CMAKE_COMMAND@ -P
2 #-------------------------------------------------------------------------------
3 #               ______                _     ____          __  __
4 #              |  ____|             _| |_  / __ \   /\   |  \/  |
5 #              | |__ _ __ ___  ___ /     \| |  | | /  \  | \  / |
6 #              |  __| '__/ _ \/ _ ( (| |) ) |  | |/ /\ \ | |\/| |
7 #              | |  | | |  __/  __/\_   _/| |__| / ____ \| |  | |
8 #              |_|  |_|  \___|\___|  |_|   \____/_/    \_\_|  |_|
10 #                   FreeFOAM: The Cross-Platform CFD Toolkit
12 # Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
13 #                         Gerber van der Graaf <gerber_graaf@users.sf.net>
14 #-------------------------------------------------------------------------------
15 # License
16 #   This file is part of FreeFOAM.
18 #   FreeFOAM is free software: you can redistribute it and/or modify it
19 #   under the terms of the GNU General Public License as published by the
20 #   Free Software Foundation, either version 3 of the License, or (at your
21 #   option) any later version.
23 #   FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
24 #   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 #   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26 #   for more details.
28 #   You should have received a copy of the GNU General Public License
29 #   along with FreeFOAM.  If not, see <http://www.gnu.org/licenses/>.
31 # Script
32 #   wmakeToCMake
34 # Description
35 #   Simple utility to convert a wmake based build system to CMake.
37 #------------------------------------------------------------------------------
39 # safe-guard against overwriting
40 if(EXISTS "CMakeLists.txt")
41   message(FATAL_ERROR "CMakeLists.txt already exists")
42 endif()
44 # get the tools to do the heavy lifting
45 include("@FOAM_CMAKECONFIG_DIR@/@PROJECT_NAME@WmakeCompatibility.cmake")
47 # parse Make/files and Make/options
48 _foam_awt_parse(type target absfiles libs incdirs
49   "${CMAKE_CURRENT_SOURCE_DIR}")
51 # turn file paths into relative paths
52 set(files)
53 foreach(f ${absfiles})
54   file(RELATIVE_PATH f "${CMAKE_CURRENT_SOURCE_DIR}" "${f}")
55   list(APPEND files "${f}")
56 endforeach()
58 # transform into nicely formatted lists
59 string(REPLACE ";" "\n  " files "${files}")
60 string(REPLACE ";" "\n  " libs "${libs}")
62 # prepare the call to foam_add_(executable|library)
63 if(type STREQUAL EXE)
64   set(type executable)
65 else()
66   set(type library)
67 endif()
69 # write the CMakeLists.txt
70 file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" "
71 cmake_minimum_required(VERSION 2.8)
72 project(${target})
74 find_package(FreeFOAM REQUIRED)
75 include("\${FOAM_USE_FILE}")
77 set_source_files_properties(
78   Make/files
79   Make/options
80   PROPERTIES HEADER_FILE_ONLY TRUE
81   )
83 foam_add_${type}(\${PROJECT_NAME}
84   ${files}
85   )
87 target_link_libraries(\${PROJECT_NAME}
88   ${libs}
89   )