2 #-------------------------------------------------------------------------------
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 #-------------------------------------------------------------------------------
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
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/>.
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")
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
53 foreach(f ${absfiles})
54 file(RELATIVE_PATH f "${CMAKE_CURRENT_SOURCE_DIR}" "${f}")
55 list(APPEND files "${f}")
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)
69 # write the CMakeLists.txt
70 file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" "
71 cmake_minimum_required(VERSION 2.8)
74 find_package(FreeFOAM REQUIRED)
75 include("\${FOAM_USE_FILE}")
77 set_source_files_properties(
80 PROPERTIES HEADER_FILE_ONLY TRUE
83 foam_add_${type}(\${PROJECT_NAME}
87 target_link_libraries(\${PROJECT_NAME}