foamCheckJobs and foamListJobs no longer require FOAM_JOB_DIR
[freefoam.git] / CMakeLists.txt
blob8f0b25d1ca6676c564570a271dabfebae17f54d4
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 project( FreeFOAM )
34 cmake_minimum_required( VERSION 2.6.0 )
36 # version information
37 set( FF_VERSION_MAJOR 1 )
38 set( FF_VERSION_MINOR 5 )
39 set( FF_VERSION_PATCH 0 )
40 set( FF_VERSION_REVISION 0 )
41 set( FF_VERSION ${FF_VERSION_MAJOR}.${FF_VERSION_MINOR}.${FF_VERSION_PATCH} )
42 set( FF_VERSION_FULL ${FF_VERSION}-${FF_VERSION_REVISION} )
44 # set up custom cmake module path
45 set( CMAKE_MODULE_PATH
46   ${CMAKE_SOURCE_DIR}/CMake
47   ${CMAKE_SOURCE_DIR}/CMake/Modules
48   )
50 # select precision
51 set( FF_PRECISION DP CACHE STRING "Precision with which to compile FreeFOAM. [DP|SP]" )
53 # select whether we want to build framewors on Mac OS X
54 if( APPLE )
55   option( FF_BUILD_FRAMEWORK "Build frameworks on Mac OS X" ON )
56 else( APPLE )
57   set( FF_BUILD_FRAMEWORK OFF )
58 endif( APPLE )
60 # we want shared libraries
61 set( BUILD_SHARED_LIBS SHARED )
63 # use a prefix for executables
64 set (EXECUTABLE_PREFIX "ff_" CACHE STRING "Prefix prepended to all program and script names")
66 # installation directories
67 set( FF_INSTALL_BIN_PATH bin CACHE STRING "Executables installation path (absolute or relative to CMAKE_INSTALL_PREFIX)" )
68 if( APPLE AND FF_BUILD_FRAMEWORK )
69   set( FF_INSTALL_LIB_PATH /Library/Frameworks CACHE STRING "Framework installation path (absolute or relative to CMAKE_INSTALL_PREFIX)" )
70 else( APPLE AND FF_BUILD_FRAMEWORK )
71 set( FF_INSTALL_LIB_PATH lib/${CMAKE_PROJECT_NAME}/${FF_VERSION} CACHE STRING "Library installation path (absolute or relative to CMAKE_INSTALL_PREFIX)" )
72 endif( APPLE AND FF_BUILD_FRAMEWORK )
73 set( FF_INSTALL_HEADER_PATH include/${CMAKE_PROJECT_NAME}/${FF_VERSION} CACHE STRING "Header installation path (absolute or relative to CMAKE_INSTALL_PREFIX, not for frameworks)" )
74 set( FF_INSTALL_CONFIG_PATH etc/${CMAKE_PROJECT_NAME}/${FF_VERSION} CACHE STRING "Configuration files installation path (absolute or relative to CMAKE_INSTALL_PREFIX)" )
75 set( FF_INSTALL_DATA_PATH share/${CMAKE_PROJECT_NAME}/${FF_VERSION} CACHE STRING "Data files installation path (absolute or relative to CMAKE_INSTALL_PREFIX)" )
76 set( FF_INSTALL_PVFOAMREADER_PATH lib/${CMAKE_PROJECT_NAME}/${FF_VERSION}/plugins/PVFoamReader CACHE STRING "ParaView2 OpenFOAM-reader plugin installation path" )
77 set( FF_INSTALL_PV3FOAMREADER_PATH lib/${CMAKE_PROJECT_NAME}/${FF_VERSION}/plugins/PV3FoamReader CACHE STRING "ParaView3 OpenFOAM-reader plugin installation path" )
78 set( FF_INSTALL_USERDFOAM_PATH lib/${CMAKE_PROJECT_NAME}/${FF_VERSION}/plugins/userd-foam CACHE STRING "Ensight OpenFOAM-reader plugin installation path" )
80 # make absolute paths
81 foreach( _p FF_INSTALL_BIN_PATH FF_INSTALL_LIB_PATH FF_INSTALL_HEADER_PATH FF_INSTALL_CONFIG_PATH FF_INSTALL_DATA_PATH )
82   if( NOT IS_ABSOLUTE ${${_p}} )
83     set( ${_p} "${CMAKE_INSTALL_PREFIX}/${${_p}}" )
84   endif( NOT IS_ABSOLUTE ${${_p}} )
85 endforeach( _p )
87 # set up the RPATH for installation
88 set( CMAKE_INSTALL_RPATH ${FF_INSTALL_LIB_PATH} )
90 # we want executables and libraries in one place
91 set( EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE PATH
92   "Single output directory for building all executables." )
93 set( LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/FreeFOAM/${FF_VERSION} CACHE PATH
94   "Single output directory for building all libraries." )
96 # determine computer system
97 include( FFDetermineArch )
99 # find parallel libraries
100 option( FF_USE_MPI "Build ${CMAKE_PROJECT} against MPI parallel libraries" ON )
101 if( FF_USE_MPI )
102   find_package( MPI REQUIRED )
103 endif( FF_USE_MPI )
104 option( FF_USE_PVM "Build ${CMAKE_PROJECT} against PVM parallel libraries" OFF )
105 if( FF_USE_PVM )
106   find_package( PVM REQUIRED )
107 endif( FF_USE_PVM )
108 if( CMAKE_SYSTEM_NAME STREQUAL Linux )
109 option( FF_USE_GAMMA "Build ${CMAKE_PROJECT} against GAMMA parallel libraries" OFF )
110 if( FF_USE_GAMMA )
111   find_package( GAMMA REQUIRED )
112 endif( FF_USE_GAMMA )
113 endif( CMAKE_SYSTEM_NAME STREQUAL Linux )
114 if( MPI_FOUND OR PVM_FOUND OR GAMMA_FOUND )
115   set( FF_USE_PARALLEL TRUE )
116 endif( MPI_FOUND OR PVM_FOUND OR GAMMA_FOUND )
118 # find flex
119 find_package( FLEX REQUIRED )
120 set( FLEX_CXX_FLAGS "-+" CACHE STRING "Flags used by the flex compiler for flex++ targets." )
121 mark_as_advanced( FLEX_CXX_FLAGS )
123 # find zlib
124 find_package( ZLIB REQUIRED )
125 if( NOT ZLIB_FOUND )
126   message( SEND_ERROR "zlib is required! Override ZLIB_* settings [advanced]." )
127 endif( NOT ZLIB_FOUND )
129 # utility
130 include( FFLinkLoadableLibrary )
131 include( FFExportTargetsToBuildTree )
133 # find metis (recent distros have it in their repository, so default to search for that)
134 option( FF_BUILD_PRIVATE_METIS "Download and compile private METIS library instead of searching the system for it" OFF )
135 if( FF_BUILD_PRIVATE_METIS )
136   find_package( Threads REQUIRED )
137   add_subdirectory( ThirdParty/METIS )
138 else( FF_BUILD_PRIVATE_METIS )
139   find_package( Metis REQUIRED )
140   if( NOT METIS_FOUND )
141     message( SEND_ERROR "metis is required! Override METIS_* settings [advanced]." )
142   endif( NOT METIS_FOUND )
143   if( METIS_REQUIRES_MPI AND NOT FF_USE_MPI )
144     message( SEND_ERROR "Your metis implementation requires FF_USE_MPI to be enabled. If you don't have/want MPI, enable FF_BUILD_PRIVATE_METIS instead." )
145   endif( METIS_REQUIRES_MPI AND NOT FF_USE_MPI )
146 endif( FF_BUILD_PRIVATE_METIS )
148 # find ParMetis (recent distros have it in their repository, so default to search for that)
149 if( FF_USE_MPI )
150   option( FF_BUILD_PRIVATE_PARMETIS "Download and compile private ParMetis library instead of searching the system for it" OFF )
151   if( FF_BUILD_PRIVATE_PARMETIS )
152     add_subdirectory( ThirdParty/ParMetis )
153   else( FF_BUILD_PRIVATE_PARMETIS )
154     find_package( ParMetis REQUIRED )
155     if( NOT PARMETIS_FOUND )
156       message( SEND_ERROR "ParMetis is required! Override PARMETIS_* settings [advanced]." )
157     endif( NOT PARMETIS_FOUND )
158   endif( FF_BUILD_PRIVATE_PARMETIS )
159 else( FF_USE_MPI )
160   message( STATUS "NOTE: Not using ParMetis because FF_USE_MPI not selected." )
161 endif( FF_USE_MPI )
163 # find mgridgen (not commonly available, default to private build)
164 option( FF_BUILD_PRIVATE_PARMGRIDGEN "Download and compile private PARMGRIDGEN library instead of searching the system for it" ON )
165 if( FF_BUILD_PRIVATE_PARMGRIDGEN )
166   add_subdirectory( ThirdParty/PARMGRIDGEN )
167 else( FF_BUILD_PRIVATE_PARMGRIDGEN )
168   if( FF_PRECISION STREQUAL SP )
169     set( MGRIDGEN_USE_REAL ON )
170   endif( FF_PRECISION STREQUAL SP )
171   find_package( MGRIDGEN REQUIRED )
172   if( NOT MGRIDGEN_FOUND )
173     message( SEND_ERROR "MGRIDGEN is required! Override MGRIDGEN_* settings [advanced]." )
174   endif( NOT MGRIDGEN_FOUND )
175 endif( FF_BUILD_PRIVATE_PARMGRIDGEN )
177 # find ccmio (not commonly available, default to private build)
178 option( FF_BUILD_PRIVATE_CCMIO "Download and compile private CCMIO library instead of searching the system for it" ON )
179 if( FF_BUILD_PRIVATE_CCMIO )
180   add_subdirectory( ThirdParty/ccmio )
181 else( FF_BUILD_PRIVATE_CCMIO )
182   find_package( Ccmio REQUIRED )
183   if( NOT CCMIO_FOUND )
184     message( SEND_ERROR "ccmio is required! Override CCMIO_* settings [advanced]." )
185   endif( NOT CCMIO_FOUND )
186 endif( FF_BUILD_PRIVATE_CCMIO )
188 # ask user whether she wants to build ParaView plugins
189 option( FF_BUILD_PARAVIEW_PLUGINS "Build the ParaView plugins. Requires a ParaView build tree." ON )
190 if( FF_BUILD_PARAVIEW_PLUGINS )
191   # find ParaView, which also find the VTK which has been used to build ParaView
192   find_package( ParaView REQUIRED )
193 endif( FF_BUILD_PARAVIEW_PLUGINS )
195 # figure out default Pstream library
196 if( FF_USE_MPI )
197   set( _FF_DEFAULT_PSTREAM mpi )
198 elseif( FF_USE_PVM )
199   set( _FF_DEFAULT_PSTREAM pvm )
200 elseif( FF_USE_GAMMA )
201   set( _FF_DEFAULT_PSTREAM gamma )
202 else( FF_USE_MPI )
203   set( _FF_DEFAULT_PSTREAM dummy )
204 endif( FF_USE_MPI )
205 set( FF_DEFAULT_PSTREAM ${_FF_DEFAULT_PSTREAM} CACHE STRING "Default Pstream library implementation [dummy|mpi|pvm|gamma]" )
206 mark_as_advanced( FF_DEFAULT_PSTREAM )
208 # set up defines
209 add_definitions(
210   -D${FF_PRECISION}
211   -DNoRepository
212   -D${FF_OS}
213   )
215 # tools for building the include tree
216 include( createIncludeWrappers )
217 include_directories( ${CMAKE_BINARY_DIR}/include )
219 # descend into the sources...
220 add_subdirectory( bin )
221 add_subdirectory( src )
222 add_subdirectory( applications )
224 # export the library dependencies to the build tree
225 ff_export_targets_to_build_tree()
227 # export build settings and library dependencies
228 include( CMakeExportBuildSettings )
229 cmake_export_build_settings( ${LIBRARY_OUTPUT_PATH}/FreeFOAMBuildSettings.cmake )
231 # create FreeFOAMConfig.cmake for the build tree
232 set( CONFIG_DEFINITIONS -DNoRepository -D${FF_OS} -D${FF_PRECISION} )
233 if( APPLE )
234   list( APPEND CONFIG_DEFINITIONS -Ddarwin )
235 endif( APPLE )
236 set( CONFIG_HEADER_PATH ${CMAKE_BINARY_DIR}/include )
237 set( CONFIG_LIBRARY_PATH ${LIBRARY_OUTPUT_PATH} )
238 set( CONFIG_USE_FILE_PATH ${CMAKE_SOURCE_DIR} )
239 configure_file(
240   ${CMAKE_SOURCE_DIR}/FreeFOAMConfig.cmake.in
241   ${CMAKE_BINARY_DIR}/FreeFOAMConfig.cmake
242   @ONLY
243   )
245 # create FreeFOAMConfig.cmake for the install tree
246 set( CONFIG_HEADER_PATH ${FF_INSTALL_HEADER_PATH} )
247 set( CONFIG_LIBRARY_PATH ${FF_INSTALL_LIB_PATH} )
248 set( CONFIG_USE_FILE_PATH ${FF_INSTALL_LIB_PATH} )
249 configure_file(
250   ${CMAKE_SOURCE_DIR}/FreeFOAMConfig.cmake.in
251   ${CMAKE_BINARY_DIR}/InstallFiles/FreeFOAMConfig.cmake
252   @ONLY
253   )
255 # install the CMake config files
256 install( FILES
257   FreeFOAMUse.cmake
258   ${CMAKE_BINARY_DIR}/InstallFiles/FreeFOAMConfig.cmake
259   ${LIBRARY_OUTPUT_PATH}/FreeFOAMBuildSettings.cmake
260   DESTINATION ${FF_INSTALL_LIB_PATH}
261   COMPONENT dev
262   )
264 # install the FreeFOAMLibraryDepends.cmake file
265 install( EXPORT FreeFOAMLibraryDepends
266   DESTINATION ${FF_INSTALL_LIB_PATH}
267   NAMESPACE FF_
268   COMPONENT dev
269   )
271 # install the config files
272 install( FILES
273   etc/controlDict
274   etc/cellModels
275   DESTINATION ${FF_INSTALL_CONFIG_PATH}
276   COMPONENT config
277   )
278 install( DIRECTORY
279   etc/thermoData
280   DESTINATION ${FF_INSTALL_CONFIG_PATH}
281   COMPONENT config
282   )
284 # install the data files
285 install( FILES
286   data/templates/foamCommentStyles
287   data/templates/foamScript
288   data/templates/foamAppTemplate.C
289   data/templates/foamTemplate.C
290   data/templates/foamTemplate.H
291   data/templates/foamTemplateI.H
292   data/templates/foamTemplateIO.C
293   data/templates/foamUtilTemplate.cfg
294   data/templates/foamTemplateTemplate.C
295   data/templates/foamTemplateTemplate.H
296   data/templates/foamTemplateTemplateI.H
297   data/templates/foamTemplateTemplateIO.C
298   DESTINATION ${FF_INSTALL_DATA_PATH}/templates/
299   COMPONENT data
300   )
302 # pack things up
303 include( FreeFOAMCPack )
305 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file