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