1 #-------------------------------------------------------------------------------
3 # | ____| _| |_ / __ \ /\ | \/ |
4 # | |__ _ __ ___ ___ / \| | | | / \ | \ / |
5 # | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
6 # | | | | | __/ __/\_ _/| |__| / ____ \| | | |
7 # |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
9 # FreeFOAM: The Cross-Platform CFD Toolkit
11 # Copyright (C) 2008-2012 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 3 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, see <http://www.gnu.org/licenses/>.
29 #-------------------------------------------------------------------------------
31 # Do feature detection
32 # ~~~~~~~~~~~~~~~~~~~~
34 include(CheckCXXSourceCompiles)
35 include(CheckVariableExists)
36 include(CheckIncludeFile)
37 include(CheckFunctionExists)
39 # look for __malloc_hook
40 check_variable_exists(__malloc_hook FOAM_HAVE_MALLOC_HOOK)
43 check_include_file(fenv.h FOAM_HAVE_FENV_H)
45 # look for feenableexcept
46 check_function_exists(feenableexcept FOAM_HAVE_FEENABLEEXCEPT)
49 check_include_file(sigfpe.h FOAM_HAVE_SIGFPE_H)
51 # look for handle_sigfpes
52 check_function_exists(handle_sigfpes FOAM_HAVE_HANDLE_SIGFPES)
57 # file suffix for python executables
59 set(FOAM_PY_SCRIPT_SUFFIX ".py")
61 set(FOAM_PY_SCRIPT_SUFFIX "")
67 execute_process(COMMAND uname -s OUTPUT_VARIABLE FOAM_OSNAME OUTPUT_STRIP_TRAILING_WHITESPACE)
68 execute_process(COMMAND uname -m OUTPUT_VARIABLE FOAM_CPUNAME OUTPUT_STRIP_TRAILING_WHITESPACE)
70 message(FATAL_ERROR "${CMAKE_PROJECT_NAME} only runs under UNIX-like systems (Linux, Solaris, Mac OS X,...)")
74 set(FOAM_DEFAULT_64_BIT OFF)
75 if(FOAM_CPUNAME MATCHES ".*64" OR FOAM_OSNAME MATCHES ".*64")
76 set(FOAM_DEFAULT_64_BIT ON)
77 option(FOAM_64_BIT "Compile ${CMAKE_PROJECT_NAME} in 64 bit." ${FOAM_DEFAULT_64_BIT})
78 mark_as_advanced(FOAM_64_BIT)
80 set(FOAM_64_BIT ${FOAM_DEFAULT_64_BIT})
86 if(FOAM_OSNAME STREQUAL Linux)
87 if(FOAM_CPUNAME STREQUAL i686)
89 elseif(FOAM_CPUNAME STREQUAL x86_64)
95 elseif(FOAM_CPUNAME STREQUAL ia64)
96 set(FOAM_OS linuxIA64)
97 elseif(FOAM_CPUNAME STREQUAL mips64)
98 set(FOAM_OS SiCortex64)
100 message(STATUS Unknown processor type ${FOAM_CPUNAME} for Linux)
104 if(FOAM_OS STREQUAL linux)
105 set(LINUX_COMPILE_OPTS -m32)
106 elseif(FOAM_OS STREQUAL linux64)
107 set(LINUX_COMPILE_OPTS -m64)
108 elseif(FOAM_OS STREQUAL SiCortex64)
109 set(LINUX_COMPILE_OPTS -mabi=64)
110 set(LINUX_LINK_OPTS -G0)
112 set(LINUX_COMPILE_OPTS)
115 set(CMAKE_C_FLAGS ${LINUX_COMPILE_OPTS} ${LINUX_LINK_OPTS} CACHE STRING
116 "Flags for C compiler.")
117 set(CMAKE_CXX_FLAGS ${LINUX_COMPILE_OPTS} ${LINUX_LINK_OPTS} CACHE STRING
118 "Flags used by the compiler during all build types.")
119 set(CMAKE_SHARED_LINKER_FLAGS ${LINUX_COMPILE_OPTS} ${LINUX_LINK_OPTS} CACHE STRING
120 "Flags used by the linker during the creation of shared libs.")
124 elseif(FOAM_OSNAME STREQUAL SunOS)
126 set(SUNOS_COMPILE_FLAGS -mabi=64)
127 set(CMAKE_C_FLAGS ${SUNOS_COMPILE_OPTS} CACHE STRING
128 "Flags for C compiler.")
129 set(CMAKE_CXX_FLAGS ${SUNOS_COMPILE_OPTS} CACHE STRING
130 "Flags used by the compiler during all build types.")
131 set(CMAKE_SHARED_LINKER_FLAGS ${SUNOS_COMPILE_OPTS} -G0 CACHE STRING
132 "Flags used by the linker during the creation of shared libs.")
134 # Silicon Graphics workstation
135 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
136 elseif(FOAM_OSNAME STREQUAL IRIX OR FOAM_OSNAME STREQUAL IRIX64)
144 set(FOAM_DEFAULT_MPLIB_NAME MPICH-GM)
146 # Mac OS X 10.4/5 Darwin
147 # ~~~~~~~~~~~~~~~~~~~~
148 elseif(FOAM_OSNAME STREQUAL Darwin)
150 execute_process(COMMAND arch OUTPUT_VARIABLE FOAM_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
151 if(FOAM_ARCH STREQUAL i386)
153 elseif(FOAM_ARCH STREQUAL ppc)
156 set(FOAM_OS darwin${FOAM_ARCH})
158 foam_fix_apple_gcc_bug()
160 # An unsupported operating system
161 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164 message(STATUS "Your ${FOAM_OSNAME} operating system is not supported
165 by this release of FreeFOAM. Things might work out of the box if you're
166 lucky, require some tweaking or just blow up into your face. For further
167 assistance please contact http://freefoam.sf.net.")
173 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file