STYLE: Refer to FreeFOAM web page in FFDetermineArch.cmake
[freefoam.git] / CMake / FFDetermineArch.cmake
blob24893501449e73adbea71e887c92a93461f18748
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 )
124 # An unsupported operating system
125 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126 else( FF_OSNAME STREQUAL Linux )
128   message( STATUS "Your ${FF_OSNAME} operating system is not supported
129   by this release of FreeFOAM. Things might work out of the box if you're
130   lucky, require some tweaking or just blow up into your face. For further
131   assistance please contact http://freefoam.sf.net." )
133   set( FF_OS generic )
135 endif( FF_OSNAME STREQUAL Linux )
137 # Do feature detection
138 # ~~~~~~~~~~~~~~~~~~~~
140 include( CheckVariableExists )
141 include( CheckIncludeFile )
142 include( CheckFunctionExists )
144 # look for __malloc_hook
145 check_variable_exists( __malloc_hook FF_HAVE_MALLOC_HOOK )
147 # look for fenv.h
148 check_include_file( fenv.h FF_HAVE_FENV_H )
150 # look for feenableexcept
151 check_function_exists( feenableexcept FF_HAVE_FEENABLEEXCEPT )
153 # look for sigfpe.h
154 check_include_file( sigfpe.h FF_HAVE_SIGFPE_H )
156 # look for handle_sigfpes
157 check_function_exists( handle_sigfpes FF_HAVE_HANDLE_SIGFPES )
159 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file