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 rc6)
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.12.0" "ParaView 3.10.1"
118 "ParaView 3.10.0" "ParaView 3.8.1" "ParaView 3.8.0" ParaView paraview
119 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
130 "(paraview version |ParaView)(([0-9]+\\.)+[0-9]+)")
131 set(FOAM_PARAVIEW3_VERSION ${CMAKE_MATCH_2} CACHE INTERNAL
132 "The ParaView version")
134 "ParaView ${FOAM_PARAVIEW3_VERSION} found: ${FOAM_PARAVIEW3_APP}")
137 "Failed to determine the ParaView version: ${_pv_version_output}")
140 if(${FOAM_PARAVIEW3_VERSION} VERSION_LESS 3.8)
142 "ParaView versions older than 3.8 might not be able\n"
143 "to read ${PROJECT_NAME} cases.")
147 "Failed to find the ParaView application")
148 set(FOAM_PARAVIEW3_APP)
151 # we want shared libraries
152 set(BUILD_SHARED_LIBS SHARED)
154 # installation directories
155 foam_installation_path(FOAM_INSTALL_BIN_PATH bin "Executables"
156 "Executables installation path")
157 if(APPLE AND FOAM_BUILD_FRAMEWORKS)
158 foam_installation_path(FOAM_INSTALL_FRAMEWORK_PATH /Library/Frameworks
159 "Frameworks" "Framework installation path")
161 foam_installation_path(FOAM_INSTALL_LIBRARY_PATH
162 lib/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL}
163 "Libraries" "Library installation path")
165 foam_installation_path(FOAM_INSTALL_PLUGIN_PATH
166 "${FOAM_INSTALL_LIBRARY_PATH_ORIG}/plugins${FOAM_SOVERSION}"
167 "Plugins" "Plugin installation path")
169 foam_installation_path(FOAM_INSTALL_LIBEXEC_PATH
170 libexec/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Private executables"
171 "Installation path for executables not on PATH.")
172 foam_installation_path(FOAM_INSTALL_HEADER_PATH
173 include/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL}
174 "Headers" "Header installation path (not for frameworks)")
175 foam_installation_path(FOAM_INSTALL_CONFIG_PATH
176 etc/${CMAKE_PROJECT_NAME}/${FOAM_VERSION_FULL} "Config files"
177 "Configuration files installation path")
178 foam_installation_path(FOAM_INSTALL_DATA_PATH
179 share/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Data files"
180 "Data files installation path")
181 foam_installation_path(FOAM_INSTALL_DOC_PATH
182 share/doc/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Documentation"
183 "Documentation files installation path")
184 foam_installation_path(FOAM_INSTALL_MAN_PATH share/man "Man pages"
185 "Man-pages installation path")
186 foam_installation_path(FOAM_INSTALL_TUTORIALS_PATH
187 "${FOAM_INSTALL_DOC_PATH_ORIG}" "Tutorials" "Tutorials installation path")
188 foam_installation_path(FOAM_INSTALL_CMAKE_PATH
189 "${FOAM_INSTALL_DATA_PATH_ORIG}/CMake"
190 "CMake files" "CMake configuration files installation path")
191 foam_installation_path(FOAM_INSTALL_USERDFOAM_PATH
192 "${FOAM_INSTALL_PLUGIN_PATH_ORIG}/ensightReader"
193 "Ensight plugin" "Ensight OpenFOAM-reader plugin installation path")
194 foam_installation_path(FOAM_INSTALL_PYTHON_PATH
195 "lib/python${PYTHON_SHORT_VERSION}/site-packages"
196 "Python modules" "Python modules installation base path")
198 set(FOAM_INSTALL_RUNTIME_PATH "${FOAM_INSTALL_LIBEXEC_PATH}")
200 # determine the INSTALL_NAME_DIR of potential frameworks
201 if(APPLE AND FOAM_BUILD_FRAMEWORKS)
202 set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_FRAMEWORK_PATH}")
204 set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_LIBRARY_PATH}")
207 # select html documentation browser (try a few well known ones for default)
208 # have to loop, because find_program(HTML_DOC_BROWSER NAMES ...) garbles things
210 set(_BROWSERS xdg-open sensible-browser x-www-browser gnome-open kde-open
211 firefox chromium-browser epiphany konqueror www-browser w3m lynx launch)
213 list(INSERT _BROWSERS 0 open)
215 foreach(browser IN LISTS _BROWSERS)
216 find_program(HTML_DOC_BROWSER ${browser}
217 DOC "Program to open an HTML file")
222 if(NOT HTML_DOC_BROWSER)
224 "Failed to find a program to open HTML pages with (a.k.a a browser).\n"
225 "Point HTML_DOC_BROWSER to a suitable program.")
226 set(HTML_DOC_BROWSER "ECHO" CACHE STRING
227 "Command to open an HTML file (ECHO will print it to STDOUT)" FORCE)
229 set(FOAM_HTML_DOC_BROWSER_COMMAND
230 "\${HTML_DOC_BROWSER} %f" CACHE STRING "Command to open an HTML file")
231 string(CONFIGURE "${FOAM_HTML_DOC_BROWSER_COMMAND}"
232 FOAM_HTML_DOC_BROWSER_COMMAND ESCAPE_QUOTES)
233 mark_as_advanced(HTML_DOC_BROWSER FOAM_HTML_DOC_BROWSER_COMMAND)
236 string(TOLOWER "${PROJECT_NAME}-" _FOAM_DEFAULT_EXE_PREFIX)
237 set(FOAM_EXE_PREFIX "${_FOAM_DEFAULT_EXE_PREFIX}"
238 CACHE STRING "Prefix for application output-names")
239 mark_as_advanced(FOAM_EXE_PREFIX)
240 string(TOUPPER "${FOAM_EXE_PREFIX}" FOAM_UPPER_EXE_PREFIX)
242 # ask user whether she wants to build Doxygen docs
243 foam_option(FOAM_ENABLE_DOXYGEN_DOCS "Doxygen API documentation"
244 "Build the Doxygen API documentation" OFF)
245 # make sure only ON and OFF are used
246 if(FOAM_ENABLE_DOXYGEN_DOCS)
247 set(FOAM_ENABLE_DOXYGEN_DOCS ON)
249 set(FOAM_ENABLE_DOXYGEN_DOCS OFF)
251 # if user wants doxygen docs, find Doxygen and set up some options
252 if(FOAM_ENABLE_DOXYGEN_DOCS)
253 find_package(Doxygen REQUIRED)
254 execute_process(COMMAND ${DOXYGEN_EXECUTABLE} --version
255 RESULT_VARIABLE DOXYGEN_VERSION_RESULT
256 OUTPUT_VARIABLE DOXYGEN_VERSION_OUTPUT
257 OUTPUT_STRIP_TRAILING_WHITESPACE)
258 if(DOXYGEN_VERSION_RESULT)
259 message(SEND_ERROR "Failed to determine doxygen version")
261 if(${DOXYGEN_VERSION_OUTPUT} VERSION_GREATER 1.6.3 AND
262 ${DOXYGEN_VERSION_OUTPUT} VERSION_LESS 1.7.2-20101106)
264 "Found Doxygen version ${DOXYGEN_VERSION_OUTPUT}. "
265 "Versions newer than 1.6.3 and older than 1.7.2-20101106 "
266 "usually crash when processing the ${PROJECT_NAME} documentation.")
268 # ask user whether she prefers local or www docs
269 foam_option(FOAM_USE_LOCAL_DOXYGEN_DOCS "Use local API docs"
270 "Use the local API documentation instead of http://freefoam.sf.net/doc/API"
272 mark_as_advanced(FOAM_USE_LOCAL_DOXYGEN_DOCS)
275 # ask user whether she wants to build the man pages
276 foam_option(FOAM_ENABLE_MANPAGE_HELP "Build manpage help"
277 "Build the manpages (requires asciidoc)" OFF)
278 # ask user whether she wants to build the xhtml man pages
279 foam_option(FOAM_ENABLE_XHTML_HELP "Build xhtml help"
280 "Build the xhtml help pages (requires asciidoc)" OFF)
281 # as user whether she wanst to build the xhtml guides
282 foam_option(FOAM_ENABLE_XHTML_GUIDES "Build the xhtml guides"
283 "Build the xhtml guides (requires asciidoc, dot, inkscape and asymptote)"
285 # as user whether she wanst to build the xhtml guides
286 foam_option(FOAM_ENABLE_PDF_GUIDES "Build the PDF guides"
287 "Build the PDF guides (requires asciidoc, dot, inkscape and asymptote)" OFF)
288 if(FOAM_ENABLE_PDF_GUIDES)
289 foam_option(FOAM_USE_FOP "Use FOP instead of dblatex"
290 "Use FOP to build the PDF guides instead of dblatex" OFF)
291 mark_as_advanced(FOAM_USE_FOP)
293 set(FOAM_USE_FOP FALSE)
296 if(FOAM_ENABLE_DOXYGEN_DOCS OR FOAM_ENABLE_XHTML_GUIDES)
297 foam_option(FOAM_DOCS_FOR_SF "Docs for SourceForge"
298 "Build the docs for deployment on SourceForge" OFF)
299 mark_as_advanced(FOAM_DOCS_FOR_SF)
300 # make sure only ON and OFF are used
302 set(FOAM_DOCS_FOR_SF ON)
304 set(FOAM_DOCS_FOR_SF OFF)
309 # ask user whether whe wants full tutorial tests
310 foam_option(FOAM_ENABLE_FULL_TUTORIAL_TESTS
311 "Full tutorial tests"
312 "Run the complete tutorial tests (not just a single time step)" OFF)
313 mark_as_advanced(FOAM_ENABLE_FULL_TUTORIAL_TESTS)
316 if(FOAM_ENABLE_XHTML_GUIDES)
317 set(FOAM_ENABLE_XHTML_GUIDES ON)
318 foam_option(FOAM_ENABLE_MATHJAX "Use MathJax in XHTML guides"
319 "Use MathJax for formulas in the XHTML version of the guides" ON)
320 if(FOAM_ENABLE_MATHJAX)
321 foam_option(FOAM_MATHJAX_USE_CDN
322 "Use the MathJax CDN"
323 "Use public MathJax installation at http://cdn.mathjax.org" ON)
324 mark_as_advanced(FOAM_MATHJAX_USE_CDN)
325 if(FOAM_MATHJAX_USE_CDN)
326 set(FOAM_MATHJAX_URL "http://cdn.mathjax.org/mathjax/latest")
328 set(FOAM_MATHJAX_URL "MathJAX-NOTFOUND" CACHE PATH
329 "Path or URL to the MathJax directory containing the MathJax.js file")
330 mark_as_advanced(FOAM_MATHJAX_URL)
331 if(NOT FOAM_MATHJAX_URL)
332 message(SEND_ERROR "FOAM_MATHJAX_URL must be set to the directory or "
333 "URL containing MathJax.js")
338 set(FOAM_ENABLE_XHTML_GUIDES OFF)
339 set(FOAM_ENABLE_MATHJAX FALSE)
342 # assemble the list of enabled manpage formats
343 set(FOAM_MANPAGE_FORMATS)
344 if(FOAM_ENABLE_MANPAGE_HELP)
345 list(APPEND FOAM_MANPAGE_FORMATS manpage)
347 if(FOAM_ENABLE_XHTML_HELP)
348 list(APPEND FOAM_MANPAGE_FORMATS xhtml)
351 # assemble the list of enabled guides formats
352 set(FOAM_GUIDES_FORMATS)
353 if(FOAM_ENABLE_XHTML_GUIDES)
354 list(APPEND FOAM_GUIDES_FORMATS xhtml)
356 if(FOAM_ENABLE_PDF_GUIDES)
357 list(APPEND FOAM_GUIDES_FORMATS pdf)
360 if(FOAM_MANPAGE_FORMATS OR FOAM_GUIDES_FORMATS)
362 find_program(ASCIIDOC_EXECUTABLE NAMES asciidoc.py asciidoc)
363 get_filename_component(asciidoc_path "${ASCIIDOC_EXECUTABLE}" PATH)
364 find_program(A2X_EXECUTABLE NAMES a2x.py a2x HINTS "${asciidoc_path}")
365 if(NOT ASCIIDOC_EXECUTABLE OR NOT A2X_EXECUTABLE)
367 "AsciiDoc is required to create man and html help and the guides")
369 mark_as_advanced(ASCIIDOC_EXECUTABLE A2X_EXECUTABLE)
370 # read CONF_DIR from A2X_EXECUTABLE and copy style files over
372 file(READ "${A2X_EXECUTABLE}" _asciidoc_text)
373 if(_asciidoc_text MATCHES "[ \t]*CONF_DIR[ \t]*=[ \t]*r?['\"]([^'\"]+)")
374 set(A2X_CONF_DIR "${CMAKE_MATCH_1}")
375 if(IS_DIRECTORY "${A2X_CONF_DIR}")
376 configure_file("${A2X_CONF_DIR}/docbook-xsl/common.xsl"
377 "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-common.xsl"
379 configure_file("${A2X_CONF_DIR}/docbook-xsl/chunked.xsl"
380 "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-chunked.xsl"
382 configure_file("${A2X_CONF_DIR}/docbook-xsl/xhtml.xsl"
383 "${CMAKE_BINARY_DIR}/data/asciidoc/docbook-xsl/orig-xhtml.xsl"
385 configure_file("${A2X_CONF_DIR}/dblatex/asciidoc-dblatex.sty"
386 "${CMAKE_BINARY_DIR}/data/asciidoc/dblatex/orig-asciidoc-dblatex.sty"
388 configure_file("${A2X_CONF_DIR}/dblatex/asciidoc-dblatex.xsl"
389 "${CMAKE_BINARY_DIR}/data/asciidoc/dblatex/orig-asciidoc-dblatex.xsl"
392 message(SEND_ERROR "The Asciidoc configuration directory "
393 "${A2X_CONF_DIR} does not exist")
396 message(SEND_ERROR "Failed to read CONF_DIR from ${A2X_EXECUTABLE}")
399 set(FOAM_NEED_PNGMATH FALSE)
400 if((FOAM_ENABLE_XHTML_GUIDES AND NOT FOAM_ENABLE_MATHJAX) OR
401 (FOAM_ENABLE_PDF_GUIES AND FOAM_USE_FOP))
402 set(FOAM_NEED_PNGMATH TRUE)
403 foreach(prog latex dvipng)
404 string(TOUPPER ${prog} uprog)
405 find_program(${uprog}_EXECUTABLE ${prog})
406 mark_as_advanced(${uprog}_EXECUTABLE)
407 if(NOT ${uprog}_EXECUTABLE)
409 "${prog} is required when FOAM_ENABLE_MATHJAX is disabled "
410 "or FOAM_USE_FOP is enabled")
415 if(FOAM_GUIDES_FORMATS)
417 find_program(ASY_EXECUTABLE asy)
418 if(NOT ASY_EXECUTABLE)
419 message(SEND_ERROR "Asymptote is required to create the guides")
421 mark_as_advanced(ASY_EXECUTABLE)
424 # set up the RPATH for installation
425 set(CMAKE_INSTALL_RPATH ${FOAM_INSTALL_LIBRARY_PATH})
426 set(CMAKE_INSTALL_NAME_DIR ${FOAM_FRAMEWORK_INSTALL_NAME_DIR})
428 # we want executables and libraries in uniform places
429 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
430 "${CMAKE_BINARY_DIR}/libexec/${PROJECT_NAME}/${FOAM_VERSION_FULL}")
431 set(FOAM_LIBRARY_OUTPUT_DIRECTORY
432 "${CMAKE_BINARY_DIR}/lib/${PROJECT_NAME}-${FOAM_VERSION_FULL}")
433 set(FOAM_FRAMEWORK_OUTPUT_DIRECTORY
434 "${CMAKE_BINARY_DIR}/Library/Frameworks")
435 if(FOAM_BUILD_FRAMEWORKS)
436 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_FRAMEWORK_OUTPUT_DIRECTORY}")
438 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
440 set(FOAM_ARCHIVE_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
442 # find parallel libraries
445 set(_FOAM_USE_MPI ON)
447 set(_FOAM_USE_MPI OFF)
449 foam_option(FOAM_USE_MPI "Use MPI"
450 "Build ${CMAKE_PROJECT} against MPI parallel libraries" ${_FOAM_USE_MPI})
451 mark_as_advanced(FOAM_USE_MPI)
452 if(FOAM_USE_MPI AND NOT MPI_FOUND)
454 "FOAM_ENABLE_MPI is true, but MPI cannot be found.\n"
455 "If you have MPI installed on your system, edit the variables\n"
456 "MPI_INCLUDE_DIR and MPI_LIBRARY in the cache, else disable the\n"
457 "setting FOAM_USE_MPI."
462 find_package(Readline)
464 # substitution for build-tree and install-tree as used by
465 # foam_configure_files.
466 set(FOAM_CONFIGURE_FILES_VARIABLES
468 "${CMAKE_BINARY_DIR}/data"
469 "${FOAM_INSTALL_DATA_PATH}"
471 "${CMAKE_BINARY_DIR}/doc"
472 "${FOAM_INSTALL_DOC_PATH}"
474 "${CMAKE_BINARY_DIR}/bin"
475 "${FOAM_INSTALL_BIN_PATH}"
477 "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}"
478 "${FOAM_INSTALL_LIBRARY_PATH}"
480 "${CMAKE_BINARY_DIR}/libexec/FreeFOAM/${FOAM_VERSION_FULL}"
481 "${FOAM_INSTALL_LIBEXEC_PATH}"
483 "${CMAKE_BINARY_DIR}/Library/Frameworks"
484 "${FOAM_INSTALL_FRAMEWORK_PATH}"
486 "${CMAKE_BINARY_DIR}/include"
487 "${FOAM_INSTALL_HEADER_PATH}"
489 "${CMAKE_BINARY_DIR}/etc"
490 "${FOAM_INSTALL_CONFIG_PATH}"
492 "${CMAKE_BINARY_DIR}/CMake"
493 "${FOAM_INSTALL_CMAKE_PATH}"
495 "${CMAKE_BINARY_DIR}/data/python"
496 "${FOAM_INSTALL_PYTHON_PATH}"
502 list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
504 "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}"
505 "${FOAM_INSTALL_LIBRARY_PATH}")
507 list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
509 "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}/plugins"
510 "${FOAM_INSTALL_PLUGIN_PATH}")
512 if(FOAM_USE_LOCAL_DOXYGEN_DOCS)
513 list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
514 FOAM_DOC_DIR "${CMAKE_BINARY_DIR}/doc" "${FOAM_INSTALL_DOC_PATH}")
516 set(_sf_doc "http://freefoam.sf.net/doc/${FOAM_VERSION_FULL}")
517 list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
518 FOAM_DOC_DIR "${_sf_doc}" "${_sf_doc}")
521 # thirdparty libraries
522 foam_thirdparty_option(Metis
523 "Required by the metis decomposition method"
525 if(FOAM_ENABLE_METIS)
526 if(FOAM_ENABLE_METIS AND METIS_REQUIRES_MPI AND NOT FOAM_USE_MPI)
528 "Your metis implementation requires FOAM_USE_MPI to be enabled."
529 "If you don't have/want MPI, enable FOAM_BUILD_PRIVATE_METIS instead.")
532 foam_thirdparty_option(ParMetis
533 "Required by the parmetis decomposition method"
534 ParMetis TRUE ${FOAM_USE_MPI}
535 PARMETIS_metis_LIBRARY PARMETIS_parmetis_LIBRARY)
536 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_USE_MPI)
538 "ParMetis requires FOAM_USE_MPI to be enabled.")
540 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_ENABLE_METIS)
542 "ParMetis requires FOAM_ENABLE_METIS to be enabled.")
544 set(SCOTCH_USE_ERREXIT TRUE)
545 foam_thirdparty_option(SCOTCH "" SCOTCH FALSE ON SCOTCH_scotch_LIBRARY
546 SCOTCH_scotcherr_LIBRARY SCOTCH_scotcherrexit_LIBRARY)
547 # do not enable mgridgen by default (licensing issues)
548 if(NOT FOAM_DOUBLE_PRECISION)
549 set(MGRIDGEN_USE_REAL ON)
551 foam_thirdparty_option(MGRIDGEN
552 "Required by the MGridGen GAMG agglomerator. LICENSE UNCLEAR"
554 # do not enable libccmio by default (licensing issues)
555 foam_thirdparty_option(ccmio
556 "Required by ccm26ToFoam. REQUIRES PERMISSION BY CDADAPCO!"
558 foam_thirdparty_option(zlib "" ZLIB FALSE ON)
560 # figure out default Pstream library
562 set(_FOAM_DEFAULT_PSTREAM mpi)
564 set(_FOAM_DEFAULT_PSTREAM dummy)
566 set(FOAM_DEFAULT_PSTREAM ${_FOAM_DEFAULT_PSTREAM} CACHE STRING
567 "Default Pstream library implementation [dummy|mpi]")
568 mark_as_advanced(FOAM_DEFAULT_PSTREAM)
570 # find m4 macro processor
571 find_program(M4_EXECUTABLE m4 DOC "Path to the m4 macro processor")
572 mark_as_advanced(M4_EXECUTABLE)
573 if(NOT M4_EXECUTABLE)
574 message("WARNING: Failed to find M4 macro processor.\n"
575 "Some of the tutorials will fail if it can't be found.")
576 set(M4_EXECUTABLE m4)
579 # on APPLE use cp -R -P -p, otherwise use cp -a
581 set(FOAM_CP_A_FLAGS "-R -P -p")
583 set(FOAM_CP_A_FLAGS "-a")
586 # execinfo.h and cxxabi.h only work using GNU gcc and Debug config
587 # assume that if we have execinfo.h, cxxabi.h is also present.
588 if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL Debug)
589 find_package(Execinfo)
592 # create the FOAMConfig.h file
593 configure_file(${CMAKE_SOURCE_DIR}/FOAMConfig.h.in
594 ${CMAKE_BINARY_DIR}/include/FOAMConfig.h @ONLY)
596 # on Solaris/SunOS fix up the shebangs
597 if(CMAKE_SYSTEM_NAME STREQUAL SunOS AND
598 NOT EXISTS ${CMAKE_BINARY_DIR}/replaceAllShellSun.run)
599 message(STATUS "Fixing shell-interpreter for SunOS and Solaris")
601 COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun bin
602 COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun data
603 COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun tutorials
604 COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun doc
605 COMMAND ${CMAKE_COMMAND} -E touch${CMAKE_BINARY_DIR}/replaceAllShellSun.run
606 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
611 set(FOAM_COMPILE_DEFINITIONS
617 list(APPEND FOAM_COMPILE_DEFINITIONS -Ddarwin)
619 add_definitions(${FOAM_COMPILE_DEFINITIONS})
621 # set up include-directories for own headers
622 include_directories(${CMAKE_BINARY_DIR}/include)
624 # set up version info checks and updating of global.C
625 set(FOAM_HAVE_GIT FALSE)
626 if(EXISTS "${CMAKE_SOURCE_DIR}/.git/config")
629 set(FOAM_HAVE_GIT TRUE)
630 option(FOAM_VERSION_CHECK_WARN_ONLY
631 "Only warn if the version numbers are wrong" FALSE)
632 mark_as_advanced(FOAM_VERSION_CHECK_WARN_ONLY)
633 configure_file(CMake/ConfigureGlobalC.cmake.in
634 "${CMAKE_BINARY_DIR}/CMake/ConfigureGlobalC.cmake" @ONLY)
635 add_custom_target(version_check ALL
636 COMMAND "${PYTHON_EXECUTABLE}"
637 "${CMAKE_BINARY_DIR}/data/utilities/checkVersionInfo.py"
638 ${_CHECK_VERSION_INFO_ARGS}
639 DEPENDS "${CMAKE_BINARY_DIR}/data/utilities/checkVersionInfo.py"
640 COMMENT "Checking version information"
644 "Not performing version checks because GIT_EXECUTABLE is missing")
648 "Not performing version checks because not in a Git checkout")
651 if(NOT FOAM_HAVE_GIT)
652 if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.build.cmake)
653 message(SEND_ERROR "If not in a Git checkout, .build.cmake is required")
655 include(${CMAKE_SOURCE_DIR}/.build.cmake)
658 # helper variables to force linking on some systems
659 set(_TURBULENCE_MODELS ${PROJECT_SOURCE_DIR}/src/turbulenceModels)
660 set(FORCE_LINK_COMPRESSIBLE_RAS_MODELS
661 ${_TURBULENCE_MODELS}/compressible/RAS/RASModel/forceLink.C)
662 set(FORCE_LINK_COMPRESSIBLE_LES_MODELS
663 ${_TURBULENCE_MODELS}/compressible/LES/LESModel/forceLink.C)
664 set(FORCE_LINK_INCOMPRESSIBLE_RAS_MODELS
665 ${_TURBULENCE_MODELS}/incompressible/RAS/RASModel/forceLink.C)
666 set(FORCE_LINK_INCOMPRESSIBLE_LES_MODELS
667 ${_TURBULENCE_MODELS}/incompressible/LES/LESModel/forceLink.C)
668 set(FORCE_LINK_GENERIC_PATCH_FIELDS
669 ${PROJECT_SOURCE_DIR}/src/genericPatchFields/include/forceLink.C)
670 set(FORCE_LINK_RADIATION
671 ${PROJECT_SOURCE_DIR}/src/thermophysicalModels/radiation/radiationModel/radiationModel/forceLink.C)
672 set(FORCE_LINK_COAL_COMBUSTION
673 ${PROJECT_SOURCE_DIR}/src/lagrangian/coalCombustion/include/forceLink.C)
674 set(FORCE_LINK_INTERFACE_PROPERTIES
675 ${PROJECT_SOURCE_DIR}/src/transportModels/interfaceProperties/forceLink.C)
677 # descend into the sources...
678 add_subdirectory(bin)
679 add_subdirectory(etc)
680 add_subdirectory(data)
681 add_subdirectory(src)
682 add_subdirectory(applications)
683 add_subdirectory(tutorials)
684 # doc *must* be last, else manpage and Doxygen generation fails
685 add_subdirectory(doc)
687 # export the library dependencies to the build tree
688 foam_export_targets_to_build_tree(${PROJECT_NAME}LibraryDepends)
689 export(PACKAGE ${PROJECT_NAME})
691 # write the doc index file and install it
692 foam_write_doc_index()
694 ${CMAKE_BINARY_DIR}/InstallFiles/data/DoxyDocIndex
695 DESTINATION ${FOAM_INSTALL_DATA_PATH}
699 # create ${PROJECT_NAME}Config.cmake ${PROJECT_NAME}Use.cmake,
700 # ${PROJECT_NAME}Utilities.cmake and ${PROJECT_NAME}WmakeCompatibility.cmake
701 # for the build and install tree
702 foam_configure_files(ConfigInstallFiles
703 "CMake/FOAMConfig.cmake.in==CMake/${PROJECT_NAME}Config.cmake"
704 "CMake/FOAMUse.cmake.in==CMake/${PROJECT_NAME}Use.cmake"
705 "CMake/FOAMWmakeCompatibility.cmake.in==CMake/${PROJECT_NAME}WmakeCompatibility.cmake"
707 "CMake/FOAMUtilities.cmake==CMake/${PROJECT_NAME}Utilities.cmake"
710 # install the CMake config files
712 ${ConfigInstallFiles}
713 DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
717 # install the ${PROJECT_NAME}LibraryDepends.cmake file
718 install(EXPORT ${PROJECT_NAME}LibraryDepends
719 DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
726 "${CMAKE_SOURCE_DIR}/CMake/Modules/cmake_uninstall.cmake.in"
727 "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
731 add_custom_target(uninstall
732 "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
735 # print cool feature summary
736 foam_print_feature_summary()
738 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file