1 #-------------------------------------------------------------------------------
3 # | ____| _| |_ / __ \ /\ | \/ |
4 # | |__ _ __ ___ ___ / \| | | | / \ | \ / |
5 # | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
6 # | | | | | __/ __/\_ _/| |__| / ____ \| | | |
7 # |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
9 # FreeFOAM: The Cross-Platform CFD Toolkit
11 # Copyright (C) 2008-2011 Michael Wild <themiwi@users.sf.net>
12 # Gerber van der Graaf <gerber_graaf@users.sf.net>
13 #-------------------------------------------------------------------------------
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
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.2 FATAL_ERROR)
36 string(TOLOWER "${PROJECT_NAME}" LOWER_PROJECT_NAME)
39 set(FOAM_VERSION_MAJOR 0)
40 set(FOAM_VERSION_MINOR 1)
41 set(FOAM_VERSION_PATCH 0)
42 set(FOAM_VERSION_SUFFIX rc5)
43 set(FOAM_VERSION ${FOAM_VERSION_MAJOR}.${FOAM_VERSION_MINOR})
45 ${FOAM_VERSION}.${FOAM_VERSION_PATCH}${FOAM_VERSION_SUFFIX})
47 set(FOAM_UPSTREAM_VERSION_FULL 1.7.x-d08d3c2)
49 # set up custom cmake module path
50 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
53 set(FOAM_CREATE_INCLUDE_WRAPPERS TRUE)
54 set(FOAM_HAS_FLEX_SOURCES TRUE)
55 set(FOAM_ENABLE_DOC_INDEX TRUE)
56 set(FOAM_EXPORT_NAMESPACE FOAM_)
57 include(${CMAKE_SOURCE_DIR}/CMake/FOAMUtilities.cmake)
58 include(${CMAKE_SOURCE_DIR}/CMake/FOAMThirdPartyUtilities.cmake)
59 include(${CMAKE_SOURCE_DIR}/CMake/FOAMInternal.cmake)
62 # determine computer system
63 include(${CMAKE_SOURCE_DIR}/CMake/FOAMDetermineArch.cmake)
66 foam_option(FOAM_DOUBLE_PRECISION "Double precision"
67 "Compile ${PROJECT_NAME} with double precision floating point arithmetics."
69 mark_as_advanced(FOAM_DOUBLE_PRECISION)
70 if(FOAM_DOUBLE_PRECISION)
71 set(FOAM_PRECISION DP)
73 set(FOAM_PRECISION SP)
76 # select whether we want to build framewors on Mac OS X
78 foam_option(FOAM_BUILD_FRAMEWORKS "Build frameworks"
79 "Build frameworks on Mac OS X" OFF)
80 mark_as_advanced(FOAM_BUILD_FRAMEWORKS)
82 set(FOAM_BUILD_FRAMEWORKS OFF)
85 # find python interpreter
86 find_package(PythonInterp REQUIRED)
88 # make sure we got Python version 2.6 or newer
89 foam_dependent_variables(PYTHON_EXECUTABLE PYTHON_VERSION)
90 if(NOT PYTHON_VERSION)
92 COMMAND ${PYTHON_EXECUTABLE} -c
93 "import sys; sys.stdout.write('%s.%s.%s\\n'%sys.version_info[0:3])"
94 RESULT_VARIABLE _py_version_result
95 OUTPUT_VARIABLE _py_version_output
96 ERROR_VARIABLE _py_version_output
97 OUTPUT_STRIP_TRAILING_WHITESPACE
99 if(NOT _py_version_result)
100 string(REGEX MATCH "([0-9]+\\.)+[0-9]+" PYTHON_VERSION
101 "${_py_version_output}")
102 message(STATUS "Python version ${PYTHON_VERSION} found")
103 if(${PYTHON_VERSION} VERSION_LESS 2.4.0)
104 message(SEND_ERROR "Python version 2.4 or newer required")
107 set(PYTHON_VERSION PYTHON_VERSION-NOTFOUND)
109 "Failed to determine the python version: ${_py_version_output}")
111 set(PYTHON_VERSION ${PYTHON_VERSION} CACHE INTERNAL "The Python version")
113 string(REGEX REPLACE "\\.[0-9]+$" "" PYTHON_SHORT_VERSION ${PYTHON_VERSION})
115 # find the installed ParaView executable
117 FOAM_PARAVIEW3_APP NAMES "ParaView 3.8.1" "ParaView 3.8.0" ParaView paraview
118 DOC "Path to the ParaView 3.8 (or newer) application"
120 mark_as_advanced(FOAM_PARAVIEW3_APP)
121 foam_dependent_variables(FOAM_PARAVIEW3_APP FOAM_PARAVIEW3_VERSION)
122 if(FOAM_PARAVIEW3_APP)
123 if(NOT FOAM_PARAVIEW3_VERSION)
124 execute_process(COMMAND ${FOAM_PARAVIEW3_APP} --version
125 OUTPUT_VARIABLE _pv_version_output
126 ERROR_VARIABLE _pv_version_output
127 OUTPUT_STRIP_TRAILING_WHITESPACE
129 if(_pv_version_output MATCHES "ParaView(([0-9]+\\.)+[0-9]+)")
130 set(FOAM_PARAVIEW3_VERSION ${CMAKE_MATCH_1} CACHE INTERNAL
131 "The ParaView version")
133 "ParaView ${FOAM_PARAVIEW3_VERSION} found: ${FOAM_PARAVIEW3_APP}")
136 "Failed to determine the ParaView version: ${_pv_version_output}")
139 if(${FOAM_PARAVIEW3_VERSION} VERSION_LESS 3.8)
141 "ParaView versions older than 3.8 might not be able\n"
142 "to read ${PROJECT_NAME} cases.")
146 "Failed to find the ParaView application")
147 set(FOAM_PARAVIEW3_APP)
150 # we want shared libraries
151 set(BUILD_SHARED_LIBS SHARED)
153 # installation directories
154 foam_installation_path(FOAM_INSTALL_BIN_PATH bin "Executables"
155 "Executables installation path")
156 if(APPLE AND FOAM_BUILD_FRAMEWORKS)
157 foam_installation_path(FOAM_INSTALL_FRAMEWORK_PATH /Library/Frameworks
158 "Frameworks" "Framework installation path")
160 foam_installation_path(FOAM_INSTALL_LIBRARY_PATH
161 lib/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL}
162 "Libraries" "Library installation path")
164 foam_installation_path(FOAM_INSTALL_PLUGIN_PATH
165 "${FOAM_INSTALL_LIBRARY_PATH_ORIG}/plugins${FOAM_SOVERSION}"
166 "Plugins" "Plugin installation path")
168 foam_installation_path(FOAM_INSTALL_LIBEXEC_PATH
169 libexec/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Private executables"
170 "Installation path for executables not on PATH.")
171 foam_installation_path(FOAM_INSTALL_HEADER_PATH
172 include/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL}
173 "Headers" "Header installation path (not for frameworks)")
174 foam_installation_path(FOAM_INSTALL_CONFIG_PATH
175 etc/${CMAKE_PROJECT_NAME}/${FOAM_VERSION_FULL} "Config files"
176 "Configuration files installation path")
177 foam_installation_path(FOAM_INSTALL_DATA_PATH
178 share/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Data files"
179 "Data files installation path")
180 foam_installation_path(FOAM_INSTALL_DOC_PATH
181 share/doc/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Documentation"
182 "Documentation files installation path")
183 foam_installation_path(FOAM_INSTALL_MAN_PATH share/man "Man pages"
184 "Man-pages installation path")
185 foam_installation_path(FOAM_INSTALL_TUTORIALS_PATH
186 "${FOAM_INSTALL_DOC_PATH_ORIG}" "Tutorials" "Tutorials installation path")
187 foam_installation_path(FOAM_INSTALL_CMAKE_PATH
188 "${FOAM_INSTALL_DATA_PATH_ORIG}/CMake"
189 "CMake files" "CMake configuration files installation path")
190 foam_installation_path(FOAM_INSTALL_USERDFOAM_PATH
191 "${FOAM_INSTALL_PLUGIN_PATH_ORIG}/ensightReader"
192 "Ensight plugin" "Ensight OpenFOAM-reader plugin installation path")
193 foam_installation_path(FOAM_INSTALL_PYTHON_PATH
194 "lib/python${PYTHON_SHORT_VERSION}/site-packages"
195 "Python modules" "Python modules installation base path")
197 set(FOAM_INSTALL_RUNTIME_PATH "${FOAM_INSTALL_LIBEXEC_PATH}")
199 # determine the INSTALL_NAME_DIR of potential frameworks
200 if(APPLE AND FOAM_BUILD_FRAMEWORKS)
201 set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_FRAMEWORK_PATH}")
203 set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_LIBRARY_PATH}")
206 # select html documentation browser (try a few well known ones for default)
207 # have to loop, because find_program(HTML_DOC_BROWSER NAMES ...) garbles things
209 set(_BROWSERS xdg-open sensible-browser x-www-browser gnome-open kde-open
210 firefox chromium-browser epiphany konqueror www-browser w3m lynx launch)
212 list(INSERT _BROWSERS 0 open)
214 foreach(browser IN LISTS _BROWSERS)
215 find_program(HTML_DOC_BROWSER ${browser}
216 DOC "Program to open an HTML file")
221 if(NOT HTML_DOC_BROWSER)
223 "Failed to find a program to open HTML pages with (a.k.a a browser).\n"
224 "Point HTML_DOC_BROWSER to a suitable program.")
225 set(HTML_DOC_BROWSER "ECHO" CACHE STRING
226 "Command to open an HTML file (ECHO will print it to STDOUT)" FORCE)
228 set(FOAM_HTML_DOC_BROWSER_COMMAND
229 "\${HTML_DOC_BROWSER} %f" CACHE STRING "Command to open an HTML file")
230 string(CONFIGURE "${FOAM_HTML_DOC_BROWSER_COMMAND}"
231 FOAM_HTML_DOC_BROWSER_COMMAND ESCAPE_QUOTES)
232 mark_as_advanced(HTML_DOC_BROWSER FOAM_HTML_DOC_BROWSER_COMMAND)
235 string(TOLOWER "${PROJECT_NAME}-" _FOAM_DEFAULT_EXE_PREFIX)
236 set(FOAM_EXE_PREFIX "${_FOAM_DEFAULT_EXE_PREFIX}"
237 CACHE STRING "Prefix for application output-names")
238 mark_as_advanced(FOAM_EXE_PREFIX)
239 string(TOUPPER "${FOAM_EXE_PREFIX}" FOAM_UPPER_EXE_PREFIX)
241 # ask user whether she wants to build Doxygen docs
242 foam_option(FOAM_ENABLE_DOXYGEN_DOCS "Doxygen API documentation"
243 "Build the Doxygen API documentation" OFF)
244 # make sure only ON and OFF are used
245 if(FOAM_ENABLE_DOXYGEN_DOCS)
246 set(FOAM_ENABLE_DOXYGEN_DOCS ON)
248 set(FOAM_ENABLE_DOXYGEN_DOCS OFF)
250 # if user wants doxygen docs, find Doxygen and set up some options
251 if(FOAM_ENABLE_DOXYGEN_DOCS)
252 find_package(Doxygen REQUIRED)
253 execute_process(COMMAND ${DOXYGEN_EXECUTABLE} --version
254 RESULT_VARIABLE DOXYGEN_VERSION_RESULT
255 OUTPUT_VARIABLE DOXYGEN_VERSION_OUTPUT
256 OUTPUT_STRIP_TRAILING_WHITESPACE)
257 if(DOXYGEN_VERSION_RESULT)
258 message(SEND_ERROR "Failed to determine doxygen version")
260 if(${DOXYGEN_VERSION_OUTPUT} VERSION_GREATER 1.6.3 AND
261 ${DOXYGEN_VERSION_OUTPUT} VERSION_LESS 1.7.2-20101106)
263 "Found Doxygen version ${DOXYGEN_VERSION_OUTPUT}. "
264 "Versions newer than 1.6.3 and older than 1.7.2-20101106 "
265 "usually crash when processing the ${PROJECT_NAME} documentation.")
267 # ask user whether she prefers local or www docs
268 foam_option(FOAM_USE_LOCAL_DOXYGEN_DOCS "Use local API docs"
269 "Use the local API documentation instead of http://freefoam.sf.net/doc/API"
271 mark_as_advanced(FOAM_USE_LOCAL_DOXYGEN_DOCS)
274 # ask user whether she wants to build the man pages
275 foam_option(FOAM_ENABLE_MANPAGE_HELP "Build manpage help"
276 "Build the manpages (requires asciidoc)" OFF)
277 # ask user whether she wants to build the xhtml man pages
278 foam_option(FOAM_ENABLE_XHTML_HELP "Build xhtml help"
279 "Build the xhtml help pages (requires asciidoc)" OFF)
280 # as user whether she wanst to build the xhtml guides
281 foam_option(FOAM_ENABLE_XHTML_GUIDES "Build the xhtml guides"
282 "Build the xhtml guides (requires asciidoc, dot, inkscape and asymptote)"
284 # as user whether she wanst to build the xhtml guides
285 foam_option(FOAM_ENABLE_PDF_GUIDES "Build the PDF guides"
286 "Build the PDF guides (requires asciidoc, dot, inkscape and asymptote)" OFF)
287 if(FOAM_ENABLE_PDF_GUIDES)
288 foam_option(FOAM_USE_FOP "Use FOP instead of dblatex"
289 "Use FOP to build the PDF guides instead of dblatex" OFF)
290 mark_as_advanced(FOAM_USE_FOP)
292 set(FOAM_USE_FOP FALSE)
295 if(FOAM_ENABLE_DOXYGEN_DOCS OR FOAM_ENABLE_XHTML_GUIDES)
296 foam_option(FOAM_DOCS_FOR_SF "Docs for SourceForge"
297 "Build the docs for deployment on SourceForge" OFF)
298 mark_as_advanced(FOAM_DOCS_FOR_SF)
299 # make sure only ON and OFF are used
301 set(FOAM_DOCS_FOR_SF ON)
303 set(FOAM_DOCS_FOR_SF OFF)
308 # ask user whether whe wants full tutorial tests
309 foam_option(FOAM_ENABLE_FULL_TUTORIAL_TESTS
310 "Full tutorial tests"
311 "Run the complete tutorial tests (not just a single time step)" OFF)
312 mark_as_advanced(FOAM_ENABLE_FULL_TUTORIAL_TESTS)
315 if(FOAM_ENABLE_XHTML_GUIDES)
316 set(FOAM_ENABLE_XHTML_GUIDES ON)
317 foam_option(FOAM_ENABLE_MATHJAX "Use MathJax in XHTML guides"
318 "Use MathJax for formulas in the XHTML version of the guides" ON)
319 if(FOAM_ENABLE_MATHJAX)
320 foam_option(FOAM_MATHJAX_USE_CDN
321 "Use the MathJax CDN"
322 "Use public MathJax installation at http://cdn.mathjax.org" ON)
323 mark_as_advanced(FOAM_MATHJAX_USE_CDN)
324 if(FOAM_MATHJAX_USE_CDN)
325 set(FOAM_MATHJAX_URL "http://cdn.mathjax.org/mathjax/latest")
327 set(FOAM_MATHJAX_URL "MathJAX-NOTFOUND" CACHE PATH
328 "Path or URL to the MathJax directory containing the MathJax.js file")
329 mark_as_advanced(FOAM_MATHJAX_URL)
330 if(NOT FOAM_MATHJAX_URL)
331 message(SEND_ERROR "FOAM_MATHJAX_URL must be set to the directory or "
332 "URL containing MathJax.js")
337 set(FOAM_ENABLE_XHTML_GUIDES OFF)
338 set(FOAM_ENABLE_MATHJAX FALSE)
341 # assemble the list of enabled manpage formats
342 set(FOAM_MANPAGE_FORMATS)
343 if(FOAM_ENABLE_MANPAGE_HELP)
344 list(APPEND FOAM_MANPAGE_FORMATS manpage)
346 if(FOAM_ENABLE_XHTML_HELP)
347 list(APPEND FOAM_MANPAGE_FORMATS xhtml)
350 # assemble the list of enabled guides formats
351 set(FOAM_GUIDES_FORMATS)
352 if(FOAM_ENABLE_XHTML_GUIDES)
353 list(APPEND FOAM_GUIDES_FORMATS xhtml)
355 if(FOAM_ENABLE_PDF_GUIDES)
356 list(APPEND FOAM_GUIDES_FORMATS pdf)
359 if(FOAM_MANPAGE_FORMATS OR FOAM_GUIDES_FORMATS)
361 find_program(ASCIIDOC_EXECUTABLE NAMES asciidoc.py asciidoc)
362 get_filename_component(asciidoc_path "${ASCIIDOC_EXECUTABLE}" PATH)
363 find_program(A2X_EXECUTABLE NAMES a2x.py a2x HINTS "${asciidoc_path}")
364 if(NOT ASCIIDOC_EXECUTABLE OR NOT A2X_EXECUTABLE)
366 "AsciiDoc is required to create man and html help and the guides")
368 mark_as_advanced(ASCIIDOC_EXECUTABLE A2X_EXECUTABLE)
369 # read CONF_DIR from A2X_EXECUTABLE and copy style files over
371 file(READ "${A2X_EXECUTABLE}" _asciidoc_text)
372 if(_asciidoc_text MATCHES "[ \t]*CONF_DIR[ \t]*=[ \t]*r?['\"]([^'\"]+)")
373 set(A2X_CONF_DIR "${CMAKE_MATCH_1}")
374 if(IS_DIRECTORY "${A2X_CONF_DIR}")
375 configure_file("${A2X_CONF_DIR}/docbook-xsl/common.xsl"
376 "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-common.xsl"
378 configure_file("${A2X_CONF_DIR}/docbook-xsl/chunked.xsl"
379 "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-chunked.xsl"
381 configure_file("${A2X_CONF_DIR}/docbook-xsl/xhtml.xsl"
382 "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-xhtml.xsl"
384 configure_file("${A2X_CONF_DIR}/dblatex/asciidoc-dblatex.sty"
385 "${CMAKE_BINARY_DIR}/data/asciidoc/dblatex/orig-asciidoc-dblatex.sty"
387 configure_file("${A2X_CONF_DIR}/dblatex/asciidoc-dblatex.xsl"
388 "${CMAKE_BINARY_DIR}/data/asciidoc/dblatex/orig-asciidoc-dblatex.xsl"
391 message(SEND_ERROR "The Asciidoc configuration directory "
392 "${A2X_CONF_DIR} does not exist")
395 message(SEND_ERROR "Failed to read CONF_DIR from ${A2X_EXECUTABLE}")
398 set(FOAM_NEED_PNGMATH FALSE)
399 if((FOAM_ENABLE_XHTML_GUIDES AND NOT FOAM_ENABLE_MATHJAX) OR
400 (FOAM_ENABLE_PDF_GUIES AND FOAM_USE_FOP))
401 set(FOAM_NEED_PNGMATH TRUE)
402 foreach(prog latex dvipng)
403 string(TOUPPER ${prog} uprog)
404 find_program(${uprog}_EXECUTABLE ${prog})
405 mark_as_advanced(${uprog}_EXECUTABLE)
406 if(NOT ${uprog}_EXECUTABLE)
408 "${prog} is required when FOAM_ENABLE_MATHJAX is disabled "
409 "or FOAM_USE_FOP is enabled")
414 if(FOAM_GUIDES_FORMATS)
416 find_program(ASY_EXECUTABLE asy)
417 if(NOT ASY_EXECUTABLE)
418 message(SEND_ERROR "Asymptote is required to create the guides")
420 mark_as_advanced(ASY_EXECUTABLE)
423 # set up the RPATH for installation
424 set(CMAKE_INSTALL_RPATH ${FOAM_INSTALL_LIBRARY_PATH})
425 set(CMAKE_INSTALL_NAME_DIR ${FOAM_FRAMEWORK_INSTALL_NAME_DIR})
427 # we want executables and libraries in uniform places
428 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
429 "${CMAKE_BINARY_DIR}/libexec/${PROJECT_NAME}/${FOAM_VERSION_FULL}")
430 set(FOAM_LIBRARY_OUTPUT_DIRECTORY
431 "${CMAKE_BINARY_DIR}/lib/${PROJECT_NAME}-${FOAM_VERSION_FULL}")
432 set(FOAM_FRAMEWORK_OUTPUT_DIRECTORY
433 "${CMAKE_BINARY_DIR}/Library/Frameworks")
434 if(FOAM_BUILD_FRAMEWORKS)
435 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_FRAMEWORK_OUTPUT_DIRECTORY}")
437 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
439 set(FOAM_ARCHIVE_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
441 # find parallel libraries
444 set(_FOAM_USE_MPI ON)
446 set(_FOAM_USE_MPI OFF)
448 foam_option(FOAM_USE_MPI "Use MPI"
449 "Build ${CMAKE_PROJECT} against MPI parallel libraries" ${_FOAM_USE_MPI})
450 mark_as_advanced(FOAM_USE_MPI)
451 if(FOAM_USE_MPI AND NOT MPI_FOUND)
453 "FOAM_ENABLE_MPI is true, but MPI cannot be found.\n"
454 "If you have MPI installed on your system, edit the variables\n"
455 "MPI_INCLUDE_DIR and MPI_LIBRARY in the cache, else disable the\n"
456 "setting FOAM_USE_MPI."
461 find_package(Readline)
463 # substitution for build-tree and install-tree as used by
464 # foam_configure_files.
465 set(FOAM_CONFIGURE_FILES_VARIABLES
467 "${CMAKE_BINARY_DIR}/data"
468 "${FOAM_INSTALL_DATA_PATH}"
470 "${CMAKE_BINARY_DIR}/doc"
471 "${FOAM_INSTALL_DOC_PATH}"
473 "${CMAKE_BINARY_DIR}/bin"
474 "${FOAM_INSTALL_BIN_PATH}"
476 "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}"
477 "${FOAM_INSTALL_LIBRARY_PATH}"
479 "${CMAKE_BINARY_DIR}/libexec/FreeFOAM/${FOAM_VERSION_FULL}"
480 "${FOAM_INSTALL_LIBEXEC_PATH}"
482 "${CMAKE_BINARY_DIR}/Library/Frameworks"
483 "${FOAM_INSTALL_FRAMEWORK_PATH}"
485 "${CMAKE_BINARY_DIR}/include"
486 "${FOAM_INSTALL_HEADER_PATH}"
488 "${CMAKE_BINARY_DIR}/etc"
489 "${FOAM_INSTALL_CONFIG_PATH}"
491 "${CMAKE_BINARY_DIR}/CMake"
492 "${FOAM_INSTALL_CMAKE_PATH}"
494 "${CMAKE_BINARY_DIR}/data/python"
495 "${FOAM_INSTALL_PYTHON_PATH}"
501 list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
503 "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}"
504 "${FOAM_INSTALL_LIBRARY_PATH}")
506 list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
508 "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}/plugins"
509 "${FOAM_INSTALL_PLUGIN_PATH}")
511 if(FOAM_USE_LOCAL_DOXYGEN_DOCS)
512 list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
513 FOAM_DOC_DIR "${CMAKE_BINARY_DIR}/doc" "${FOAM_INSTALL_DOC_PATH}")
515 set(_sf_doc "http://freefoam.sf.net/doc/${FOAM_VERSION_FULL}")
516 list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
517 FOAM_DOC_DIR "${_sf_doc}" "${_sf_doc}")
520 # thirdparty libraries
521 foam_thirdparty_option(Metis
522 "Required by the metis decomposition method"
524 if(FOAM_ENABLE_METIS)
525 if(FOAM_ENABLE_METIS AND METIS_REQUIRES_MPI AND NOT FOAM_USE_MPI)
527 "Your metis implementation requires FOAM_USE_MPI to be enabled."
528 "If you don't have/want MPI, enable FOAM_BUILD_PRIVATE_METIS instead.")
531 foam_thirdparty_option(ParMetis
532 "Required by the parmetis decomposition method"
533 ParMetis TRUE ${FOAM_USE_MPI}
534 PARMETIS_metis_LIBRARY PARMETIS_parmetis_LIBRARY)
535 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_USE_MPI)
537 "ParMetis requires FOAM_USE_MPI to be enabled.")
539 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_ENABLE_METIS)
541 "ParMetis requires FOAM_ENABLE_METIS to be enabled.")
543 set(SCOTCH_USE_ERREXIT TRUE)
544 foam_thirdparty_option(SCOTCH "" SCOTCH FALSE ON SCOTCH_scotch_LIBRARY
545 SCOTCH_scotcherr_LIBRARY SCOTCH_scotcherrexit_LIBRARY)
546 # do not enable mgridgen by default (licensing issues)
547 if(NOT FOAM_DOUBLE_PRECISION)
548 set(MGRIDGEN_USE_REAL ON)
550 foam_thirdparty_option(MGRIDGEN
551 "Required by the MGridGen GAMG agglomerator. LICENSE UNCLEAR"
553 # do not enable libccmio by default (licensing issues)
554 foam_thirdparty_option(ccmio
555 "Required by ccm26ToFoam. REQUIRES PERMISSION BY CDADAPCO!"
557 foam_thirdparty_option(zlib "" ZLIB FALSE ON)
559 # figure out default Pstream library
561 set(_FOAM_DEFAULT_PSTREAM mpi)
563 set(_FOAM_DEFAULT_PSTREAM dummy)
565 set(FOAM_DEFAULT_PSTREAM ${_FOAM_DEFAULT_PSTREAM} CACHE STRING
566 "Default Pstream library implementation [dummy|mpi]")
567 mark_as_advanced(FOAM_DEFAULT_PSTREAM)
569 # find m4 macro processor
570 find_program(M4_EXECUTABLE m4 DOC "Path to the m4 macro processor")
571 mark_as_advanced(M4_EXECUTABLE)
572 if(NOT M4_EXECUTABLE)
573 message("WARNING: Failed to find M4 macro processor.\n"
574 "Some of the tutorials will fail if it can't be found.")
575 set(M4_EXECUTABLE m4)
578 # on APPLE use cp -R -P -p, otherwise use cp -a
580 set(FOAM_CP_A_FLAGS "-R -P -p")
582 set(FOAM_CP_A_FLAGS "-a")
585 # execinfo.h and cxxabi.h only work using GNU gcc and Debug config
586 # assume that if we have execinfo.h, cxxabi.h is also present.
587 if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL Debug)
588 find_package(Execinfo)
591 # create the FOAMConfig.h file
592 configure_file(${CMAKE_SOURCE_DIR}/FOAMConfig.h.in
593 ${CMAKE_BINARY_DIR}/include/FOAMConfig.h @ONLY)
595 # on Solaris/SunOS fix up the shebangs
596 if(CMAKE_SYSTEM_NAME STREQUAL SunOS AND
597 NOT EXISTS ${CMAKE_BINARY_DIR}/replaceAllShellSun.run)
598 message(STATUS "Fixing shell-interpreter for SunOS and Solaris")
600 COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun bin
601 COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun data
602 COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun tutorials
603 COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun doc
604 COMMAND ${CMAKE_COMMAND} -E touch${CMAKE_BINARY_DIR}/replaceAllShellSun.run
605 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
610 set(FOAM_COMPILE_DEFINITIONS
616 list(APPEND FOAM_COMPILE_DEFINITIONS -Ddarwin)
618 add_definitions(${FOAM_COMPILE_DEFINITIONS})
620 # set up include-directories for own headers
621 include_directories(${CMAKE_BINARY_DIR}/include)
623 # set up version info checks and updating of global.C
624 set(FOAM_HAVE_GIT FALSE)
625 if(EXISTS "${CMAKE_SOURCE_DIR}/.git/config")
628 set(FOAM_HAVE_GIT TRUE)
629 option(FOAM_VERSION_CHECK_WARN_ONLY
630 "Only warn if the version numbers are wrong" FALSE)
631 mark_as_advanced(FOAM_VERSION_CHECK_WARN_ONLY)
632 configure_file(CMake/ConfigureGlobalC.cmake.in
633 "${CMAKE_BINARY_DIR}/CMake/ConfigureGlobalC.cmake" @ONLY)
634 add_custom_target(version_check ALL
635 COMMAND "${PYTHON_EXECUTABLE}"
636 "${CMAKE_BINARY_DIR}/data/utilities/checkVersionInfo.py"
637 ${_CHECK_VERSION_INFO_ARGS}
638 DEPENDS "${CMAKE_BINARY_DIR}/data/utilities/checkVersionInfo.py"
639 COMMENT "Checking version information"
643 "Not performing version checks because GIT_EXECUTABLE is missing")
647 "Not performing version checks because not in a Git checkout")
650 if(NOT FOAM_HAVE_GIT)
651 if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.build.cmake)
652 message(SEND_ERROR "If not in a Git checkout, .build.cmake is required")
654 include(${CMAKE_SOURCE_DIR}/.build.cmake)
657 # descend into the sources...
658 add_subdirectory(bin)
659 add_subdirectory(etc)
660 add_subdirectory(data)
661 add_subdirectory(src)
662 add_subdirectory(applications)
663 add_subdirectory(tutorials)
664 # doc *must* be last, else manpage and Doxygen generation fails
665 add_subdirectory(doc)
667 # export the library dependencies to the build tree
668 foam_export_targets_to_build_tree(${PROJECT_NAME}LibraryDepends)
669 export(PACKAGE ${PROJECT_NAME})
671 # write the doc index file and install it
672 foam_write_doc_index()
674 ${CMAKE_BINARY_DIR}/InstallFiles/data/DoxyDocIndex
675 DESTINATION ${FOAM_INSTALL_DATA_PATH}
679 # create ${PROJECT_NAME}Config.cmake ${PROJECT_NAME}Use.cmake,
680 # ${PROJECT_NAME}Utilities.cmake and ${PROJECT_NAME}WmakeCompatibility.cmake
681 # for the build and install tree
682 foam_configure_files(ConfigInstallFiles
683 "CMake/FOAMConfig.cmake.in==CMake/${PROJECT_NAME}Config.cmake"
684 "CMake/FOAMUse.cmake.in==CMake/${PROJECT_NAME}Use.cmake"
685 "CMake/FOAMWmakeCompatibility.cmake.in==CMake/${PROJECT_NAME}WmakeCompatibility.cmake"
687 "CMake/FOAMUtilities.cmake==CMake/${PROJECT_NAME}Utilities.cmake"
690 # install the CMake config files
692 ${ConfigInstallFiles}
693 DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
697 # install the ${PROJECT_NAME}LibraryDepends.cmake file
698 install(EXPORT ${PROJECT_NAME}LibraryDepends
699 DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
706 "${CMAKE_SOURCE_DIR}/CMake/Modules/cmake_uninstall.cmake.in"
707 "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
711 add_custom_target(uninstall
712 "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
715 # print cool feature summary
716 foam_print_feature_summary()
718 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file