1 #-------------------------------------------------------------------------------
3 # | ____| _| |_ / __ \ /\ | \/ |
4 # | |__ _ __ ___ ___ / \| | | | / \ | \ / |
5 # | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
6 # | | | | | __/ __/\_ _/| |__| / ____ \| | | |
7 # |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
9 # FreeFOAM: The Cross-Platform CFD Toolkit
11 # Copyright (C) 2008-2010 Michael Wild <themiwi@users.sf.net>
12 # Gerber van der Graaf <gerber_graaf@users.sf.net>
13 #-------------------------------------------------------------------------------
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
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 # Do feature detection
33 # ~~~~~~~~~~~~~~~~~~~~
35 include(CheckCXXSourceCompiles)
36 include(CheckVariableExists)
37 include(CheckIncludeFile)
38 include(CheckFunctionExists)
40 # look for __malloc_hook
41 check_variable_exists(__malloc_hook FOAM_HAVE_MALLOC_HOOK)
44 check_include_file(fenv.h FOAM_HAVE_FENV_H)
46 # look for feenableexcept
47 check_function_exists(feenableexcept FOAM_HAVE_FEENABLEEXCEPT)
50 check_include_file(sigfpe.h FOAM_HAVE_SIGFPE_H)
52 # look for handle_sigfpes
53 check_function_exists(handle_sigfpes FOAM_HAVE_HANDLE_SIGFPES)
58 # file suffix for python executables
60 set(FOAM_PY_SCRIPT_SUFFIX ".py")
62 set(FOAM_PY_SCRIPT_SUFFIX "")
68 execute_process(COMMAND uname -s OUTPUT_VARIABLE FOAM_OSNAME OUTPUT_STRIP_TRAILING_WHITESPACE)
69 execute_process(COMMAND uname -m OUTPUT_VARIABLE FOAM_CPUNAME OUTPUT_STRIP_TRAILING_WHITESPACE)
71 message(FATAL_ERROR "${CMAKE_PROJECT_NAME} only runs under UNIX-like systems (Linux, Solaris, Mac OS X,...)")
75 set(FOAM_DEFAULT_64_BIT OFF)
76 if(FOAM_CPUNAME MATCHES ".*64" OR FOAM_OSNAME MATCHES ".*64")
77 set(FOAM_DEFAULT_64_BIT ON)
78 option(FOAM_64_BIT "Compile ${CMAKE_PROJECT_NAME} in 64 bit." ${FOAM_DEFAULT_64_BIT})
79 mark_as_advanced(FOAM_64_BIT)
81 set(FOAM_64_BIT ${FOAM_DEFAULT_64_BIT})
87 if(FOAM_OSNAME STREQUAL Linux)
88 if(FOAM_CPUNAME STREQUAL i686)
90 elseif(FOAM_CPUNAME STREQUAL x86_64)
96 elseif(FOAM_CPUNAME STREQUAL ia64)
97 set(FOAM_OS linuxIA64)
98 elseif(FOAM_CPUNAME STREQUAL mips64)
99 set(FOAM_OS SiCortex64)
101 message(STATUS Unknown processor type ${FOAM_CPUNAME} for Linux)
105 if(FOAM_OS STREQUAL linux)
106 set(LINUX_COMPILE_OPTS -m32)
107 elseif(FOAM_OS STREQUAL linux64)
108 set(LINUX_COMPILE_OPTS -m64)
109 elseif(FOAM_OS STREQUAL SiCortex64)
110 set(LINUX_COMPILE_OPTS -mabi=64)
111 set(LINUX_LINK_OPTS -G0)
113 set(LINUX_COMPILE_OPTS)
116 set(CMAKE_C_FLAGS ${LINUX_COMPILE_OPTS} ${LINUX_LINK_OPTS} CACHE STRING
117 "Flags for C compiler.")
118 set(CMAKE_CXX_FLAGS ${LINUX_COMPILE_OPTS} ${LINUX_LINK_OPTS} CACHE STRING
119 "Flags used by the compiler during all build types.")
120 set(CMAKE_SHARED_LINKER_FLAGS ${LINUX_COMPILE_OPTS} ${LINUX_LINK_OPTS} CACHE STRING
121 "Flags used by the linker during the creation of shared libs.")
125 elseif(FOAM_OSNAME STREQUAL SunOS)
127 set(SUNOS_COMPILE_FLAGS -mabi=64)
128 set(CMAKE_C_FLAGS ${SUNOS_COMPILE_OPTS} CACHE STRING
129 "Flags for C compiler.")
130 set(CMAKE_CXX_FLAGS ${SUNOS_COMPILE_OPTS} CACHE STRING
131 "Flags used by the compiler during all build types.")
132 set(CMAKE_SHARED_LINKER_FLAGS ${SUNOS_COMPILE_OPTS} -G0 CACHE STRING
133 "Flags used by the linker during the creation of shared libs.")
135 # Silicon Graphics workstation
136 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137 elseif(FOAM_OSNAME STREQUAL IRIX OR FOAM_OSNAME STREQUAL IRIX64)
145 set(FOAM_DEFAULT_MPLIB_NAME MPICH-GM)
147 # Mac OS X 10.4/5 Darwin
148 # ~~~~~~~~~~~~~~~~~~~~
149 elseif(FOAM_OSNAME STREQUAL Darwin)
151 execute_process(COMMAND arch OUTPUT_VARIABLE FOAM_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
152 if(FOAM_ARCH STREQUAL i386)
154 elseif(FOAM_ARCH STREQUAL ppc)
157 set(FOAM_OS darwin${FOAM_ARCH})
159 foam_fix_apple_gcc_bug()
161 # An unsupported operating system
162 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165 message(STATUS "Your ${FOAM_OSNAME} operating system is not supported
166 by this release of FreeFOAM. Things might work out of the box if you're
167 lucky, require some tweaking or just blow up into your face. For further
168 assistance please contact http://freefoam.sf.net.")
174 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file