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