ENH: Added Python package for running FreeFOAM
[freefoam.git] / CMakeLists.txt
blob23b2f017f41062a0bc06e917e800e1e203880134
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)
57 # determine computer system
58 include(${CMAKE_SOURCE_DIR}/CMake/FOAMDetermineArch.cmake)
60 # select precision
61 foam_option(FOAM_DOUBLE_PRECISION "Double precision"
62   "Compile ${PROJECT_NAME} with double precision floating point arithmetics." ON)
63 if(FOAM_DOUBLE_PRECISION)
64   set(FOAM_PRECISION DP)
65 else()
66   set(FOAM_PRECISION SP)
67 endif()
69 # select whether we want to build framewors on Mac OS X
70 if(APPLE)
71   foam_option(FOAM_BUILD_FRAMEWORKS "Build frameworks"
72     "Build frameworks on Mac OS X" OFF)
73 else()
74   set(FOAM_BUILD_FRAMEWORKS OFF)
75 endif()
77 # find python interpreter
78 find_package(PythonInterp REQUIRED)
80 # make sure we got Python version 2.6 or newer
81 foam_dependent_variables(PYTHON_EXECUTABLE PYTHON_VERSION)
82 if(NOT PYTHON_VERSION)
83   execute_process(
84     COMMAND ${PYTHON_EXECUTABLE} -c
85     "import sys; sys.stdout.write('%s.%s.%s\\n'%sys.version_info[0:3])"
86     RESULT_VARIABLE _py_version_result
87     OUTPUT_VARIABLE _py_version_output
88     ERROR_VARIABLE _py_version_output
89     OUTPUT_STRIP_TRAILING_WHITESPACE
90     )
91   if(NOT _py_version_result)
92     string(REGEX MATCH "([0-9]+\\.)+[0-9]+" PYTHON_VERSION "${_py_version_output}")
93     message(STATUS "Python version ${PYTHON_VERSION} found")
94     if(${PYTHON_VERSION} VERSION_LESS 2.4.0)
95       message(SEND_ERROR "Python version 2.4 or newer required")
96     endif()
97   else()
98     set(PYTHON_VERSION PYTHON_VERSION-NOTFOUND)
99     message(SEND_ERROR "Failed to determine the python version: ${_py_version_output}")
100   endif()
101   set(PYTHON_VERSION ${PYTHON_VERSION} CACHE INTERNAL "The Python version")
102 endif()
103 string(REGEX REPLACE "\\.[0-9]+$" "" PYTHON_SHORT_VERSION ${PYTHON_VERSION})
105 # ask user whether she wants to build ParaView plugins
106 foam_option(FOAM_BUILD_PARAVIEW_PLUGINS "Build ParaView plugins"
107   "Build the ParaView plugins. Requires a ParaView build tree." OFF)
108 if(FOAM_BUILD_PARAVIEW_PLUGINS)
109   # find ParaView, which also find the VTK which has been used to build ParaView
110   find_package(ParaView)
111   if(NOT ParaView_FOUND)
112     message(SEND_ERROR
113       "Failed to find the ParaView build tree. Specify ParaView_DIR or\n"
114       "disable FOAM_BUILD_PARAVIEW_PLUGINS")
115   endif()
116   # find the installed ParaView executable
117   find_program(
118     FOAM_PARAVIEW3_APP NAMES paraview paraview.app ParaView.app
119     "ParaView 3.6.0.app" "ParaView 3.7.0.app" "ParaView 3.8.0.app"
120     HINTS ${ParaView_DIR}/bin
121     DOC "Path to the ParaView 3 executable (or application bundle on Mac OS X)"
122     )
123   if(NOT FOAM_PARAVIEW3_APP)
124     message(SEND_ERROR
125       "Failed to find the ParaView 3 executable or application bundle")
126   endif()
127 endif()
128 mark_as_advanced(FOAM_PARAVIEW3_APP)
130 # we want shared libraries
131 set(BUILD_SHARED_LIBS SHARED)
133 # installation directories
134 foam_installation_path(FOAM_INSTALL_BIN_PATH bin "Executables"
135   "Executables installation path")
136 if(APPLE AND FOAM_BUILD_FRAMEWORKS)
137   foam_installation_path(FOAM_INSTALL_FRAMEWORK_PATH /Library/Frameworks
138     "Frameworks" "Framework installation path")
139 endif()
140 foam_installation_path(FOAM_INSTALL_LIBRARY_PATH
141   lib/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL}
142   "Libraries" "Library installation path")
143 foam_installation_path(FOAM_INSTALL_LIBEXEC_PATH
144   libexec/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Private executables"
145   "Installation path for executables not on PATH.")
146 foam_installation_path(FOAM_INSTALL_HEADER_PATH
147   include/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL}
148   "Headers" "Header installation path (not for frameworks)")
149 foam_installation_path(FOAM_INSTALL_CONFIG_PATH
150   etc/${CMAKE_PROJECT_NAME}/${FOAM_VERSION_FULL} "Config files"
151   "Configuration files installation path")
152 foam_installation_path(FOAM_INSTALL_DATA_PATH
153   share/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Data files"
154   "Data files installation path")
155 foam_installation_path(FOAM_INSTALL_DOC_PATH
156   share/doc/${CMAKE_PROJECT_NAME}-${FOAM_VERSION_FULL} "Documentation"
157   "Documentation files installation path")
158 foam_installation_path(FOAM_INSTALL_MAN_PATH share/man "Man pages"
159   "Man-pages installation path")
160 foam_installation_path(FOAM_INSTALL_TUTORIALS_PATH "${FOAM_INSTALL_DOC_PATH}"
161   "Tutorials" "Tutorials installation path")
162 foam_installation_path(FOAM_INSTALL_CMAKE_PATH "${FOAM_INSTALL_DATA_PATH}/CMake"
163   "CMake files" "CMake configuration files installation path")
164 if(FOAM_BUILD_PARAVIEW_PLUGINS)
165   foam_installation_path(FOAM_INSTALL_PVFOAMREADER_PATH
166     "${FOAM_INSTALL_LIBRARY_PATH}/plugins/PVFoamReader"
167     "ParaView2 plugin" "ParaView2 OpenFOAM-reader plugin installation path")
168   foam_installation_path(FOAM_INSTALL_PV3FOAMREADER_PATH
169     "${FOAM_INSTALL_LIBRARY_PATH}/plugins/PV3FoamReader"
170     "ParaView3 plubin" "ParaView3 OpenFOAM-reader plugin installation path")
171 endif()
172 foam_installation_path(FOAM_INSTALL_USERDFOAM_PATH
173   "${FOAM_INSTALL_LIBRARY_PATH}/plugins/ensightReader"
174   "Ensight plugin" "Ensight OpenFOAM-reader plugin installation path")
175 foam_installation_path(FOAM_INSTALL_PYTHON_PATH
176   "lib/python${PYTHON_SHORT_VERSION}/site-packages"
177   "Python modules" "Python modules installation base path")
179 set(FOAM_INSTALL_RUNTIME_PATH "${FOAM_INSTALL_LIBEXEC_PATH}")
181 # determine the INSTALL_NAME_DIR of potential frameworks
182 if(APPLE AND FOAM_BUILD_FRAMEWORKS)
183   set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_FRAMEWORK_PATH}")
184 else()
185   set(FOAM_FRAMEWORK_INSTALL_NAME_DIR "${FOAM_INSTALL_LIBRARY_PATH}")
186 endif()
188 # select html documentation browser (try a few well known ones for default)
189 # have to loop, because find_program(HTML_DOC_BROWSER NAMES ...) garbles things up
190 foreach(browser open gnome-open kde-open x-www-browser www-browser
191     firefox epiphany konqueror w3m lynx launch open)
192   find_program(HTML_DOC_BROWSER ${browser}
193     DOC "Program to open an HTML file")
194   if(HTML_DOC_BROWSER)
195     break()
196   endif()
197 endforeach()
198 if(NOT HTML_DOC_BROWSER)
199   message(STATUS
200     "Failed to find a program to open HTML pages with (a.k.a a browser).\n"
201     "Point HTML_DOC_BROWSER to a suitable program.")
202   set(HTML_DOC_BROWSER "ECHO" CACHE STRING
203     "Command to open an HTML file (ECHO will print it to STDOUT)" FORCE)
204 endif()
205 set(FOAM_HTML_DOC_BROWSER_COMMAND
206   "\${HTML_DOC_BROWSER} %f" CACHE STRING "Command to open an HTML file")
207 string(CONFIGURE "${FOAM_HTML_DOC_BROWSER_COMMAND}"
208   FOAM_HTML_DOC_BROWSER_COMMAND ESCAPE_QUOTES)
209 mark_as_advanced(HTML_DOC_BROWSER FOAM_HTML_DOC_BROWSER_COMMAND)
211 # Executable-prefix
212 string(TOLOWER "${PROJECT_NAME}-" _FOAM_DEFAULT_EXE_PREFIX)
213 set(FOAM_EXE_PREFIX "${_FOAM_DEFAULT_EXE_PREFIX}"
214   CACHE STRING "Prefix for application output-names")
215 mark_as_advanced(FOAM_EXE_PREFIX)
216 string(TOUPPER "${FOAM_EXE_PREFIX}" FOAM_UPPER_EXE_PREFIX)
218 # ask user whether she wants to build Doxygen docs
219 foam_option(FOAM_ENABLE_DOXYGEN_DOCS "Doxygen API documentation"
220   "Build the Doxygen API documentation" OFF)
221 # if user wants doxygen docs, find Doxygen and set up some options
222 if(FOAM_ENABLE_DOXYGEN_DOCS)
223   find_package(Doxygen REQUIRED)
224   foam_option(FOAM_DOXYDOCS_FOR_SF "Doxygen for SourceForge"
225     "Build the Doxygen docs for deployment on SourceForge" OFF)
226   # ask user whether she prefers local or www docs
227   foam_option(FOAM_USE_LOCAL_DOXYGEN_DOCS "Use local API docs"
228     "Use the local Doxygen documentation instead of the one on http://freefoam.sf.net/doc/Doxygen/html" OFF)
229 endif()
231 # ask user whether she wants to build the man pages
232 foam_option(FOAM_ENABLE_MANPAGE_HELP "Build manpage help"
233   "Build the manpages (requires asciidoc)" OFF)
234 # ask user whether she wants to build the xhtml man pages
235 foam_option(FOAM_ENABLE_XHTML_HELP "Build xhtml help"
236   "Build the xhtml help pages (requires asciidoc)" OFF)
238 # assemble the list of enabled manpage formats
239 set(FOAM_MANPAGE_FORMATS)
240 if(FOAM_ENABLE_MANPAGE_HELP)
241   list(APPEND FOAM_MANPAGE_FORMATS manpage)
242 endif()
243 if(FOAM_ENABLE_XHTML_HELP)
244   list(APPEND FOAM_MANPAGE_FORMATS xhtml)
245 endif()
247 # set up the RPATH for installation
248 set(CMAKE_INSTALL_RPATH ${FOAM_INSTALL_LIBRARY_PATH})
249 set(CMAKE_INSTALL_NAME_DIR ${FOAM_FRAMEWORK_INSTALL_NAME_DIR})
251 # we want executables and libraries in uniform places
252 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
253   "${CMAKE_BINARY_DIR}/libexec/${PROJECT_NAME}/${FOAM_VERSION_FULL}")
254 set(FOAM_LIBRARY_OUTPUT_DIRECTORY
255   "${CMAKE_BINARY_DIR}/lib/${PROJECT_NAME}-${FOAM_VERSION_FULL}")
256 set(FOAM_FRAMEWORK_OUTPUT_DIRECTORY
257   "${CMAKE_BINARY_DIR}/Library/Frameworks")
258 if(FOAM_BUILD_FRAMEWORKS)
259   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_FRAMEWORK_OUTPUT_DIRECTORY}")
260 else()
261   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
262 endif()
263 set(FOAM_ARCHIVE_OUTPUT_DIRECTORY "${FOAM_LIBRARY_OUTPUT_DIRECTORY}")
265 # find parallel libraries
266 set(_FOAM_PAR_ERROR
267   "FOAM_ENABLE_@PKG@ is true, but @PKG@ cannot be found.\n"
268   "If you have @PKG@ installed on your system, edit the variables\n"
269   "@PKG@_INCLUDE_DIR and @PKG@_LIBRARY in the cache, else disable the\n"
270   "setting FOAM_USE_@PKG@."
271   )
272 find_package(MPI)
273 if(MPI_FOUND)
274   set(_FOAM_USE_MPI ON)
275 else()
276   set(_FOAM_USE_MPI OFF)
277 endif()
278 foam_option(FOAM_USE_MPI "Use MPI"
279   "Build ${CMAKE_PROJECT} against MPI parallel libraries" ${_FOAM_USE_MPI})
280 if(FOAM_USE_MPI AND NOT MPI_FOUND)
281   string(REPLACE "@PKG@" "MPI" _FOAM_MPI_ERROR "${_FOAM_PAR_ERROR}")
282   message(SEND_ERROR "${_FOAM_MPI_ERROR}")
283 endif()
284 if(CMAKE_SYSTEM_NAME STREQUAL Linux)
285   find_package(GAMMA)
286   if(GAMMA_FOUND)
287     set(_FOAM_USE_GAMMA ON)
288   else()
289     set(_FOAM_USE_GAMMA OFF)
290   endif()
291   foam_option(FOAM_USE_GAMMA "Use GAMMA"
292     "Build ${CMAKE_PROJECT} against GAMMA parallel libraries"
293     ${_FOAM_USE_GAMMA})
294   if(FOAM_USE_GAMMA AND NOT GAMMA_FOUND)
295     string(REPLACE "@PKG@" "GAMMA" _FOAM_GAMMA_ERROR "${_FOAM_PAR_ERROR}")
296     message(SEND_ERROR "${_FOAM_GAMMA_ERROR}")
297   endif()
298 endif()
299 if(MPI_FOUND OR GAMMA_FOUND)
300   set(FOAM_USE_PARALLEL TRUE)
301 endif()
303 # find readline
304 find_package(Readline)
306 # substitution for build-tree and install-tree as used by
307 # foam_configure_files.
308 set(FOAM_CONFIGURE_FILES_VARIABLES
309   FOAM_DATA_DIR
310     "${CMAKE_BINARY_DIR}/data"
311     "${FOAM_INSTALL_DATA_PATH}"
312   FOAM_LOCAL_DOC_DIR
313     "${CMAKE_BINARY_DIR}/doc"
314     "${FOAM_INSTALL_DOC_PATH}"
315   FOAM_BIN_DIR
316     "${CMAKE_BINARY_DIR}/bin"
317     "${FOAM_INSTALL_BIN_PATH}"
318   FOAM_LIB_DIR
319     "${CMAKE_BINARY_DIR}/lib/FreeFOAM-${FOAM_VERSION_FULL}"
320     "${FOAM_INSTALL_LIBRARY_PATH}"
321   FOAM_LIBEXEC_DIR
322     "${CMAKE_BINARY_DIR}/libexec/FreeFOAM/${FOAM_VERSION_FULL}"
323     "${FOAM_INSTALL_LIBEXEC_PATH}"
324   FOAM_FRAMEWORK_DIR
325     "${CMAKE_BINARY_DIR}/Library/Frameworks"
326     "${FOAM_INSTALL_FRAMEWORK_PATH}"
327   FOAM_PV3FOAMREADER_DIR
328     "${FOAM_LIB_DIR}/plugins/PV3FoamReader"
329     "${FOAM_INSTALL_PV3FOAMREADER_PATH}"
330   FOAM_INCLUDE_DIR
331     "${CMAKE_BINARY_DIR}/include"
332     "${FOAM_INSTALL_HEADER_PATH}"
333   FOAM_CONFIG_DIR
334     "${CMAKE_BINARY_DIR}/etc"
335     "${FOAM_INSTALL_CONFIG_PATH}"
336   FOAM_CMAKECONFIG_DIR
337     "${CMAKE_BINARY_DIR}/CMake"
338     "${FOAM_INSTALL_CMAKE_PATH}"
339   FOAM_IS_INSTALLED
340     "FALSE"
341     "TRUE"
342   FOAM_FIX_INCLUDES
343     "${CMAKE_BINARY_DIR}/data/utilities/doxyFixIncludes $1 |"
344     "cat $1 |"
345   FOAM_FIX_HEADER_NAME
346     "| ${CMAKE_BINARY_DIR}/data/utilities/doxyFixHeaderName $1"
347     ""
348   )
349 if(FOAM_USE_LOCAL_DOXYGEN_DOCS)
350   list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
351     FOAM_DOC_DIR "${CMAKE_BINARY_DIR}/doc" "${FOAM_INSTALL_DOC_PATH}")
352 else()
353   set(_sf_doc "http://freefoam.sf.net/doc/${FOAM_VERSION_FULL}")
354   list(APPEND FOAM_CONFIGURE_FILES_VARIABLES
355     FOAM_DOC_DIR "${_sf_doc}" "${_sf_doc}")
356 endif()
358 # thirdparty libraries
359 foam_thirdparty_option(Metis
360   "Required by the metis decomposition method"
361   Metis TRUE ON)
362 if(FOAM_ENABLE_METIS)
363   if(FOAM_ENABLE_METIS AND METIS_REQUIRES_MPI AND NOT FOAM_USE_MPI)
364     message(SEND_ERROR
365       "Your metis implementation requires FOAM_USE_MPI to be enabled."
366       "If you don't have/want MPI, enable FOAM_BUILD_PRIVATE_METIS instead.")
367   endif()
368 endif()
369 foam_thirdparty_option(ParMetis
370   "Required by the parmetis decomposition method"
371   ParMetis TRUE ${FOAM_USE_MPI}
372   PARMETIS_metis_LIBRARY PARMETIS_parmetis_LIBRARY)
373 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_USE_MPI)
374   message(SEND_ERROR
375     "ParMetis requires FOAM_USE_MPI to be enabled.")
376 endif()
377 if(FOAM_ENABLE_PARMETIS AND NOT FOAM_ENABLE_METIS)
378   message(SEND_ERROR
379     "ParMetis requires FOAM_ENABLE_METIS to be enabled.")
380 endif()
381 set(SCOTCH_USE_ERREXIT TRUE)
382 foam_thirdparty_option(SCOTCH "" SCOTCH FALSE ON SCOTCH_scotch_LIBRARY
383   SCOTCH_scotcherr_LIBRARY SCOTCH_scotcherrexit_LIBRARY)
384 # do not enable mgridgen by default (licensing issues)
385 if(NOT FOAM_DOUBLE_PRECISION)
386   set(MGRIDGEN_USE_REAL ON)
387 endif()
388 foam_thirdparty_option(MGRIDGEN
389   "Required by the MGridGen GAMG agglomerator. LICENSE UNCLEAR"
390   MGRIDGEN TRUE OFF)
391 # do not enable libccmio by default (licensing issues)
392 foam_thirdparty_option(ccmio
393   "Required by ccm26ToFoam. REQUIRES PERMISSION BY CDADAPCO!"
394   Ccmio TRUE OFF)
395 foam_thirdparty_option(zlib "" ZLIB FALSE ON)
397 if(FOAM_BUILD_PRIVATE_METIS OR FOAM_BUILD_PRIVATE_MGRIDGEN)
398   find_package(Threads REQUIRED)
399 endif()
400 if(FOAM_BUILD_PRIVATE_SCOTCH)
401   find_package(BISON REQUIRED)
402   find_package(FLEX REQUIRED)
403   find_package(Threads)
404 endif()
406 # figure out default Pstream library
407 if(FOAM_USE_MPI)
408   set(_FOAM_DEFAULT_PSTREAM mpi)
409 elseif(FOAM_USE_GAMMA)
410   set(_FOAM_DEFAULT_PSTREAM gamma)
411 else()
412   set(_FOAM_DEFAULT_PSTREAM dummy)
413 endif()
414 set(FOAM_DEFAULT_PSTREAM ${_FOAM_DEFAULT_PSTREAM} CACHE STRING
415   "Default Pstream library implementation [dummy|mpi|gamma]")
416 mark_as_advanced(FOAM_DEFAULT_PSTREAM)
418 # find m4 macro processor
419 find_program(M4_EXECUTABLE m4 DOC "Path to the m4 macro processor")
420 mark_as_advanced(M4_EXECUTABLE)
421 if(NOT M4_EXECUTABLE)
422   message("WARNING: Failed to find M4 macro processor.\n"
423     "Some of the tutorials will fail if it can't be found.")
424   set(M4_EXECUTABLE m4)
425 endif()
427 # find gnuplot executable
428 find_program(GNUPLOT_EXECUTABLE gnuplot DOC "Path to the gnuplot program")
429 mark_as_advanced(GNUPLOT_EXECUTABLE)
430 if(NOT GNUPLOT_EXECUTABLE)
431   message("WARNING: Failed ot find gnuplot.\n"
432     "Some tutorials will not create quantitative comparison plots.")
433 endif()
435 # on APPLE use cp -R -P -p, otherwise use cp -a
436 if(APPLE)
437   set(FOAM_CP_A_FLAGS "-R -P -p")
438 else()
439   set(FOAM_CP_A_FLAGS "-a")
440 endif()
442 # execinfo.h and cxxabi.h only work using GNU gcc and Debug config
443 # assume that if we have execinfo.h, cxxabi.h is also present.
444 if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL Debug)
445   find_package(Execinfo)
446 endif()
448 # create the FOAMConfig.h file
449 configure_file(${CMAKE_SOURCE_DIR}/FOAMConfig.h.in
450   ${CMAKE_BINARY_DIR}/include/FOAMConfig.h @ONLY)
452 # on Solaris/SunOS fix up the shebangs
453 if(CMAKE_SYSTEM_NAME STREQUAL SunOS AND NOT EXISTS ${CMAKE_BINARY_DIR}/replaceAllShellSun.run)
454   message(STATUS "Fixing shell-interpreter for SunOS and Solaris")
455   execute_process(
456     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun bin
457     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun data
458     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun tutorials
459     COMMAND ${CMAKE_SOURCE_DIR}/data/utilities/replaceAllShellSun doc
460     COMMAND ${CMAKE_COMMAND} -E touch${CMAKE_BINARY_DIR}/replaceAllShellSun.run
461     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
462     )
463 endif()
465 # set up defines
466 set(FOAM_COMPILE_DEFINITIONS
467   -D${FOAM_PRECISION}
468   -DNoRepository
469   -D${FOAM_OS}
470   )
471 if(APPLE)
472   list(APPEND FOAM_COMPILE_DEFINITIONS -Ddarwin)
473 endif()
474 add_definitions(${FOAM_COMPILE_DEFINITIONS})
476 # set up include-directories for own headers
477 include_directories(${CMAKE_BINARY_DIR}/include)
479 # descend into the sources...
480 add_subdirectory(bin)
481 add_subdirectory(etc)
482 add_subdirectory(data)
483 add_subdirectory(src)
484 add_subdirectory(applications)
485 add_subdirectory(tutorials)
486 add_subdirectory(doc)
488 # export the library dependencies to the build tree
489 foam_export_targets_to_build_tree(${PROJECT_NAME}LibraryDepends)
490 export(PACKAGE ${PROJECT_NAME})
492 # write the doc index file and install it
493 foam_write_doc_index()
494 install(FILES
495   ${CMAKE_BINARY_DIR}/InstallFiles/data/DoxyDocIndex
496   DESTINATION ${FOAM_INSTALL_DATA_PATH}
497   COMPONENT data
498   )
500 # create ${PROJECT_NAME}Config.cmake ${PROJECT_NAME}Use.cmake,
501 # ${PROJECT_NAME}Utilities.cmake and ${PROJECT_NAME}WmakeCompatibility.cmake
502 # for the build and install tree
503 foam_configure_files(ConfigInstallFiles
504   "CMake/FOAMConfig.cmake.in==CMake/${PROJECT_NAME}Config.cmake"
505   "CMake/FOAMUse.cmake.in==CMake/${PROJECT_NAME}Use.cmake"
506   "CMake/FOAMWmakeCompatibility.cmake.in==CMake/${PROJECT_NAME}WmakeCompatibility.cmake"
507   COPYONLY
508   "CMake/FOAMUtilities.cmake==CMake/${PROJECT_NAME}Utilities.cmake"
509   )
511 # install the CMake config files
512 install(FILES
513   ${ConfigInstallFiles}
514   DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
515   COMPONENT dev
516   )
518 # install the ${PROJECT_NAME}LibraryDepends.cmake file
519 install(EXPORT ${PROJECT_NAME}LibraryDepends
520   DESTINATION ${FOAM_INSTALL_CMAKE_PATH}
521   NAMESPACE FOAM_
522   COMPONENT dev
523   )
525 # pack things up
526 include(${CMAKE_SOURCE_DIR}/CMake/FOAMCPack.cmake)
528 # uninstall target
529 configure_file(
530   "${CMAKE_SOURCE_DIR}/CMake/Modules/cmake_uninstall.cmake.in"
531   "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
532   @ONLY
533   )
535 add_custom_target(uninstall
536   "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
537   )
539 # print cool feature summary
540 foam_print_feature_summary()
542 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file