ENH: Set VERSION and SOVERSION properties on libraries
[freefoam.git] / CMakeLists.txt
blob4d0d5acdd99952bc7efa112e0ed3863168dd0eae
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 foam_installation_path(FOAM_INSTALL_LIBEXEC_PATH
155   libexec/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Private executables"
156   "Installation path for executables not on PATH.")
157 foam_installation_path(FOAM_INSTALL_HEADER_PATH
158   include/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL}
159   "Headers" "Header installation path (not for frameworks)")
160 foam_installation_path(FOAM_INSTALL_CONFIG_PATH
161   etc/${CMAKE_PROJECT_NAME}/${FOAM_VERSION_FULL} "Config files"
162   "Configuration files installation path")
163 foam_installation_path(FOAM_INSTALL_DATA_PATH
164   share/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Data files"
165   "Data files installation path")
166 foam_installation_path(FOAM_INSTALL_DOC_PATH
167   share/doc/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Documentation"
168   "Documentation files installation path")
169 foam_installation_path(FOAM_INSTALL_MAN_PATH share/man "Man pages"
170   "Man-pages installation path")
171 foam_installation_path(FOAM_INSTALL_TUTORIALS_PATH
172   "${FOAM_INSTALL_DOC_PATH_ORIG}" "Tutorials" "Tutorials installation path")
173 foam_installation_path(FOAM_INSTALL_CMAKE_PATH
174   "${FOAM_INSTALL_DATA_PATH_ORIG}/CMake"
175   "CMake files" "CMake configuration files installation path")
176 foam_installation_path(FOAM_INSTALL_USERDFOAM_PATH
177   "${FOAM_INSTALL_LIBRARY_PATH_ORIG}/plugins/ensightReader"
178   "Ensight plugin" "Ensight OpenFOAM-reader plugin installation path")
179 foam_installation_path(FOAM_INSTALL_PYTHON_PATH
180   "lib/python${PYTHON_SHORT_VERSION}/site-packages"
181   "Python modules" "Python modules installation base path")
183 set(FOAM_INSTALL_RUNTIME_PATH "${FOAM_INSTALL_LIBEXEC_PATH}")
185 # determine the INSTALL_NAME_DIR of potential frameworks
186 if(APPLE AND FOAM_BUILD_FRAMEWORKS)
187   set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_FRAMEWORK_PATH}")
188 else()
189   set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_LIBRARY_PATH}")
190 endif()
192 # select html documentation browser (try a few well known ones for default)
193 # have to loop, because find_program(HTML_DOC_BROWSER NAMES ...) garbles things up
194 foreach(browser open gnome-open kde-open x-www-browser www-browser
195     firefox epiphany konqueror w3m lynx launch open)
196   find_program(HTML_DOC_BROWSER ${browser}
197     DOC "Program to open an HTML file")
198   if(HTML_DOC_BROWSER)
199     break()
200   endif()
201 endforeach()
202 if(NOT HTML_DOC_BROWSER)
203   message(STATUS
204     "Failed to find a program to open HTML pages with (a.k.a a browser).\n"
205     "Point HTML_DOC_BROWSER to a suitable program.")
206   set(HTML_DOC_BROWSER "ECHO" CACHE STRING
207     "Command to open an HTML file (ECHO will print it to STDOUT)" FORCE)
208 endif()
209 set(FOAM_HTML_DOC_BROWSER_COMMAND
210   "\${HTML_DOC_BROWSER} %f" CACHE STRING "Command to open an HTML file")
211 string(CONFIGURE "${FOAM_HTML_DOC_BROWSER_COMMAND}"
212   FOAM_HTML_DOC_BROWSER_COMMAND ESCAPE_QUOTES)
213 mark_as_advanced(HTML_DOC_BROWSER FOAM_HTML_DOC_BROWSER_COMMAND)
215 # Executable-prefix
216 string(TOLOWER "${PROJECT_NAME}-" _FOAM_DEFAULT_EXE_PREFIX)
217 set(FOAM_EXE_PREFIX "${_FOAM_DEFAULT_EXE_PREFIX}"
218   CACHE STRING "Prefix for application output-names")
219 mark_as_advanced(FOAM_EXE_PREFIX)
220 string(TOUPPER "${FOAM_EXE_PREFIX}" FOAM_UPPER_EXE_PREFIX)
222 # ask user whether she wants to build Doxygen docs
223 foam_option(FOAM_ENABLE_DOXYGEN_DOCS "Doxygen API documentation"
224   "Build the Doxygen API documentation" OFF)
225 # if user wants doxygen docs, find Doxygen and set up some options
226 if(FOAM_ENABLE_DOXYGEN_DOCS)
227   find_package(Doxygen REQUIRED)
228   execute_process(COMMAND ${DOXYGEN_EXECUTABLE} --version
229     RESULT_VARIABLE DOXYGEN_VERSION_RESULT
230     OUTPUT_VARIABLE DOXYGEN_VERSION_OUTPUT
231     OUTPUT_STRIP_TRAILING_WHITESPACE)
232   if(DOXYGEN_VERSION_RESULT)
233     message(SEND_ERROR "Failed to determine doxygen version")
234   endif()
235   if(${DOXYGEN_VERSION_OUTPUT} VERSION_GREATER 1.6.3 AND
236       ${DOXYGEN_VERSION_OUTPUT} VERSION_LESS 1.7.2-20101106)
237     message(WARNING
238       "Found Doxygen version ${DOXYGEN_VERSION_OUTPUT}. "
239       "Versions newer than 1.6.3 and older than 1.7.2-20101106 "
240       "usually crash when processing the ${PROJECT_NAME} documentation.")
241   endif()
242   foam_option(FOAM_DOXYDOCS_FOR_SF "Doxygen for SourceForge"
243     "Build the Doxygen docs for deployment on SourceForge" OFF)
244   # ask user whether she prefers local or www docs
245   foam_option(FOAM_USE_LOCAL_DOXYGEN_DOCS "Use local API docs"
246     "Use the local Doxygen documentation instead of the one on http://freefoam.sf.net/doc/Doxygen/html" OFF)
247 endif()
249 # ask user whether she wants to build the man pages
250 foam_option(FOAM_ENABLE_MANPAGE_HELP "Build manpage help"
251   "Build the manpages (requires asciidoc)" OFF)
252 # ask user whether she wants to build the xhtml man pages
253 foam_option(FOAM_ENABLE_XHTML_HELP "Build xhtml help"
254   "Build the xhtml help pages (requires asciidoc)" OFF)
255 # as user whether she wanst to build the xhtml guides
256 foam_option(FOAM_ENABLE_XHTML_GUIDES "Build the xhtml guides"
257   "Build the xhtml guides (requires asciidoc, dot, inkscape and asymptote)" OFF)
258 # as user whether she wanst to build the xhtml guides
259 foam_option(FOAM_ENABLE_PDF_GUIDES "Build the PDF guides"
260   "Build the PDF guides (requires asciidoc, dot, inkscape and asymptote)" OFF)
261 if(FOAM_ENABLE_PDF_GUIDES)
262   foam_option(FOAM_USE_FOP "Use FOP instead of dblatex"
263     "Use FOP to build the PDF guides instead of dblatex" OFF)
264 else()
265   set(FOAM_USE_FOP FALSE)
266 endif()
268 if(BUILD_TESTING)
269   # ask user whether whe wants full tutorial tests
270   foam_option(FOAM_ENABLE_FULL_TUTORIAL_TESTS
271     "Full tutorial tests"
272     "Run the complete tutorial tests (not just a single time step)" OFF)
273 endif()
275 option(FOAM_ENABLE_CPACK "Enable CPACK packaging support" OFF)
277 # assemble the list of enabled manpage formats
278 set(FOAM_MANPAGE_FORMATS)
279 if(FOAM_ENABLE_MANPAGE_HELP)
280   list(APPEND FOAM_MANPAGE_FORMATS manpage)
281 endif()
282 if(FOAM_ENABLE_XHTML_HELP)
283   list(APPEND FOAM_MANPAGE_FORMATS xhtml)
284 endif()
286 # assemble the list of enabled guides formats
287 set(FOAM_GUIDES_FORMATS)
288 if(FOAM_ENABLE_XHTML_GUIDES)
289   list(APPEND FOAM_GUIDES_FORMATS xhtml)
290 endif()
291 if(FOAM_ENABLE_PDF_GUIDES)
292   list(APPEND FOAM_GUIDES_FORMATS pdf)
293 endif()
295 if(FOAM_MANPAGE_FORMATS OR FOAM_ENABLE_CPACK OR FOAM_GUIDES_FORMATS)
296   # find AsciiDoc
297   find_program(ASCIIDOC_EXECUTABLE NAMES asciidoc.py asciidoc)
298   get_filename_component(asciidoc_path "${ASCIIDOC_EXECUTABLE}" PATH)
299   find_program(A2X_EXECUTABLE NAMES a2x.py a2x HINTS "${asciidoc_path}")
300   if(NOT ASCIIDOC_EXECUTABLE OR NOT A2X_EXECUTABLE)
301     message(SEND_ERROR
302       "AsciiDoc is required to create man and html help and the guides")
303   endif()
304   # read CONF_DIR from A2X_EXECUTABLE and copy style files over
305   if(A2X_EXECUTABLE)
306     file(READ "${A2X_EXECUTABLE}" _asciidoc_text)
307     if(_asciidoc_text MATCHES "[ \t]*CONF_DIR[ \t]*=[ \t]*r?['\"]([^'\"]+)")
308       set(A2X_CONF_DIR "${CMAKE_MATCH_1}")
309       if(IS_DIRECTORY "${A2X_CONF_DIR}")
310         configure_file("${A2X_CONF_DIR}/docbook-xsl/common.xsl"
311           "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-common.xsl"
312           COPYONLY)
313         configure_file("${A2X_CONF_DIR}/docbook-xsl/chunked.xsl"
314           "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-chunked.xsl"
315           COPYONLY)
316         configure_file("${A2X_CONF_DIR}/dblatex/asciidoc-dblatex.sty"
317           "${CMAKE_BINARY_DIR}/data/asciidoc/dblatex/orig-asciidoc-dblatex.sty"
318           COPYONLY)
319         configure_file("${A2X_CONF_DIR}/dblatex/asciidoc-dblatex.xsl"
320           "${CMAKE_BINARY_DIR}/data/asciidoc/dblatex/orig-asciidoc-dblatex.xsl"
321           COPYONLY)
322       else()
323         message(SEND_ERROR "The Asciidoc configuration directory "
324           "${A2X_CONF_DIR} does not exist")
325       endif()
326     else()
327       message(SEND_ERROR "Failed to read CONF_DIR from ${A2X_EXECUTABLE}")
328     endif()
329   endif()
330   set(FOAM_NEED_PNGMATH FALSE)
331   if(NOT FOAM_ENABLE_MATHJAX OR FOAM_USE_FOP)
332     set(FOAM_NEED_PNGMATH TRUE)
333     foreach(prog latex dvipng)
334       string(TOUPPER ${prog} uprog)
335       find_program(${uprog}_EXECUTABLE ${prog})
336       if(NOT ${uprog}_EXECUTABLE)
337         message(SEND_ERROR
338           "${prog} is required when FOAM_ENABLE_MATHJAX is disabled "
339           "or FOAM_USE_FOP is enabled")
340       endif()
341     endforeach()
342   endif()
343 endif()
344 if(FOAM_GUIDES_FORMATS)
345   # find asymptote
346   find_program(ASY_EXECUTABLE asy)
347   if(NOT ASY_EXECUTABLE)
348     message(SEND_ERROR "Asymptote is required to create the guides")
349   endif()
350 endif()
352 # set up the RPATH for installation
353 set(CMAKE_INSTALL_RPATH ${FOAM_INSTALL_LIBRARY_PATH})
354 set(CMAKE_INSTALL_NAME_DIR ${FOAM_FRAMEWORK_INSTALL_NAME_DIR})
356 # we want executables and libraries in uniform places
357 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
358   "${CMAKE_BINARY_DIR}/libexec/${PROJECT_NAME}/${FOAM_VERSION_FULL}")
359 set(FOAM_LIBRARY_OUTPUT_DIRECTORY
360   "${CMAKE_BINARY_DIR}/lib/${PROJECT_NAME}-${FOAM_VERSION_FULL}")
361 set(FOAM_FRAMEWORK_OUTPUT_DIRECTORY
362   "${CMAKE_BINARY_DIR}/Library/Frameworks")
363 if(FOAM_BUILD_FRAMEWORKS)
364   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_FRAMEWORK_OUTPUT_DIRECTORY}")
365 else()
366   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
367 endif()
368 set(FOAM_ARCHIVE_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
370 # find parallel libraries
371 find_package(MPI)
372 if(MPI_FOUND)
373   set(_FOAM_USE_MPI ON)
374 else()
375   set(_FOAM_USE_MPI OFF)
376 endif()
377 foam_option(FOAM_USE_MPI "Use MPI"
378   "Build ${CMAKE_PROJECT} against MPI parallel libraries" ${_FOAM_USE_MPI})
379 if(FOAM_USE_MPI AND NOT MPI_FOUND)
380   message(SEND_ERROR
381     "FOAM_ENABLE_MPI is true, but MPI cannot be found.\n"
382     "If you have MPI installed on your system, edit the variables\n"
383     "MPI_INCLUDE_DIR and MPI_LIBRARY in the cache, else disable the\n"
384     "setting FOAM_USE_MPI."
385   )
386 endif()
388 # find readline
389 find_package(Readline)
391 # substitution for build-tree and install-tree as used by
392 # foam_configure_files.
393 set(FOAM_CONFIGURE_FILES_VARIABLES
394   FOAM_DATA_DIR
395     "${CMAKE_BINARY_DIR}/data"
396     "${FOAM_INSTALL_DATA_PATH}"
397   FOAM_LOCAL_DOC_DIR
398     "${CMAKE_BINARY_DIR}/doc"
399     "${FOAM_INSTALL_DOC_PATH}"
400   FOAM_BIN_DIR
401     "${CMAKE_BINARY_DIR}/bin"
402     "${FOAM_INSTALL_BIN_PATH}"
403   FOAM_LIB_DIR
404     "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}"
405     "${FOAM_INSTALL_LIBRARY_PATH}"
406   FOAM_LIBEXEC_DIR
407     "${CMAKE_BINARY_DIR}/libexec/FreeFOAM/${FOAM_VERSION_FULL}"
408     "${FOAM_INSTALL_LIBEXEC_PATH}"
409   FOAM_FRAMEWORK_DIR
410     "${CMAKE_BINARY_DIR}/Library/Frameworks"
411     "${FOAM_INSTALL_FRAMEWORK_PATH}"
412   FOAM_INCLUDE_DIR
413     "${CMAKE_BINARY_DIR}/include"
414     "${FOAM_INSTALL_HEADER_PATH}"
415   FOAM_CONFIG_DIR
416     "${CMAKE_BINARY_DIR}/etc"
417     "${FOAM_INSTALL_CONFIG_PATH}"
418   FOAM_CMAKECONFIG_DIR
419     "${CMAKE_BINARY_DIR}/CMake"
420     "${FOAM_INSTALL_CMAKE_PATH}"
421   FOAM_PYTHON_DIR
422     "${CMAKE_BINARY_DIR}/data/python"
423     "${FOAM_INSTALL_PYTHON_PATH}"
424   FOAM_IS_INSTALLED
425     "FALSE"
426     "TRUE"
427   )
428 if(FOAM_USE_LOCAL_DOXYGEN_DOCS)
429   list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
430     FOAM_DOC_DIR "${CMAKE_BINARY_DIR}/doc" "${FOAM_INSTALL_DOC_PATH}")
431 else()
432   set(_sf_doc "http://freefoam.sf.net/doc/${FOAM_VERSION_FULL}")
433   list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
434     FOAM_DOC_DIR "${_sf_doc}" "${_sf_doc}")
435 endif()
437 # thirdparty libraries
438 foam_thirdparty_option(Metis
439   "Required by the metis decomposition method"
440   Metis TRUE ON)
441 if(FOAM_ENABLE_METIS)
442   if(FOAM_ENABLE_METIS AND METIS_REQUIRES_MPI AND NOT FOAM_USE_MPI)
443     message(SEND_ERROR
444       "Your metis implementation requires FOAM_USE_MPI to be enabled."
445       "If you don't have/want MPI, enable FOAM_BUILD_PRIVATE_METIS instead.")
446   endif()
447 endif()
448 foam_thirdparty_option(ParMetis
449   "Required by the parmetis decomposition method"
450   ParMetis TRUE ${FOAM_USE_MPI}
451   PARMETIS_metis_LIBRARY PARMETIS_parmetis_LIBRARY)
452 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_USE_MPI)
453   message(SEND_ERROR
454     "ParMetis requires FOAM_USE_MPI to be enabled.")
455 endif()
456 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_ENABLE_METIS)
457   message(SEND_ERROR
458     "ParMetis requires FOAM_ENABLE_METIS to be enabled.")
459 endif()
460 set(SCOTCH_USE_ERREXIT TRUE)
461 foam_thirdparty_option(SCOTCH "" SCOTCH FALSE ON SCOTCH_scotch_LIBRARY
462   SCOTCH_scotcherr_LIBRARY SCOTCH_scotcherrexit_LIBRARY)
463 # do not enable mgridgen by default (licensing issues)
464 if(NOT FOAM_DOUBLE_PRECISION)
465   set(MGRIDGEN_USE_REAL ON)
466 endif()
467 foam_thirdparty_option(MGRIDGEN
468   "Required by the MGridGen GAMG agglomerator. LICENSE UNCLEAR"
469   MGRIDGEN TRUE OFF)
470 # do not enable libccmio by default (licensing issues)
471 foam_thirdparty_option(ccmio
472   "Required by ccm26ToFoam. REQUIRES PERMISSION BY CDADAPCO!"
473   Ccmio TRUE OFF)
474 foam_thirdparty_option(zlib "" ZLIB FALSE ON)
476 if(FOAM_ENABLE_XHTML_GUIDES)
477   foam_thirdparty_option(MathJax
478     "Use MathJax for formulas in the XHTML version of the guides"
479     MathJax TRUE ON)
480   if(FOAM_ENABLE_MATHJAX)
481     if(FOAM_BUILD_PRIVATE_MATHJAX)
482       set(CONFIG_MATHJAX_DIR ../../../MathJax)
483     else()
484       set(CONFIG_MATHJAX_DIR "${MATHJAX_DIR}")
485     endif()
486   endif()
487 else()
488   set(FOAM_ENABLE_MATHJAX FALSE)
489 endif()
491 # figure out default Pstream library
492 if(FOAM_USE_MPI)
493   set(_FOAM_DEFAULT_PSTREAM mpi)
494 else()
495   set(_FOAM_DEFAULT_PSTREAM dummy)
496 endif()
497 set(FOAM_DEFAULT_PSTREAM ${_FOAM_DEFAULT_PSTREAM} CACHE STRING
498   "Default Pstream library implementation [dummy|mpi]")
499 mark_as_advanced(FOAM_DEFAULT_PSTREAM)
501 # find m4 macro processor
502 find_program(M4_EXECUTABLE m4 DOC "Path to the m4 macro processor")
503 mark_as_advanced(M4_EXECUTABLE)
504 if(NOT M4_EXECUTABLE)
505   message("WARNING: Failed to find M4 macro processor.\n"
506     "Some of the tutorials will fail if it can't be found.")
507   set(M4_EXECUTABLE m4)
508 endif()
510 # on APPLE use cp -R -P -p, otherwise use cp -a
511 if(APPLE)
512   set(FOAM_CP_A_FLAGS "-R -P -p")
513 else()
514   set(FOAM_CP_A_FLAGS "-a")
515 endif()
517 # execinfo.h and cxxabi.h only work using GNU gcc and Debug config
518 # assume that if we have execinfo.h, cxxabi.h is also present.
519 if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL Debug)
520   find_package(Execinfo)
521 endif()
523 # create the FOAMConfig.h file
524 configure_file(${CMAKE_SOURCE_DIR}/FOAMConfig.h.in
525   ${CMAKE_BINARY_DIR}/include/FOAMConfig.h @ONLY)
527 # on Solaris/SunOS fix up the shebangs
528 if(CMAKE_SYSTEM_NAME STREQUAL SunOS AND NOT EXISTS ${CMAKE_BINARY_DIR}/replaceAllShellSun.run)
529   message(STATUS "Fixing shell-interpreter for SunOS and Solaris")
530   execute_process(
531     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun bin
532     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun data
533     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun tutorials
534     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun doc
535     COMMAND ${CMAKE_COMMAND} -E touch${CMAKE_BINARY_DIR}/replaceAllShellSun.run
536     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
537     )
538 endif()
540 # set up defines
541 set(FOAM_COMPILE_DEFINITIONS
542   -D${FOAM_PRECISION}
543   -DNoRepository
544   -D${FOAM_OS}
545   )
546 if(APPLE)
547   list(APPEND FOAM_COMPILE_DEFINITIONS -Ddarwin)
548 endif()
549 add_definitions(${FOAM_COMPILE_DEFINITIONS})
551 # set up include-directories for own headers
552 include_directories(${CMAKE_BINARY_DIR}/include)
554 # descend into the sources...
555 add_subdirectory(bin)
556 add_subdirectory(etc)
557 add_subdirectory(data)
558 add_subdirectory(src)
559 add_subdirectory(applications)
560 add_subdirectory(tutorials)
561 add_subdirectory(doc)
563 # export the library dependencies to the build tree
564 foam_export_targets_to_build_tree(${PROJECT_NAME}LibraryDepends)
565 export(PACKAGE ${PROJECT_NAME})
567 # write the doc index file and install it
568 foam_write_doc_index()
569 install(FILES
570   ${CMAKE_BINARY_DIR}/InstallFiles/data/DoxyDocIndex
571   DESTINATION ${FOAM_INSTALL_DATA_PATH}
572   COMPONENT data
573   )
575 # create ${PROJECT_NAME}Config.cmake ${PROJECT_NAME}Use.cmake,
576 # ${PROJECT_NAME}Utilities.cmake and ${PROJECT_NAME}WmakeCompatibility.cmake
577 # for the build and install tree
578 foam_configure_files(ConfigInstallFiles
579   "CMake/FOAMConfig.cmake.in==CMake/${PROJECT_NAME}Config.cmake"
580   "CMake/FOAMUse.cmake.in==CMake/${PROJECT_NAME}Use.cmake"
581   "CMake/FOAMWmakeCompatibility.cmake.in==CMake/${PROJECT_NAME}WmakeCompatibility.cmake"
582   COPYONLY
583   "CMake/FOAMUtilities.cmake==CMake/${PROJECT_NAME}Utilities.cmake"
584   )
586 # install the CMake config files
587 install(FILES
588   ${ConfigInstallFiles}
589   DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
590   COMPONENT dev
591   )
593 # install the ${PROJECT_NAME}LibraryDepends.cmake file
594 install(EXPORT ${PROJECT_NAME}LibraryDepends
595   DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
596   NAMESPACE FOAM_
597   COMPONENT dev
598   )
600 # pack things up
601 if(FOAM_ENABLE_CPACK)
602   include(${CMAKE_SOURCE_DIR}/CMake/FOAMCPack.cmake)
603 endif()
605 # uninstall target
606 configure_file(
607   "${CMAKE_SOURCE_DIR}/CMake/Modules/cmake_uninstall.cmake.in"
608   "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
609   @ONLY
610   )
612 add_custom_target(uninstall
613   "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
614   )
616 # print cool feature summary
617 foam_print_feature_summary()
619 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file