FIX: bugs in Allrun.in scripts
[freefoam.git] / CMake / FFDetermineArch.cmake
blobdad92f533a3d8bafc13f73e628034c51d24175f0
1 #-------------------------------------------------------------------------------
2 #                ______             ______ ____          __  __
3 #               |  ____|           |  ____/ __ \   /\   |  \/  |
4 #               | |__ _ __ ___  ___| |__ | |  | | /  \  | \  / |
5 #               |  __| '__/ _ \/ _ \  __|| |  | |/ /\ \ | |\/| |
6 #               | |  | | |  __/  __/ |   | |__| / ____ \| |  | |
7 #               |_|  |_|  \___|\___|_|    \____/_/    \_\_|  |_|
9 #                   FreeFOAM: The Cross-Platform CFD Toolkit
11 # Copyright (C) 2008 Michael Wild <themiwi@users.sf.net>
12 #                    Gerber van der Graaf <gerber_graaf@users.sf.net>
13 #-------------------------------------------------------------------------------
14 # License
15 #   This file is part of FreeFOAM.
17 #   FreeFOAM is free software; you can redistribute it and/or modify it
18 #   under the terms of the GNU General Public License as published by the
19 #   Free Software Foundation; either version 2 of the License, or (at your
20 #   option) any later version.
22 #   FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
23 #   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 #   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25 #   for more details.
27 #   You should have received a copy of the GNU General Public License
28 #   along with FreeFOAM; if not, write to the Free Software Foundation,
29 #   Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #-------------------------------------------------------------------------------
32 if( UNIX )
33   execute_process( COMMAND uname -s OUTPUT_VARIABLE FF_OSNAME OUTPUT_STRIP_TRAILING_WHITESPACE )
34   execute_process( COMMAND uname -m OUTPUT_VARIABLE FF_CPUNAME OUTPUT_STRIP_TRAILING_WHITESPACE )
35 else( UNIX )
36   message( FATAL_ERROR "${CMAKE_PROJECT_NAME} only runs under UNIX-like systems (Linux, Solaris, Mac OS X,...)")
37 endif( UNIX )
39 # 64 bit possible?
40 set( FF_DEFAULT_64_BIT OFF )
41 if( FF_CPUNAME MATCHES ".*64" OR FF_OSNAME MATCHES ".*64" )
42   set( FF_DEFAULT_64_BIT ON )
43   option( FF_64_BIT "Compile ${CMAKE_PROJECT_NAME} in 64 bit." ${FF_DEFAULT_64_BIT} )
44 else( FF_CPUNAME MATCHES ".*64" OR FF_OSNAME MATCHES ".*64" )
45   set( FF_64_BIT ${FF_DEFAULT_64_BIT} )
46 endif( FF_CPUNAME MATCHES ".*64" OR FF_OSNAME MATCHES ".*64" )
49 # linux
50 #~~~~~~
51 if( FF_OSNAME STREQUAL Linux )
52   if( FF_CPUNAME STREQUAL i686 )
53     set( FF_OS linux )
54   elseif( FF_CPUNAME STREQUAL x86_64 )
55     if( FF_64_BIT )
56       set( FF_OS linux64 )
57     else( FF_64_BIT )
58       set( FF_OS linux )
59     endif( FF_64_BIT )
60   elseif( FF_CPUNAME STREQUAL ia64 )
61     set( FF_OS linuxIA64 )
62   elseif( FF_CPUNAME STREQUAL mips64 )
63     set( FF_OS SiCortex64 )
64   else( FF_CPUNAME STREQUAL i686 )
65     message( STATUS  Unknown processor type ${FF_CPUNAME} for Linux )
66   endif( FF_CPUNAME STREQUAL i686 )
68   set( LINUX_LINK_OPTS )
69   if( FF_OS STREQUAL linux )
70     set( LINUX_COMPILE_OPTS -m32 )
71   elseif( FF_OS STREQUAL linux64 )
72     set( LINUX_COMPILE_OPTS -m64 )
73   elseif( FF_OS STREQUAL SiCortex64 )
74     set( LINUX_COMPILE_OPTS -mabi=64 )
75     set( LINUX_LINK_OPTS  -G0 )
76   else( FF_OS STREQUAL linux )
77     set( LINUX_COMPILE_OPTS )
78   endif( FF_OS STREQUAL linux )
80   set( CMAKE_C_FLAGS ${LINUX_COMPILE_OPTS} ${LINUX_LINK_OPTS} CACHE STRING
81     "Flags for C compiler." )
82   set( CMAKE_CXX_FLAGS ${LINUX_COMPILE_OPTS} ${LINUX_LINK_OPTS} CACHE STRING
83     "Flags used by the compiler during all build types." )
84   set( CMAKE_SHARED_LINKER_FLAGS ${LINUX_COMPILE_OPTS} ${LINUX_LINK_OPTS} CACHE STRING
85     "Flags used by the linker during the creation of shared libs." )
87 # SUN workstation
88 # ~~~~~~~~~~~~~~~
89 elseif( FF_OSNAME STREQUAL SunOS )
90   set( FF_OS SunOS64 )
91   set( SUNOS_COMPILE_FLAGS -mabi=64 )
92   set( CMAKE_C_FLAGS ${SUNOS_COMPILE_OPTS} CACHE STRING
93     "Flags for C compiler." )
94   set( CMAKE_CXX_FLAGS ${SUNOS_COMPILE_OPTS} CACHE STRING
95     "Flags used by the compiler during all build types." )
96   set( CMAKE_SHARED_LINKER_FLAGS ${SUNOS_COMPILE_OPTS} -G0 CACHE STRING
97     "Flags used by the linker during the creation of shared libs." )
99 # Silicon Graphics workstation
100 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101 elseif( FF_OSNAME STREQUAL IRIX OR FF_OSNAME STREQUAL IRIX64 )
103   if( FF_64_BIT )
104     set( FF_OS sgi64 )
105   else( FF_64_BIT )
106     set( FF_OS sgiN32 )
107   endif( FF_64_BIT )
109   set( FF_DEFAULT_MPLIB_NAME MPICH-GM )
111 # Mac OS X 10.4/5 Darwin
112 # ~~~~~~~~~~~~~~~~~~~~
113 elseif( FF_OSNAME STREQUAL Darwin )
115   execute_process( COMMAND arch OUTPUT_VARIABLE FF_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE )
116   if( FF_ARCH STREQUAL i386 )
117     set( FF_ARCH Intel )
118   elseif( FF_ARCH STREQUAL ppc )
119     set( FF_ARCH Ppc )
120   endif( FF_ARCH STREQUAL i386 )
121   set( FF_OS darwin${FF_ARCH} )
122   add_definitions( -Ddarwin )
123   # for malloc.h
124   include_directories( /usr/include/malloc )
126 # An unsupported operating system
127 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128 else( FF_OSNAME STREQUAL Linux )
130   message( STATUS "Your ${FF_OSNAME} operating system is not supported
131   by this release of FreeFOAM. Things might work out of the box if you're
132   lucky, require some tweaking or just blow up into your face. For further
133   assistance please contact www.openfoam.org." )
135   set( FF_OS generic )
137 endif( FF_OSNAME STREQUAL Linux )
139 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file