DOC: Updated and simplified HACKING
[freefoam.git] / CMakeLists.txt
blobb1936c1e03d8cc55b1607c1a07e62088cffb8c3d
1 #-------------------------------------------------------------------------------
2 #               ______                _     ____          __  __
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 #-------------------------------------------------------------------------------
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 cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
34 project(FreeFOAM)
36 string(TOLOWER "${PROJECT_NAME}" LOWER_PROJECT_NAME)
38 # version information
39 set(FOAM_VERSION_MAJOR 0)
40 set(FOAM_VERSION_MINOR 1)
41 set(FOAM_VERSION_PATCH 0)
42 set(FOAM_VERSION ${FOAM_VERSION_MAJOR}.${FOAM_VERSION_MINOR})
43 set(FOAM_VERSION_FULL ${FOAM_VERSION}.${FOAM_VERSION_PATCH})
44 set(FOAM_SOVERSION 1)
46 # set up custom cmake module path
47 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
49 # utilities
50 set(FOAM_CREATE_INCLUDE_WRAPPERS TRUE)
51 set(FOAM_HAS_FLEX_SOURCES TRUE)
52 set(FOAM_ENABLE_DOC_INDEX TRUE)
53 set(FOAM_EXPORT_NAMESPACE FOAM_)
54 include(${CMAKE_SOURCE_DIR}/CMake/FOAMUtilities.cmake)
55 include(${CMAKE_SOURCE_DIR}/CMake/FOAMThirdPartyUtilities.cmake)
56 include(${CMAKE_SOURCE_DIR}/CMake/FOAMInternal.cmake)
57 include(CTest)
59 # determine computer system
60 include(${CMAKE_SOURCE_DIR}/CMake/FOAMDetermineArch.cmake)
62 # select precision
63 foam_option(FOAM_DOUBLE_PRECISION "Double precision"
64   "Compile ${PROJECT_NAME} with double precision floating point arithmetics." ON)
65 mark_as_advanced(FOAM_DOUBLE_PRECISION)
66 if(FOAM_DOUBLE_PRECISION)
67   set(FOAM_PRECISION DP)
68 else()
69   set(FOAM_PRECISION SP)
70 endif()
72 # select whether we want to build framewors on Mac OS X
73 if(APPLE)
74   foam_option(FOAM_BUILD_FRAMEWORKS "Build frameworks"
75     "Build frameworks on Mac OS X" OFF)
76   mark_as_advanced(FOAM_BUILD_FRAMEWORKS)
77 else()
78   set(FOAM_BUILD_FRAMEWORKS OFF)
79 endif()
81 # find python interpreter
82 find_package(PythonInterp REQUIRED)
84 # make sure we got Python version 2.6 or newer
85 foam_dependent_variables(PYTHON_EXECUTABLE PYTHON_VERSION)
86 if(NOT PYTHON_VERSION)
87   execute_process(
88     COMMAND ${PYTHON_EXECUTABLE} -c
89     "import sys; sys.stdout.write('%s.%s.%s\\n'%sys.version_info[0:3])"
90     RESULT_VARIABLE _py_version_result
91     OUTPUT_VARIABLE _py_version_output
92     ERROR_VARIABLE _py_version_output
93     OUTPUT_STRIP_TRAILING_WHITESPACE
94     )
95   if(NOT _py_version_result)
96     string(REGEX MATCH "([0-9]+\\.)+[0-9]+" PYTHON_VERSION "${_py_version_output}")
97     message(STATUS "Python version ${PYTHON_VERSION} found")
98     if(${PYTHON_VERSION} VERSION_LESS 2.4.0)
99       message(SEND_ERROR "Python version 2.4 or newer required")
100     endif()
101   else()
102     set(PYTHON_VERSION PYTHON_VERSION-NOTFOUND)
103     message(SEND_ERROR "Failed to determine the python version: ${_py_version_output}")
104   endif()
105   set(PYTHON_VERSION ${PYTHON_VERSION} CACHE INTERNAL "The Python version")
106 endif()
107 string(REGEX REPLACE "\\.[0-9]+$" "" PYTHON_SHORT_VERSION ${PYTHON_VERSION})
109 # find the installed ParaView executable
110 find_program(
111   FOAM_PARAVIEW3_APP NAMES "ParaView 3.8.1" "ParaView 3.8.0" ParaView paraview
112   DOC "Path to the ParaView 3.8 (or newer) application"
113   )
114 mark_as_advanced(FOAM_PARAVIEW3_APP)
115 foam_dependent_variables(FOAM_PARAVIEW3_APP FOAM_PARAVIEW3_VERSION)
116 if(FOAM_PARAVIEW3_APP)
117   if(NOT FOAM_PARAVIEW3_VERSION)
118     execute_process(COMMAND ${FOAM_PARAVIEW3_APP} --version
119       OUTPUT_VARIABLE _pv_version_output
120       ERROR_VARIABLE _pv_version_output
121       OUTPUT_STRIP_TRAILING_WHITESPACE
122       )
123     if(_pv_version_output MATCHES "ParaView(([0-9]+\\.)+[0-9]+)")
124       set(FOAM_PARAVIEW3_VERSION ${CMAKE_MATCH_1} CACHE INTERNAL
125         "The ParaView version")
126       message(STATUS
127         "ParaView ${FOAM_PARAVIEW3_VERSION} found: ${FOAM_PARAVIEW3_APP}")
128     else()
129       message(SEND_ERROR
130         "Failed to determine the ParaView version: ${_pv_version_output}")
131     endif()
132   endif()
133   if(${FOAM_PARAVIEW3_VERSION} VERSION_LESS 3.8)
134     message(WARNING
135       "ParaView versions older than 3.8 might not be able\n"
136       "to read ${PROJECT_NAME} cases.")
137   endif()
138 else()
139   message(WARNING
140     "Failed to find the ParaView application")
141   set(FOAM_PARAVIEW3_APP)
142 endif()
144 # we want shared libraries
145 set(BUILD_SHARED_LIBS SHARED)
147 # installation directories
148 foam_installation_path(FOAM_INSTALL_BIN_PATH bin "Executables"
149   "Executables installation path")
150 if(APPLE AND FOAM_BUILD_FRAMEWORKS)
151   foam_installation_path(FOAM_INSTALL_FRAMEWORK_PATH /Library/Frameworks
152     "Frameworks" "Framework installation path")
153 endif()
154 foam_installation_path(FOAM_INSTALL_LIBRARY_PATH
155   lib/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL}
156   "Libraries" "Library installation path")
157 if(NOT WIN32)
158   foam_installation_path(FOAM_INSTALL_PLUGIN_PATH
159     "${FOAM_INSTALL_LIBRARY_PATH_ORIG}/plugins${FOAM_SOVERSION}"
160     "Plugins" "Plugin installation path")
161 endif()
162 foam_installation_path(FOAM_INSTALL_LIBEXEC_PATH
163   libexec/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Private executables"
164   "Installation path for executables not on PATH.")
165 foam_installation_path(FOAM_INSTALL_HEADER_PATH
166   include/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL}
167   "Headers" "Header installation path (not for frameworks)")
168 foam_installation_path(FOAM_INSTALL_CONFIG_PATH
169   etc/${CMAKE_PROJECT_NAME}/${FOAM_VERSION_FULL} "Config files"
170   "Configuration files installation path")
171 foam_installation_path(FOAM_INSTALL_DATA_PATH
172   share/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Data files"
173   "Data files installation path")
174 foam_installation_path(FOAM_INSTALL_DOC_PATH
175   share/doc/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Documentation"
176   "Documentation files installation path")
177 foam_installation_path(FOAM_INSTALL_MAN_PATH share/man "Man pages"
178   "Man-pages installation path")
179 foam_installation_path(FOAM_INSTALL_TUTORIALS_PATH
180   "${FOAM_INSTALL_DOC_PATH_ORIG}" "Tutorials" "Tutorials installation path")
181 foam_installation_path(FOAM_INSTALL_CMAKE_PATH
182   "${FOAM_INSTALL_DATA_PATH_ORIG}/CMake"
183   "CMake files" "CMake configuration files installation path")
184 foam_installation_path(FOAM_INSTALL_USERDFOAM_PATH
185   "${FOAM_INSTALL_PLUGIN_PATH_ORIG}/ensightReader"
186   "Ensight plugin" "Ensight OpenFOAM-reader plugin installation path")
187 foam_installation_path(FOAM_INSTALL_PYTHON_PATH
188   "lib/python${PYTHON_SHORT_VERSION}/site-packages"
189   "Python modules" "Python modules installation base path")
191 set(FOAM_INSTALL_RUNTIME_PATH "${FOAM_INSTALL_LIBEXEC_PATH}")
193 # determine the INSTALL_NAME_DIR of potential frameworks
194 if(APPLE AND FOAM_BUILD_FRAMEWORKS)
195   set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_FRAMEWORK_PATH}")
196 else()
197   set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_LIBRARY_PATH}")
198 endif()
200 # select html documentation browser (try a few well known ones for default)
201 # have to loop, because find_program(HTML_DOC_BROWSER NAMES ...) garbles things
202 # up
203 set(_BROWSERS xdg-open sensible-browser x-www-browser gnome-open kde-open
204   firefox chromium-browser epiphany konqueror www-browser w3m lynx launch)
205 if(APPLE)
206   list(INSERT _BROWSERS 0 open)
207 endif()
208 foreach(browser IN LISTS _BROWSERS)
209   find_program(HTML_DOC_BROWSER ${browser}
210     DOC "Program to open an HTML file")
211   if(HTML_DOC_BROWSER)
212     break()
213   endif()
214 endforeach()
215 if(NOT HTML_DOC_BROWSER)
216   message(STATUS
217     "Failed to find a program to open HTML pages with (a.k.a a browser).\n"
218     "Point HTML_DOC_BROWSER to a suitable program.")
219   set(HTML_DOC_BROWSER "ECHO" CACHE STRING
220     "Command to open an HTML file (ECHO will print it to STDOUT)" FORCE)
221 endif()
222 set(FOAM_HTML_DOC_BROWSER_COMMAND
223   "\${HTML_DOC_BROWSER} %f" CACHE STRING "Command to open an HTML file")
224 string(CONFIGURE "${FOAM_HTML_DOC_BROWSER_COMMAND}"
225   FOAM_HTML_DOC_BROWSER_COMMAND ESCAPE_QUOTES)
226 mark_as_advanced(HTML_DOC_BROWSER FOAM_HTML_DOC_BROWSER_COMMAND)
228 # Executable-prefix
229 string(TOLOWER "${PROJECT_NAME}-" _FOAM_DEFAULT_EXE_PREFIX)
230 set(FOAM_EXE_PREFIX "${_FOAM_DEFAULT_EXE_PREFIX}"
231   CACHE STRING "Prefix for application output-names")
232 mark_as_advanced(FOAM_EXE_PREFIX)
233 string(TOUPPER "${FOAM_EXE_PREFIX}" FOAM_UPPER_EXE_PREFIX)
235 # ask user whether she wants to build Doxygen docs
236 foam_option(FOAM_ENABLE_DOXYGEN_DOCS "Doxygen API documentation"
237   "Build the Doxygen API documentation" OFF)
238 # if user wants doxygen docs, find Doxygen and set up some options
239 if(FOAM_ENABLE_DOXYGEN_DOCS)
240   find_package(Doxygen REQUIRED)
241   execute_process(COMMAND ${DOXYGEN_EXECUTABLE} --version
242     RESULT_VARIABLE DOXYGEN_VERSION_RESULT
243     OUTPUT_VARIABLE DOXYGEN_VERSION_OUTPUT
244     OUTPUT_STRIP_TRAILING_WHITESPACE)
245   if(DOXYGEN_VERSION_RESULT)
246     message(SEND_ERROR "Failed to determine doxygen version")
247   endif()
248   if(${DOXYGEN_VERSION_OUTPUT} VERSION_GREATER 1.6.3 AND
249       ${DOXYGEN_VERSION_OUTPUT} VERSION_LESS 1.7.2-20101106)
250     message(WARNING
251       "Found Doxygen version ${DOXYGEN_VERSION_OUTPUT}. "
252       "Versions newer than 1.6.3 and older than 1.7.2-20101106 "
253       "usually crash when processing the ${PROJECT_NAME} documentation.")
254   endif()
255   foam_option(FOAM_DOXYDOCS_FOR_SF "Doxygen for SourceForge"
256     "Build the Doxygen docs for deployment on SourceForge" OFF)
257   # ask user whether she prefers local or www docs
258   foam_option(FOAM_USE_LOCAL_DOXYGEN_DOCS "Use local API docs"
259     "Use the local Doxygen documentation instead of the one on http://freefoam.sf.net/doc/Doxygen/html" ON)
260   mark_as_advanced(FOAM_DOXYDOCS_FOR_SF FOAM_USE_LOCAL_DOXYGEN_DOCS)
261 endif()
263 # ask user whether she wants to build the man pages
264 foam_option(FOAM_ENABLE_MANPAGE_HELP "Build manpage help"
265   "Build the manpages (requires asciidoc)" OFF)
266 # ask user whether she wants to build the xhtml man pages
267 foam_option(FOAM_ENABLE_XHTML_HELP "Build xhtml help"
268   "Build the xhtml help pages (requires asciidoc)" OFF)
269 # as user whether she wanst to build the xhtml guides
270 foam_option(FOAM_ENABLE_XHTML_GUIDES "Build the xhtml guides"
271   "Build the xhtml guides (requires asciidoc, dot, inkscape and asymptote)" OFF)
272 # as user whether she wanst to build the xhtml guides
273 foam_option(FOAM_ENABLE_PDF_GUIDES "Build the PDF guides"
274   "Build the PDF guides (requires asciidoc, dot, inkscape and asymptote)" OFF)
275 if(FOAM_ENABLE_PDF_GUIDES)
276   foam_option(FOAM_USE_FOP "Use FOP instead of dblatex"
277     "Use FOP to build the PDF guides instead of dblatex" OFF)
278   mark_as_advanced(FOAM_USE_FOP)
279 else()
280   set(FOAM_USE_FOP FALSE)
281 endif()
283 if(BUILD_TESTING)
284   # ask user whether whe wants full tutorial tests
285   foam_option(FOAM_ENABLE_FULL_TUTORIAL_TESTS
286     "Full tutorial tests"
287     "Run the complete tutorial tests (not just a single time step)" OFF)
288 endif()
290 foam_option(FOAM_ENABLE_CPACK "CPack packaging"
291   "Enable CPack packaging support" OFF)
292 mark_as_advanced(FOAM_ENABLE_CPACK)
294 if(FOAM_ENABLE_XHTML_GUIDES)
295   foam_option(FOAM_ENABLE_MATHJAX "Use MathJax in XHTML guides"
296     "Use MathJax for formulas in the XHTML version of the guides" ON)
297   if(FOAM_ENABLE_MATHJAX)
298     foam_option(FOAM_MATHJAX_USE_CDN
299       "Use the MathJax CDN"
300       "Use public MathJax installation at http://cdn.mathjax.org" ON)
301     mark_as_advanced(FOAM_MATHJAX_USE_CDN)
302     if(FOAM_MATHJAX_USE_CDN)
303       set(FOAM_MATHJAX_URL "http://cdn.mathjax.org/mathjax/latest")
304     else()
305       set(FOAM_MATHJAX_URL "MathJAX-NOTFOUND" CACHE PATH
306         "Path or URL to the MathJax directory containing the MathJax.js file")
307       mark_as_advanced(FOAM_MATHJAX_URL)
308       if(NOT FOAM_MATHJAX_URL)
309         message(SEND_ERROR "FOAM_MATHJAX_URL must be set to the directory or "
310           "URL containing MathJax.js")
311       endif()
312     endif()
313   endif()
314 else()
315   set(FOAM_ENABLE_MATHJAX FALSE)
316 endif()
318 # assemble the list of enabled manpage formats
319 set(FOAM_MANPAGE_FORMATS)
320 if(FOAM_ENABLE_MANPAGE_HELP)
321   list(APPEND FOAM_MANPAGE_FORMATS manpage)
322 endif()
323 if(FOAM_ENABLE_XHTML_HELP)
324   list(APPEND FOAM_MANPAGE_FORMATS xhtml)
325 endif()
327 # assemble the list of enabled guides formats
328 set(FOAM_GUIDES_FORMATS)
329 if(FOAM_ENABLE_XHTML_GUIDES)
330   list(APPEND FOAM_GUIDES_FORMATS xhtml)
331 endif()
332 if(FOAM_ENABLE_PDF_GUIDES)
333   list(APPEND FOAM_GUIDES_FORMATS pdf)
334 endif()
336 if(FOAM_MANPAGE_FORMATS OR FOAM_ENABLE_CPACK OR FOAM_GUIDES_FORMATS)
337   # find AsciiDoc
338   find_program(ASCIIDOC_EXECUTABLE NAMES asciidoc.py asciidoc)
339   get_filename_component(asciidoc_path "${ASCIIDOC_EXECUTABLE}" PATH)
340   find_program(A2X_EXECUTABLE NAMES a2x.py a2x HINTS "${asciidoc_path}")
341   if(NOT ASCIIDOC_EXECUTABLE OR NOT A2X_EXECUTABLE)
342     message(SEND_ERROR
343       "AsciiDoc is required to create man and html help and the guides")
344   endif()
345   mark_as_advanced(ASCIIDOC_EXECUTABLE A2X_EXECUTABLE)
346   # read CONF_DIR from A2X_EXECUTABLE and copy style files over
347   if(A2X_EXECUTABLE)
348     file(READ "${A2X_EXECUTABLE}" _asciidoc_text)
349     if(_asciidoc_text MATCHES "[ \t]*CONF_DIR[ \t]*=[ \t]*r?['\"]([^'\"]+)")
350       set(A2X_CONF_DIR "${CMAKE_MATCH_1}")
351       if(IS_DIRECTORY "${A2X_CONF_DIR}")
352         configure_file("${A2X_CONF_DIR}/docbook-xsl/common.xsl"
353           "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-common.xsl"
354           COPYONLY)
355         configure_file("${A2X_CONF_DIR}/docbook-xsl/chunked.xsl"
356           "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-chunked.xsl"
357           COPYONLY)
358         configure_file("${A2X_CONF_DIR}/dblatex/asciidoc-dblatex.sty"
359           "${CMAKE_BINARY_DIR}/data/asciidoc/dblatex/orig-asciidoc-dblatex.sty"
360           COPYONLY)
361         configure_file("${A2X_CONF_DIR}/dblatex/asciidoc-dblatex.xsl"
362           "${CMAKE_BINARY_DIR}/data/asciidoc/dblatex/orig-asciidoc-dblatex.xsl"
363           COPYONLY)
364       else()
365         message(SEND_ERROR "The Asciidoc configuration directory "
366           "${A2X_CONF_DIR} does not exist")
367       endif()
368     else()
369       message(SEND_ERROR "Failed to read CONF_DIR from ${A2X_EXECUTABLE}")
370     endif()
371   endif()
372   set(FOAM_NEED_PNGMATH FALSE)
373   if(NOT FOAM_ENABLE_MATHJAX OR FOAM_USE_FOP)
374     set(FOAM_NEED_PNGMATH TRUE)
375     foreach(prog latex dvipng)
376       string(TOUPPER ${prog} uprog)
377       find_program(${uprog}_EXECUTABLE ${prog})
378       mark_as_advanced(${uprog}_EXECUTABLE)
379       if(NOT ${uprog}_EXECUTABLE)
380         message(SEND_ERROR
381           "${prog} is required when FOAM_ENABLE_MATHJAX is disabled "
382           "or FOAM_USE_FOP is enabled")
383       endif()
384     endforeach()
385   endif()
386 endif()
387 if(FOAM_GUIDES_FORMATS)
388   # find asymptote
389   find_program(ASY_EXECUTABLE asy)
390   if(NOT ASY_EXECUTABLE)
391     message(SEND_ERROR "Asymptote is required to create the guides")
392   endif()
393   mark_as_advanced(ASY_EXECUTABLE)
394 endif()
396 # set up the RPATH for installation
397 set(CMAKE_INSTALL_RPATH ${FOAM_INSTALL_LIBRARY_PATH})
398 set(CMAKE_INSTALL_NAME_DIR ${FOAM_FRAMEWORK_INSTALL_NAME_DIR})
400 # we want executables and libraries in uniform places
401 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
402   "${CMAKE_BINARY_DIR}/libexec/${PROJECT_NAME}/${FOAM_VERSION_FULL}")
403 set(FOAM_LIBRARY_OUTPUT_DIRECTORY
404   "${CMAKE_BINARY_DIR}/lib/${PROJECT_NAME}-${FOAM_VERSION_FULL}")
405 set(FOAM_FRAMEWORK_OUTPUT_DIRECTORY
406   "${CMAKE_BINARY_DIR}/Library/Frameworks")
407 if(FOAM_BUILD_FRAMEWORKS)
408   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_FRAMEWORK_OUTPUT_DIRECTORY}")
409 else()
410   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
411 endif()
412 set(FOAM_ARCHIVE_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
414 # find parallel libraries
415 find_package(MPI)
416 if(MPI_FOUND)
417   set(_FOAM_USE_MPI ON)
418 else()
419   set(_FOAM_USE_MPI OFF)
420 endif()
421 foam_option(FOAM_USE_MPI "Use MPI"
422   "Build ${CMAKE_PROJECT} against MPI parallel libraries" ${_FOAM_USE_MPI})
423 mark_as_advanced(FOAM_USE_MPI)
424 if(FOAM_USE_MPI AND NOT MPI_FOUND)
425   message(SEND_ERROR
426     "FOAM_ENABLE_MPI is true, but MPI cannot be found.\n"
427     "If you have MPI installed on your system, edit the variables\n"
428     "MPI_INCLUDE_DIR and MPI_LIBRARY in the cache, else disable the\n"
429     "setting FOAM_USE_MPI."
430   )
431 endif()
433 # find readline
434 find_package(Readline)
436 # substitution for build-tree and install-tree as used by
437 # foam_configure_files.
438 set(FOAM_CONFIGURE_FILES_VARIABLES
439   FOAM_DATA_DIR
440     "${CMAKE_BINARY_DIR}/data"
441     "${FOAM_INSTALL_DATA_PATH}"
442   FOAM_LOCAL_DOC_DIR
443     "${CMAKE_BINARY_DIR}/doc"
444     "${FOAM_INSTALL_DOC_PATH}"
445   FOAM_BIN_DIR
446     "${CMAKE_BINARY_DIR}/bin"
447     "${FOAM_INSTALL_BIN_PATH}"
448   FOAM_LIB_DIR
449     "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}"
450     "${FOAM_INSTALL_LIBRARY_PATH}"
451   FOAM_LIBEXEC_DIR
452     "${CMAKE_BINARY_DIR}/libexec/FreeFOAM/${FOAM_VERSION_FULL}"
453     "${FOAM_INSTALL_LIBEXEC_PATH}"
454   FOAM_FRAMEWORK_DIR
455     "${CMAKE_BINARY_DIR}/Library/Frameworks"
456     "${FOAM_INSTALL_FRAMEWORK_PATH}"
457   FOAM_INCLUDE_DIR
458     "${CMAKE_BINARY_DIR}/include"
459     "${FOAM_INSTALL_HEADER_PATH}"
460   FOAM_CONFIG_DIR
461     "${CMAKE_BINARY_DIR}/etc"
462     "${FOAM_INSTALL_CONFIG_PATH}"
463   FOAM_CMAKECONFIG_DIR
464     "${CMAKE_BINARY_DIR}/CMake"
465     "${FOAM_INSTALL_CMAKE_PATH}"
466   FOAM_PYTHON_DIR
467     "${CMAKE_BINARY_DIR}/data/python"
468     "${FOAM_INSTALL_PYTHON_PATH}"
469   FOAM_IS_INSTALLED
470     "FALSE"
471     "TRUE"
472   )
473 if(WIN32)
474   list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
475     FOAM_PLUGIN_DIR
476       "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}"
477       "${FOAM_INSTALL_LIBRARY_PATH}")
478 else()
479   list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
480     FOAM_PLUGIN_DIR
481       "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}/plugins"
482       "${FOAM_INSTALL_PLUGIN_PATH}")
483 endif()
484 if(FOAM_USE_LOCAL_DOXYGEN_DOCS)
485   list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
486     FOAM_DOC_DIR "${CMAKE_BINARY_DIR}/doc" "${FOAM_INSTALL_DOC_PATH}")
487 else()
488   set(_sf_doc "http://freefoam.sf.net/doc/${FOAM_VERSION_FULL}")
489   list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
490     FOAM_DOC_DIR "${_sf_doc}" "${_sf_doc}")
491 endif()
493 # thirdparty libraries
494 foam_thirdparty_option(Metis
495   "Required by the metis decomposition method"
496   Metis TRUE ON)
497 if(FOAM_ENABLE_METIS)
498   if(FOAM_ENABLE_METIS AND METIS_REQUIRES_MPI AND NOT FOAM_USE_MPI)
499     message(SEND_ERROR
500       "Your metis implementation requires FOAM_USE_MPI to be enabled."
501       "If you don't have/want MPI, enable FOAM_BUILD_PRIVATE_METIS instead.")
502   endif()
503 endif()
504 foam_thirdparty_option(ParMetis
505   "Required by the parmetis decomposition method"
506   ParMetis TRUE ${FOAM_USE_MPI}
507   PARMETIS_metis_LIBRARY PARMETIS_parmetis_LIBRARY)
508 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_USE_MPI)
509   message(SEND_ERROR
510     "ParMetis requires FOAM_USE_MPI to be enabled.")
511 endif()
512 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_ENABLE_METIS)
513   message(SEND_ERROR
514     "ParMetis requires FOAM_ENABLE_METIS to be enabled.")
515 endif()
516 set(SCOTCH_USE_ERREXIT TRUE)
517 foam_thirdparty_option(SCOTCH "" SCOTCH FALSE ON SCOTCH_scotch_LIBRARY
518   SCOTCH_scotcherr_LIBRARY SCOTCH_scotcherrexit_LIBRARY)
519 # do not enable mgridgen by default (licensing issues)
520 if(NOT FOAM_DOUBLE_PRECISION)
521   set(MGRIDGEN_USE_REAL ON)
522 endif()
523 foam_thirdparty_option(MGRIDGEN
524   "Required by the MGridGen GAMG agglomerator. LICENSE UNCLEAR"
525   MGRIDGEN TRUE OFF)
526 # do not enable libccmio by default (licensing issues)
527 foam_thirdparty_option(ccmio
528   "Required by ccm26ToFoam. REQUIRES PERMISSION BY CDADAPCO!"
529   Ccmio TRUE OFF)
530 foam_thirdparty_option(zlib "" ZLIB FALSE ON)
532 # figure out default Pstream library
533 if(FOAM_USE_MPI)
534   set(_FOAM_DEFAULT_PSTREAM mpi)
535 else()
536   set(_FOAM_DEFAULT_PSTREAM dummy)
537 endif()
538 set(FOAM_DEFAULT_PSTREAM ${_FOAM_DEFAULT_PSTREAM} CACHE STRING
539   "Default Pstream library implementation [dummy|mpi]")
540 mark_as_advanced(FOAM_DEFAULT_PSTREAM)
542 # find m4 macro processor
543 find_program(M4_EXECUTABLE m4 DOC "Path to the m4 macro processor")
544 mark_as_advanced(M4_EXECUTABLE)
545 if(NOT M4_EXECUTABLE)
546   message("WARNING: Failed to find M4 macro processor.\n"
547     "Some of the tutorials will fail if it can't be found.")
548   set(M4_EXECUTABLE m4)
549 endif()
551 # on APPLE use cp -R -P -p, otherwise use cp -a
552 if(APPLE)
553   set(FOAM_CP_A_FLAGS "-R -P -p")
554 else()
555   set(FOAM_CP_A_FLAGS "-a")
556 endif()
558 # execinfo.h and cxxabi.h only work using GNU gcc and Debug config
559 # assume that if we have execinfo.h, cxxabi.h is also present.
560 if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL Debug)
561   find_package(Execinfo)
562 endif()
564 # create the FOAMConfig.h file
565 configure_file(${CMAKE_SOURCE_DIR}/FOAMConfig.h.in
566   ${CMAKE_BINARY_DIR}/include/FOAMConfig.h @ONLY)
568 # on Solaris/SunOS fix up the shebangs
569 if(CMAKE_SYSTEM_NAME STREQUAL SunOS AND NOT EXISTS ${CMAKE_BINARY_DIR}/replaceAllShellSun.run)
570   message(STATUS "Fixing shell-interpreter for SunOS and Solaris")
571   execute_process(
572     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun bin
573     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun data
574     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun tutorials
575     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun doc
576     COMMAND ${CMAKE_COMMAND} -E touch${CMAKE_BINARY_DIR}/replaceAllShellSun.run
577     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
578     )
579 endif()
581 # set up defines
582 set(FOAM_COMPILE_DEFINITIONS
583   -D${FOAM_PRECISION}
584   -DNoRepository
585   -D${FOAM_OS}
586   )
587 if(APPLE)
588   list(APPEND FOAM_COMPILE_DEFINITIONS -Ddarwin)
589 endif()
590 add_definitions(${FOAM_COMPILE_DEFINITIONS})
592 # set up include-directories for own headers
593 include_directories(${CMAKE_BINARY_DIR}/include)
595 # descend into the sources...
596 add_subdirectory(bin)
597 add_subdirectory(etc)
598 add_subdirectory(data)
599 add_subdirectory(src)
600 add_subdirectory(applications)
601 add_subdirectory(tutorials)
602 add_subdirectory(doc)
604 # export the library dependencies to the build tree
605 foam_export_targets_to_build_tree(${PROJECT_NAME}LibraryDepends)
606 export(PACKAGE ${PROJECT_NAME})
608 # write the doc index file and install it
609 foam_write_doc_index()
610 install(FILES
611   ${CMAKE_BINARY_DIR}/InstallFiles/data/DoxyDocIndex
612   DESTINATION ${FOAM_INSTALL_DATA_PATH}
613   COMPONENT data
614   )
616 # create ${PROJECT_NAME}Config.cmake ${PROJECT_NAME}Use.cmake,
617 # ${PROJECT_NAME}Utilities.cmake and ${PROJECT_NAME}WmakeCompatibility.cmake
618 # for the build and install tree
619 foam_configure_files(ConfigInstallFiles
620   "CMake/FOAMConfig.cmake.in==CMake/${PROJECT_NAME}Config.cmake"
621   "CMake/FOAMUse.cmake.in==CMake/${PROJECT_NAME}Use.cmake"
622   "CMake/FOAMWmakeCompatibility.cmake.in==CMake/${PROJECT_NAME}WmakeCompatibility.cmake"
623   COPYONLY
624   "CMake/FOAMUtilities.cmake==CMake/${PROJECT_NAME}Utilities.cmake"
625   )
627 # install the CMake config files
628 install(FILES
629   ${ConfigInstallFiles}
630   DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
631   COMPONENT dev
632   )
634 # install the ${PROJECT_NAME}LibraryDepends.cmake file
635 install(EXPORT ${PROJECT_NAME}LibraryDepends
636   DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
637   NAMESPACE FOAM_
638   COMPONENT dev
639   )
641 # pack things up
642 if(FOAM_ENABLE_CPACK)
643   include(${CMAKE_SOURCE_DIR}/CMake/FOAMCPack.cmake)
644 endif()
646 # uninstall target
647 configure_file(
648   "${CMAKE_SOURCE_DIR}/CMake/Modules/cmake_uninstall.cmake.in"
649   "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
650   @ONLY
651   )
653 add_custom_target(uninstall
654   "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
655   )
657 # print cool feature summary
658 foam_print_feature_summary()
660 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file