Skip to content
Snippets Groups Projects
Commit 579b6bbe authored by Christian Godenschwager's avatar Christian Godenschwager
Browse files

Merge branch 'sanitizer' into 'master'

Added Cmake options to activate address and undefined behavior sanitizer

See merge request !26
parents ce490edd 0fda7c15
Branches
Tags
No related merge requests found
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
## ##
## Contents: ## Contents:
## - definition of build options ## - definition of build options
## - compiler variables ( c++ standard, warnings etc. ) ## - compiler variables ( c++ standard, warnings etc. )
## - Finding of service libraries. Required: boost, Optional: MPI, PE, METIS ## - Finding of service libraries. Required: boost, Optional: MPI, PE, METIS
## the include paths are set, and the libraries are added to variable SERVICE_LIBS ## the include paths are set, and the libraries are added to variable SERVICE_LIBS
## - Subdirectory cmake lists are called ## - Subdirectory cmake lists are called
## -> src/ this folder contains all modules, each module (that contains c or cpp files) is linked to a ## -> src/ this folder contains all modules, each module (that contains c or cpp files) is linked to a
## static library. Dependencies between these shared libraries are tracked manually, ## static library. Dependencies between these shared libraries are tracked manually,
## for more information see waLBerlaModuleDependencySystem.cmake ## for more information see waLBerlaModuleDependencySystem.cmake
## -> tests/ Same subdirectories as src/ folder. Contains tests for each module ## -> tests/ Same subdirectories as src/ folder. Contains tests for each module
## - Export of variables into internal cache variables, for usage in applications or projects that use walberla as ## - Export of variables into internal cache variables, for usage in applications or projects that use walberla as
## subdirectory. Variables containing the service-libs, ## subdirectory. Variables containing the service-libs,
## ##
############################################################################################################################ ############################################################################################################################
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
CMAKE_MINIMUM_REQUIRED (VERSION 2.8) CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
PROJECT ( walberla ) PROJECT ( walberla )
set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${walberla_SOURCE_DIR}/cmake ) set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${walberla_SOURCE_DIR}/cmake )
...@@ -41,12 +41,12 @@ if( CMAKE_VERSION VERSION_LESS 2.8.3 ) ...@@ -41,12 +41,12 @@ if( CMAKE_VERSION VERSION_LESS 2.8.3 )
else() else()
include( CMakeParseArguments ) include( CMakeParseArguments )
endif() endif()
# Enable CTest # Enable CTest
enable_testing() enable_testing()
include( CTest ) include( CTest )
############################################################################################################################ ############################################################################################################################
...@@ -62,20 +62,20 @@ include( CTest ) ...@@ -62,20 +62,20 @@ include( CTest )
# Build options # Build options
option ( WALBERLA_DOUBLE_ACCURACY "Floating point accuracy, defaults to double" ON ) option ( WALBERLA_DOUBLE_ACCURACY "Floating point accuracy, defaults to double" ON )
option ( WALBERLA_ENABLE_GUI "Compile with GUI" ) option ( WALBERLA_ENABLE_GUI "Compile with GUI" )
option ( WALBERLA_BUILD_TESTS "Build Testcases" ) option ( WALBERLA_BUILD_TESTS "Build Testcases" )
option ( WALBERLA_BUILD_BENCHMARKS "Build Benchmarks" ON ) option ( WALBERLA_BUILD_BENCHMARKS "Build Benchmarks" ON )
option ( WALBERLA_BUILD_TOOLS "Build Tools" ) option ( WALBERLA_BUILD_TOOLS "Build Tools" )
option ( WALBERLA_BUILD_TUTORIALS "Build Tutorials" ON ) option ( WALBERLA_BUILD_TUTORIALS "Build Tutorials" ON )
option ( WALBERLA_BUILD_WITH_MPI "Build with MPI" ON ) option ( WALBERLA_BUILD_WITH_MPI "Build with MPI" ON )
option ( WALBERLA_BUILD_WITH_METIS "Build with metis graph partitioner" OFF ) option ( WALBERLA_BUILD_WITH_METIS "Build with metis graph partitioner" OFF )
option ( WALBERLA_BUILD_WITH_GPROF "Enables gprof" ) option ( WALBERLA_BUILD_WITH_GPROF "Enables gprof" )
option ( WALBERLA_BUILD_WITH_GCOV "Enables gcov" ) option ( WALBERLA_BUILD_WITH_GCOV "Enables gcov" )
option ( WALBERLA_BUILD_WITH_LTO "Enable link time optimizations" ) option ( WALBERLA_BUILD_WITH_LTO "Enable link time optimizations" )
option ( WALBERLA_BUILD_WITH_OPENMP "Enable OpenMP support" ) option ( WALBERLA_BUILD_WITH_OPENMP "Enable OpenMP support" )
option ( WALBERLA_BUILD_WITH_PYTHON "Support for embedding Python" ) option ( WALBERLA_BUILD_WITH_PYTHON "Support for embedding Python" )
option ( WALBERLA_BUILD_WITH_PYTHON_MODULE "Build waLBerla python module" ) option ( WALBERLA_BUILD_WITH_PYTHON_MODULE "Build waLBerla python module" )
option ( WALBERLA_BUILD_WITH_PYTHON_LBM "Include LBM module into python module" OFF ) option ( WALBERLA_BUILD_WITH_PYTHON_LBM "Include LBM module into python module" OFF )
...@@ -83,9 +83,9 @@ option ( WALBERLA_BUILD_WITH_LIKWID_MARKERS "Compile in markers for likwid-perfc ...@@ -83,9 +83,9 @@ option ( WALBERLA_BUILD_WITH_LIKWID_MARKERS "Compile in markers for likwid-perfc
option ( WALBERLA_BUILD_WITH_FASTMATH "Fast math" ) option ( WALBERLA_BUILD_WITH_FASTMATH "Fast math" )
option ( WALBERLA_SIMD_FORCE_SCALAR "Do not use SIMD operations even when available" OFF ) option ( WALBERLA_SIMD_FORCE_SCALAR "Do not use SIMD operations even when available" OFF )
option ( WALBERLA_BUFFER_DEBUG "Type checking for BufferSystem ( slow )" OFF ) option ( WALBERLA_BUFFER_DEBUG "Type checking for BufferSystem ( slow )" OFF )
option ( WALBERLA_NO_OUTDATED_FEATURES "Show warning/errors when outdated features " option ( WALBERLA_NO_OUTDATED_FEATURES "Show warning/errors when outdated features "
...@@ -108,7 +108,7 @@ endif() ...@@ -108,7 +108,7 @@ endif()
SET_PROPERTY( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release DebugOptimized RelWithDebInfo MinSizeRel ) SET_PROPERTY( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release DebugOptimized RelWithDebInfo MinSizeRel )
# Debugging options ) # Debugging options )
option ( WALBERLA_STL_BOUNDS_CHECKS "Use debug capabilites of libstd++: iterator and bounds checks" ) option ( WALBERLA_STL_BOUNDS_CHECKS "Use debug capabilites of libstd++: iterator and bounds checks" )
# Warning options # Warning options
option ( WARNING_DISABLE "Disables additional compiler warnings" OFF ) option ( WARNING_DISABLE "Disables additional compiler warnings" OFF )
...@@ -116,10 +116,13 @@ option ( WARNING_PEDANTIC "Enables pedantic compiler warnings" ON ...@@ -116,10 +116,13 @@ option ( WARNING_PEDANTIC "Enables pedantic compiler warnings" ON
option ( WARNING_ERROR "Convert warnings to errors compiler warnings" OFF ) option ( WARNING_ERROR "Convert warnings to errors compiler warnings" OFF )
option ( WARNING_DEPRECATED "Show warning when deprecated features are used" ON ) option ( WARNING_DEPRECATED "Show warning when deprecated features are used" ON )
# Sanitizer options
option ( WALBERLA_SANITIZE_ADDRESS "Enables address sanitizer in gcc and clang" )
option ( WALBERLA_SANITIZE_UNDEFINED "Enables undefined behavior sanitizer in gcc and clang" )
# Every folder that is listed here can contain modules or tests # Every folder that is listed here can contain modules or tests
# this can be extended by applications to have own modules # this can be extended by applications to have own modules
# Here the src/ folder is added to this list, where all modules are located # Here the src/ folder is added to this list, where all modules are located
list( APPEND WALBERLA_MODULE_DIRS "${walberla_SOURCE_DIR}/src" "${walberla_SOURCE_DIR}/tests" ) list( APPEND WALBERLA_MODULE_DIRS "${walberla_SOURCE_DIR}/src" "${walberla_SOURCE_DIR}/tests" )
list( REMOVE_DUPLICATES WALBERLA_MODULE_DIRS ) list( REMOVE_DUPLICATES WALBERLA_MODULE_DIRS )
set ( WALBERLA_MODULE_DIRS ${WALBERLA_MODULE_DIRS} CACHE INTERNAL "All folders that contain modules or tests" ) set ( WALBERLA_MODULE_DIRS ${WALBERLA_MODULE_DIRS} CACHE INTERNAL "All folders that contain modules or tests" )
...@@ -169,7 +172,7 @@ else() ...@@ -169,7 +172,7 @@ else()
option ( WALBERLA_CXX_COMPILER_IS_GNU "Use gnu compiler" OFF ) option ( WALBERLA_CXX_COMPILER_IS_GNU "Use gnu compiler" OFF )
endif() endif()
mark_as_advanced ( WALBERLA_CXX_COMPILER_IS_GNU ) mark_as_advanced ( WALBERLA_CXX_COMPILER_IS_GNU )
# Check for Visual Studio # Check for Visual Studio
if ( MSVC ) if ( MSVC )
option ( WALBERLA_CXX_COMPILER_IS_MSVC "Use Visual Studio compiler" ON ) option ( WALBERLA_CXX_COMPILER_IS_MSVC "Use Visual Studio compiler" ON )
...@@ -336,32 +339,32 @@ if( WALBERLA_OPTIMIZE_FOR_LOCALHOST ) ...@@ -336,32 +339,32 @@ if( WALBERLA_OPTIMIZE_FOR_LOCALHOST )
add_flag ( CMAKE_C_FLAGS "-xhost" ) add_flag ( CMAKE_C_FLAGS "-xhost" )
endif() endif()
endif() endif()
endif() endif()
# warning flags # warning flags
if( WALBERLA_CXX_COMPILER_IS_INTEL ) if( WALBERLA_CXX_COMPILER_IS_INTEL )
# system headers are also supported by intel, but cmake does not recognize that # system headers are also supported by intel, but cmake does not recognize that
set( CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem " ) set( CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem " )
add_flag ( CMAKE_CXX_FLAGS "-wd2928,2504,2259,1682,597" ) add_flag ( CMAKE_CXX_FLAGS "-wd2928,2504,2259,1682,597" )
elseif( WALBERLA_CXX_COMPILER_IS_GNU ) elseif( WALBERLA_CXX_COMPILER_IS_GNU )
add_flag ( CMAKE_CXX_FLAGS "-Wfloat-equal -Wextra" ) add_flag ( CMAKE_CXX_FLAGS "-Wfloat-equal -Wextra" )
elseif( WALBERLA_CXX_COMPILER_IS_NEC ) elseif( WALBERLA_CXX_COMPILER_IS_NEC )
add_flag ( CMAKE_CXX_FLAGS "-wall" ) add_flag ( CMAKE_CXX_FLAGS "-wall" )
endif() endif()
if ( WARNING_PEDANTIC AND WALBERLA_CXX_COMPILER_IS_GNU ) if ( WARNING_PEDANTIC AND WALBERLA_CXX_COMPILER_IS_GNU )
add_flag ( CMAKE_CXX_FLAGS "-pedantic" ) add_flag ( CMAKE_CXX_FLAGS "-pedantic" )
endif ( ) endif ( )
# omit deprecated warnings # omit deprecated warnings
if( NOT WARNING_DEPRECATED) if( NOT WARNING_DEPRECATED)
if( WALBERLA_CXX_COMPILER_IS_INTEL ) if( WALBERLA_CXX_COMPILER_IS_INTEL )
add_flag( CMAKE_CXX_FLAGS "-wd1478" ) # Disable compiler warning # 1478: "declared as deprecated" add_flag( CMAKE_CXX_FLAGS "-wd1478" ) # Disable compiler warning # 1478: "declared as deprecated"
elseif( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_CLANG ) elseif( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_CLANG )
add_flag ( CMAKE_CXX_FLAGS "-Wno-deprecated-declarations") add_flag ( CMAKE_CXX_FLAGS "-Wno-deprecated-declarations")
endif() endif()
endif() endif()
# Treat warnings as errors # Treat warnings as errors
if ( WARNING_ERROR ) if ( WARNING_ERROR )
if( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_INTEL OR WALBERLA_CXX_COMPILER_IS_CLANG ) if( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_INTEL OR WALBERLA_CXX_COMPILER_IS_CLANG )
...@@ -391,15 +394,15 @@ if ( WALBERLA_BUILD_WITH_FASTMATH ) ...@@ -391,15 +394,15 @@ if ( WALBERLA_BUILD_WITH_FASTMATH )
if ( WALBERLA_CXX_COMPILER_IS_INTEL ) if ( WALBERLA_CXX_COMPILER_IS_INTEL )
add_flag( CMAKE_CXX_FLAGS "-fp-model fast=2 -no-prec-sqrt -no-prec-div" ) add_flag( CMAKE_CXX_FLAGS "-fp-model fast=2 -no-prec-sqrt -no-prec-div" )
endif() endif()
if ( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_CLANG ) if ( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_CLANG )
add_flag( CMAKE_CXX_FLAGS "-ffast-math") add_flag( CMAKE_CXX_FLAGS "-ffast-math")
endif() endif()
if( WALBERLA_CXX_COMPILER_IS_MSVC ) if( WALBERLA_CXX_COMPILER_IS_MSVC )
add_flag( CMAKE_CXX_FLAGS "/fp:fast" ) add_flag( CMAKE_CXX_FLAGS "/fp:fast" )
endif() endif()
endif() endif()
# Xcode generator disables -isystem flag, even though current versions of Xcode support it # Xcode generator disables -isystem flag, even though current versions of Xcode support it
if(CMAKE_GENERATOR STREQUAL "Xcode") if(CMAKE_GENERATOR STREQUAL "Xcode")
...@@ -456,33 +459,33 @@ if ( WALBERLA_CXX_COMPILER_IS_MSVC ) ...@@ -456,33 +459,33 @@ if ( WALBERLA_CXX_COMPILER_IS_MSVC )
if( WALBERLA_VS_MULTI_PROCESS_BUILD ) if( WALBERLA_VS_MULTI_PROCESS_BUILD )
add_flag ( CMAKE_CXX_FLAGS "-MP" ) # enable multi-threaded compiling add_flag ( CMAKE_CXX_FLAGS "-MP" ) # enable multi-threaded compiling
endif() endif()
add_definitions ( "-DNOMINMAX" ) # Disable Min/Max-Macros add_definitions ( "-DNOMINMAX" ) # Disable Min/Max-Macros
add_definitions ( "-D_WIN32_WINNT=0x501" ) # Minimum Windows versions is Windows XP add_definitions ( "-D_WIN32_WINNT=0x501" ) # Minimum Windows versions is Windows XP
add_definitions ( "-DWINVER=0x501" ) # Minimum Windows versions is Windows XP add_definitions ( "-DWINVER=0x501" ) # Minimum Windows versions is Windows XP
add_definitions ( "-D_CRT_SECURE_NO_WARNINGS" ) # disable warnings promoting Microsoft's security enhanced CRT add_definitions ( "-D_CRT_SECURE_NO_WARNINGS" ) # disable warnings promoting Microsoft's security enhanced CRT
add_definitions ( "-D_SCL_SECURE_NO_WARNINGS" ) # disable warnings triggered by Microsoft's checked iterators add_definitions ( "-D_SCL_SECURE_NO_WARNINGS" ) # disable warnings triggered by Microsoft's checked iterators
add_flag ( CMAKE_CXX_FLAGS "-W4" ) # set warning level to maximum add_flag ( CMAKE_CXX_FLAGS "-W4" ) # set warning level to maximum
add_flag ( CMAKE_CXX_FLAGS "-bigobj" ) # enable big object files add_flag ( CMAKE_CXX_FLAGS "-bigobj" ) # enable big object files
add_flag ( CMAKE_CXX_FLAGS "-wd4127" ) # disable compiler warning C4127: "conditional expression is constant" add_flag ( CMAKE_CXX_FLAGS "-wd4127" ) # disable compiler warning C4127: "conditional expression is constant"
add_flag ( CMAKE_CXX_FLAGS "-wd4512" ) # disable compiler warning C4512: "assignment operator could not be generated" add_flag ( CMAKE_CXX_FLAGS "-wd4512" ) # disable compiler warning C4512: "assignment operator could not be generated"
add_flag ( CMAKE_CXX_FLAGS "-wd4913" ) # disable compiler warning C4512: "user defined binary operator ',' exists but add_flag ( CMAKE_CXX_FLAGS "-wd4913" ) # disable compiler warning C4512: "user defined binary operator ',' exists but
# no overload could convert all operands, default built-in binary operator ',' # no overload could convert all operands, default built-in binary operator ','
# used" # used"
add_flag ( CMAKE_CXX_FLAGS "-wd4702" ) # disable compiler warning C4702: "unreachable code" add_flag ( CMAKE_CXX_FLAGS "-wd4702" ) # disable compiler warning C4702: "unreachable code"
add_flag ( CMAKE_CXX_FLAGS "-wd4505" ) # disable compiler warning C4505: "unreferenced local function has been removed" add_flag ( CMAKE_CXX_FLAGS "-wd4505" ) # disable compiler warning C4505: "unreferenced local function has been removed"
add_flag ( CMAKE_CXX_FLAGS "-wd4503" ) # disable compiler warning C4503: "'identifier' : decorated name length exceeded, name was truncated" add_flag ( CMAKE_CXX_FLAGS "-wd4503" ) # disable compiler warning C4503: "'identifier' : decorated name length exceeded, name was truncated"
if ( WARNING_ERROR ) if ( WARNING_ERROR )
add_flag ( CMAKE_CXX_FLAGS "-WX" ) # Treat warnings as errors add_flag ( CMAKE_CXX_FLAGS "-WX" ) # Treat warnings as errors
endif ( ) endif ( )
if( NOT WARNING_DEPRECATED) if( NOT WARNING_DEPRECATED)
add_definitions( "-D_CRT_SECURE_NO_DEPRECATE" ) add_definitions( "-D_CRT_SECURE_NO_DEPRECATE" )
add_definitions( "-D_SCL_SECURE_NO_DEPRECATE" ) add_definitions( "-D_SCL_SECURE_NO_DEPRECATE" )
add_flag ( CMAKE_CXX_FLAGS "-wd4996" ) # Disable compiler warning C4996: "declared as deprecated" add_flag ( CMAKE_CXX_FLAGS "-wd4996" ) # Disable compiler warning C4996: "declared as deprecated"
endif() endif()
endif ( ) endif ( )
############################################################################################################################ ############################################################################################################################
...@@ -495,7 +498,7 @@ endif ( ) ...@@ -495,7 +498,7 @@ endif ( )
## ##
############################################################################################################################# #############################################################################################################################
if ( WALBERLA_BUILD_WITH_PYTHON ) if ( WALBERLA_BUILD_WITH_PYTHON )
set ( waLBerla_REQUIRED_MIN_PYTHON_VERSION "2.7") set ( waLBerla_REQUIRED_MIN_PYTHON_VERSION "2.7")
if( WALBERLA_CXX_COMPILER_IS_MSVC ) if( WALBERLA_CXX_COMPILER_IS_MSVC )
find_package( PythonLibs QUIET REQUIRED) find_package( PythonLibs QUIET REQUIRED)
...@@ -503,15 +506,15 @@ if ( WALBERLA_BUILD_WITH_PYTHON ) ...@@ -503,15 +506,15 @@ if ( WALBERLA_BUILD_WITH_PYTHON )
# For Linux the standard find script does not work properly: # For Linux the standard find script does not work properly:
# Python is configured here using the command "python-config" which has to be on the PATH # Python is configured here using the command "python-config" which has to be on the PATH
if ( NOT PYTHONLIBS_VERSION_STRING ) if ( NOT PYTHONLIBS_VERSION_STRING )
find_program( PYTHON_CONFIG_EXE NAMES python3.5m-config python3.5-config find_program( PYTHON_CONFIG_EXE NAMES python3.5m-config python3.5-config
python3.4m-config python3.4-config python3.4m-config python3.4-config
python3.3m-config python3.3-config python3.3m-config python3.3-config
python3m-config python3-config python3m-config python3-config
python2.7-config python2.7-config
python2-config python-config ) python2-config python-config )
if ( NOT PYTHON_CONFIG_EXE ) if ( NOT PYTHON_CONFIG_EXE )
message( WARNING "Found python but no python-config, python-devel package not installed?" ) message( WARNING "Found python but no python-config, python-devel package not installed?" )
else() else()
execute_process( COMMAND ${PYTHON_CONFIG_EXE} --includes OUTPUT_VARIABLE PYTHON_INCLUDES ) execute_process( COMMAND ${PYTHON_CONFIG_EXE} --includes OUTPUT_VARIABLE PYTHON_INCLUDES )
separate_arguments( PYTHON_INCLUDES ) separate_arguments( PYTHON_INCLUDES )
list(GET PYTHON_INCLUDES 0 PYTHON_INCLUDES ) list(GET PYTHON_INCLUDES 0 PYTHON_INCLUDES )
...@@ -522,54 +525,54 @@ if ( WALBERLA_BUILD_WITH_PYTHON ) ...@@ -522,54 +525,54 @@ if ( WALBERLA_BUILD_WITH_PYTHON )
string( REPLACE "Python " "" PYTHONLIBS_VERSION_STRING ${PYTHONLIBS_VERSION_STRING} ) string( REPLACE "Python " "" PYTHONLIBS_VERSION_STRING ${PYTHONLIBS_VERSION_STRING} )
endif() endif()
endif() endif()
if ( NOT PYTHON_LIBRARY ) if ( NOT PYTHON_LIBRARY )
execute_process( COMMAND ${PYTHON_CONFIG_EXE} --libs OUTPUT_VARIABLE PYTHON_LIB OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( COMMAND ${PYTHON_CONFIG_EXE} --libs OUTPUT_VARIABLE PYTHON_LIB OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND ${PYTHON_CONFIG_EXE} --ldflags OUTPUT_VARIABLE PYTHON_LIB_DIR OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( COMMAND ${PYTHON_CONFIG_EXE} --ldflags OUTPUT_VARIABLE PYTHON_LIB_DIR OUTPUT_STRIP_TRAILING_WHITESPACE )
string( REGEX MATCH "(-lpython[0-9a-z.-]*)" PYTHON_LIB ${PYTHON_LIB} ) string( REGEX MATCH "(-lpython[0-9a-z.-]*)" PYTHON_LIB ${PYTHON_LIB} )
string( REGEX REPLACE "[-][l]([^ ]+)" "\\1" PYTHON_LIB "${PYTHON_LIB}" ) string( REGEX REPLACE "[-][l]([^ ]+)" "\\1" PYTHON_LIB "${PYTHON_LIB}" )
# take everything that "python-config --ldflags" gives us, remove "-L" and give it to find_library as possible paths # take everything that "python-config --ldflags" gives us, remove "-L" and give it to find_library as possible paths
# in this output there are also linker flags that are not paths but find_library can handle this # in this output there are also linker flags that are not paths but find_library can handle this
# overall this seems the most robust method # overall this seems the most robust method
string( REPLACE "-L" "" PYTHON_LIB_DIR ${PYTHON_LIB_DIR} ) string( REPLACE "-L" "" PYTHON_LIB_DIR ${PYTHON_LIB_DIR} )
separate_arguments( PYTHON_LIB_DIR ) separate_arguments( PYTHON_LIB_DIR )
find_library( PYTHON_LIBRARY NAMES ${PYTHON_LIB} find_library( PYTHON_LIBRARY NAMES ${PYTHON_LIB}
PATHS ${PYTHON_LIB_DIR} /usr/lib /usr/lib64 PATH_SUFFIXES lib lib64 NO_DEFAULT_PATH ) PATHS ${PYTHON_LIB_DIR} /usr/lib /usr/lib64 PATH_SUFFIXES lib lib64 NO_DEFAULT_PATH )
endif() endif()
endif() endif()
if( PYTHONLIBS_VERSION_STRING VERSION_LESS ${waLBerla_REQUIRED_MIN_PYTHON_VERSION} ) if( PYTHONLIBS_VERSION_STRING VERSION_LESS ${waLBerla_REQUIRED_MIN_PYTHON_VERSION} )
message( FATAL_ERROR "Found old python library: ${PYTHONLIBS_VERSION_STRING} need at least ${waLBerla_REQUIRED_MIN_PYTHON_VERSION}" ) message( FATAL_ERROR "Found old python library: ${PYTHONLIBS_VERSION_STRING} need at least ${waLBerla_REQUIRED_MIN_PYTHON_VERSION}" )
endif() endif()
option( WALBERLA_USE_PYTHON_DEBUG_LIBRARY "Make use of the python debug library" OFF ) option( WALBERLA_USE_PYTHON_DEBUG_LIBRARY "Make use of the python debug library" OFF )
if( WALBERLA_USE_PYTHON_DEBUG_LIBRARY ) if( WALBERLA_USE_PYTHON_DEBUG_LIBRARY )
# you have to make sure this matches the settings you compiled boost with! # you have to make sure this matches the settings you compiled boost with!
add_definitions( "-DBOOST_DEBUG_PYTHON" ) add_definitions( "-DBOOST_DEBUG_PYTHON" )
endif() endif()
if( NOT (PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR ) ) if( NOT (PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR ) )
message( FATAL_ERROR "Couldn't find any python library" ) message( FATAL_ERROR "Couldn't find any python library" )
endif() endif()
SET( WALBERLA_BUILD_WITH_PYTHON 1 ) SET( WALBERLA_BUILD_WITH_PYTHON 1 )
include_directories( ${PYTHON_INCLUDE_DIR} ) include_directories( ${PYTHON_INCLUDE_DIR} )
list ( APPEND SERVICE_LIBS ${PYTHON_LIBRARY} ) list ( APPEND SERVICE_LIBS ${PYTHON_LIBRARY} )
if( NOT WALBERLA_CXX_COMPILER_IS_MSVC ) if( NOT WALBERLA_CXX_COMPILER_IS_MSVC )
list ( APPEND SERVICE_LIBS -lutil ) list ( APPEND SERVICE_LIBS -lutil )
endif() endif()
if ( WALBERLA_BUILD_WITH_PYTHON_MODULE ) if ( WALBERLA_BUILD_WITH_PYTHON_MODULE )
# a python module is a shared library - so everything has to be compiled to position independent code # a python module is a shared library - so everything has to be compiled to position independent code
# otherwise linking the static libs into the shared lib will result in errors # otherwise linking the static libs into the shared lib will result in errors
if( NOT WALBERLA_CXX_COMPILER_IS_MSVC ) if( NOT WALBERLA_CXX_COMPILER_IS_MSVC )
add_flag ( CMAKE_CXX_FLAGS "-fPIC" ) add_flag ( CMAKE_CXX_FLAGS "-fPIC" )
add_flag ( CMAKE_C_FLAGS "-fPIC" ) add_flag ( CMAKE_C_FLAGS "-fPIC" )
endif() endif()
endif() endif()
if( MSVC10 ) if( MSVC10 )
include(CMakeDependentOption) include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION( PYTHON_FIXED_HYPOT_REDEFINITION "fixed _hypot redefinition by python" OFF "WALBERLA_BUILD_WITH_PYTHON" OFF ) CMAKE_DEPENDENT_OPTION( PYTHON_FIXED_HYPOT_REDEFINITION "fixed _hypot redefinition by python" OFF "WALBERLA_BUILD_WITH_PYTHON" OFF )
...@@ -577,14 +580,14 @@ if ( WALBERLA_BUILD_WITH_PYTHON ) ...@@ -577,14 +580,14 @@ if ( WALBERLA_BUILD_WITH_PYTHON )
message( WARNING "Make sure you modified your pyconfig.h that _hypot is not redefined -> see: http://connect.microsoft.com/VisualStudio/feedback/details/633988/warning-in-math-h-line-162-re-nonstandard-extensions-used" ) message( WARNING "Make sure you modified your pyconfig.h that _hypot is not redefined -> see: http://connect.microsoft.com/VisualStudio/feedback/details/633988/warning-in-math-h-line-162-re-nonstandard-extensions-used" )
endif() endif()
endif() endif()
# Sphinx documentation # Sphinx documentation
# to build documentation make sure to have sphinx and read-the-docs theme installed # to build documentation make sure to have sphinx and read-the-docs theme installed
# Install with: "pip install sphinx sphinx_rtd_theme" # Install with: "pip install sphinx sphinx_rtd_theme"
add_custom_target( docPython sphinx-build -b html "${walberla_SOURCE_DIR}/python/waLBerla_docs" "${walberla_BINARY_DIR}/doc/python" add_custom_target( docPython sphinx-build -b html "${walberla_SOURCE_DIR}/python/waLBerla_docs" "${walberla_BINARY_DIR}/doc/python"
COMMENT "Building HTML documentation for Python extension with Sphinx") COMMENT "Building HTML documentation for Python extension with Sphinx")
endif() endif()
...@@ -613,8 +616,8 @@ endif() ...@@ -613,8 +616,8 @@ endif()
# This variable is necessary, if the CMAKE version used is not aware of a more recent boost version (keep this up to date!) # This variable is necessary, if the CMAKE version used is not aware of a more recent boost version (keep this up to date!)
set ( Boost_ADDITIONAL_VERSIONS set ( Boost_ADDITIONAL_VERSIONS
"1.45" "1.45.0" "1.46" "1.46.0" "1.46.1" "1.47" "1.47.0" "1.48" "1.48.0" "1.49" "1.49.0" "1.45" "1.45.0" "1.46" "1.46.0" "1.46.1" "1.47" "1.47.0" "1.48" "1.48.0" "1.49" "1.49.0"
"1.50" "1.50.0" "1.51" "1.51.0" "1.52" "1.52.0" "1.53" "1.53.0" "1.54" "1.54.0" "1.55" "1.55.0" "1.50" "1.50.0" "1.51" "1.51.0" "1.52" "1.52.0" "1.53" "1.53.0" "1.54" "1.54.0" "1.55" "1.55.0"
"1.56" "1.56.0" "1.57" "1.57.0" "1.58" "1.58.0" "1.59" "1.59.0" "1.60" "1.60.0" "1.61" "1.61.0" "1.62" "1.62.0" "1.63" "1.63.0") "1.56" "1.56.0" "1.57" "1.57.0" "1.58" "1.58.0" "1.59" "1.59.0" "1.60" "1.60.0" "1.61" "1.61.0" "1.62" "1.62.0" "1.63" "1.63.0")
set ( Boost_USE_STATIC_LIBS OFF CACHE BOOL "Use boost static libraries" ) set ( Boost_USE_STATIC_LIBS OFF CACHE BOOL "Use boost static libraries" )
...@@ -630,12 +633,12 @@ if ( NOT BOOST_ROOT ) ...@@ -630,12 +633,12 @@ if ( NOT BOOST_ROOT )
break ( ) break ( )
endif ( ) endif ( )
endforeach ( ) endforeach ( )
endif ( ) endif ( )
find_package ( Boost ${waLBerla_REQUIRED_MIN_BOOST_VERSION} COMPONENTS ${waLBerla_REQUIRED_BOOST_COMPONENTS} QUIET ) find_package ( Boost ${waLBerla_REQUIRED_MIN_BOOST_VERSION} COMPONENTS ${waLBerla_REQUIRED_BOOST_COMPONENTS} QUIET )
if( NOT Boost_FOUND ) if( NOT Boost_FOUND )
message ( WARNING message ( WARNING
"The specified configuration of the BOOST libraries was not found on your system! Now trying some other configuration..." ) "The specified configuration of the BOOST libraries was not found on your system! Now trying some other configuration..." )
foreach ( Boost_USE_STATIC_LIBS ON OFF ) foreach ( Boost_USE_STATIC_LIBS ON OFF )
foreach ( Boost_USE_MULTITHREADED ON OFF ) foreach ( Boost_USE_MULTITHREADED ON OFF )
...@@ -665,12 +668,12 @@ if ( Boost_FOUND ) ...@@ -665,12 +668,12 @@ if ( Boost_FOUND )
link_directories ( ${Boost_LIBRARY_DIRS} ) link_directories ( ${Boost_LIBRARY_DIRS} )
list ( APPEND SERVICE_LIBS ${Boost_LIBRARIES} ) list ( APPEND SERVICE_LIBS ${Boost_LIBRARIES} )
add_definitions ( -DBOOST_ALL_NO_LIB ) # Disable Boost auto-linking (CMAKE does that for us...) add_definitions ( -DBOOST_ALL_NO_LIB ) # Disable Boost auto-linking (CMAKE does that for us...)
#fix for static lib usage: http://stackoverflow.com/questions/11812463/boost-python-link-errors-under-windows-msvc10 #fix for static lib usage: http://stackoverflow.com/questions/11812463/boost-python-link-errors-under-windows-msvc10
if( PYTHONLIBS_FOUND AND Boost_USE_STATIC_LIBS) if( PYTHONLIBS_FOUND AND Boost_USE_STATIC_LIBS)
add_definitions( -DBOOST_PYTHON_STATIC_LIB ) add_definitions( -DBOOST_PYTHON_STATIC_LIB )
endif() endif()
#fix for strange link behaviour of boost to python: boost only links to 'pyhton*.lib' and not to the absolute path #fix for strange link behaviour of boost to python: boost only links to 'pyhton*.lib' and not to the absolute path
if( WIN32 AND PYTHONLIBS_FOUND ) if( WIN32 AND PYTHONLIBS_FOUND )
get_filename_component( PYTHON_LIBRARY_DIR ${PYTHON_INCLUDE_DIR} PATH ) get_filename_component( PYTHON_LIBRARY_DIR ${PYTHON_INCLUDE_DIR} PATH )
...@@ -730,9 +733,9 @@ endif() ...@@ -730,9 +733,9 @@ endif()
## ##
############################################################################################################################ ############################################################################################################################
if ( WALBERLA_BUILD_WITH_MPI AND NOT WALBERLA_CXX_COMPILER_IS_MPI_WRAPPER ) if ( WALBERLA_BUILD_WITH_MPI AND NOT WALBERLA_CXX_COMPILER_IS_MPI_WRAPPER )
find_package ( MPI ) find_package ( MPI )
# FindMPI does not really work under windows, because it expects linux formatted strings from the mpi compiler. # FindMPI does not really work under windows, because it expects linux formatted strings from the mpi compiler.
# Nevertheless for Microsoft MPI and MPICH there are workarounds included, but not for OpenMPI. # Nevertheless for Microsoft MPI and MPICH there are workarounds included, but not for OpenMPI.
# Here is a workaround for windows with OpenMPI (use configure twice to see correct output). # Here is a workaround for windows with OpenMPI (use configure twice to see correct output).
...@@ -759,18 +762,18 @@ if ( WALBERLA_BUILD_WITH_MPI AND NOT WALBERLA_CXX_COMPILER_IS_MPI_WRAPPER ) ...@@ -759,18 +762,18 @@ if ( WALBERLA_BUILD_WITH_MPI AND NOT WALBERLA_CXX_COMPILER_IS_MPI_WRAPPER )
if ( NOT MPI_CXX_LIBRARIES STREQUAL "MPI_CXX_LIBRARIES-NOTFOUND" ) if ( NOT MPI_CXX_LIBRARIES STREQUAL "MPI_CXX_LIBRARIES-NOTFOUND" )
set ( MPI_CXX_FOUND ON FORCE ) set ( MPI_CXX_FOUND ON FORCE )
endif ( ) endif ( )
set ( MPI_C_LIBRARIES "MPI_C_LIBRARIES-NOTFOUND" CACHE FILEPATH "Cleared" FORCE ) set ( MPI_C_LIBRARIES "MPI_C_LIBRARIES-NOTFOUND" CACHE FILEPATH "Cleared" FORCE )
find_library ( MPI_C_LIBRARIES find_library ( MPI_C_LIBRARIES
NAMES mpi mpich mpich2 msmpi libmpi libmpich libmpich2 libmsmpi NAMES mpi mpich mpich2 msmpi libmpi libmpich libmpich2 libmsmpi
HINTS ${MPI_PATH} HINTS ${MPI_PATH}
PATH_SUFFIXES lib ) PATH_SUFFIXES lib )
set ( MPI_EXTRA_LIBRARY "MPI_C_LIBRARIES" CACHE FILEPATH "" FORCE ) set ( MPI_EXTRA_LIBRARY "MPI_C_LIBRARIES" CACHE FILEPATH "" FORCE )
if ( NOT MPI_C_LIBRARIES STREQUAL "MPI_C_LIBRARIES-NOTFOUND" ) if ( NOT MPI_C_LIBRARIES STREQUAL "MPI_C_LIBRARIES-NOTFOUND" )
set ( MPI_C_FOUND ON FORCE ) set ( MPI_C_FOUND ON FORCE )
endif ( ) endif ( )
if ( MPI_PATH MATCHES ".*OpenMPI.*" ) if ( MPI_PATH MATCHES ".*OpenMPI.*" )
set ( MPI_CXX_COMPILE_FLAGS "/DOMPI_IMPORTS" CACHE STRING "" FORCE ) set ( MPI_CXX_COMPILE_FLAGS "/DOMPI_IMPORTS" CACHE STRING "" FORCE )
set ( MPI_C_COMPILE_FLAGS "/DOMPI_IMPORTS" CACHE STRING "" FORCE ) set ( MPI_C_COMPILE_FLAGS "/DOMPI_IMPORTS" CACHE STRING "" FORCE )
...@@ -779,9 +782,9 @@ if ( WALBERLA_BUILD_WITH_MPI AND NOT WALBERLA_CXX_COMPILER_IS_MPI_WRAPPER ) ...@@ -779,9 +782,9 @@ if ( WALBERLA_BUILD_WITH_MPI AND NOT WALBERLA_CXX_COMPILER_IS_MPI_WRAPPER )
else ( ) else ( )
message ( WARNING "Found MPI Compiler but no Libraries -> invent a new workaround" ) message ( WARNING "Found MPI Compiler but no Libraries -> invent a new workaround" )
endif ( ) endif ( )
endif ( ) endif ( )
if ( MPI_FOUND ) if ( MPI_FOUND )
if ( MPI_CXX_FOUND ) if ( MPI_CXX_FOUND )
include_directories ( SYSTEM ${MPI_CXX_INCLUDE_PATH} ${MPI_C_INCLUDE_PATH} ) include_directories ( SYSTEM ${MPI_CXX_INCLUDE_PATH} ${MPI_C_INCLUDE_PATH} )
foreach( LIB ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} ) foreach( LIB ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} )
...@@ -799,11 +802,11 @@ if ( WALBERLA_BUILD_WITH_MPI AND NOT WALBERLA_CXX_COMPILER_IS_MPI_WRAPPER ) ...@@ -799,11 +802,11 @@ if ( WALBERLA_BUILD_WITH_MPI AND NOT WALBERLA_CXX_COMPILER_IS_MPI_WRAPPER )
endif ( ) endif ( )
add_flag ( CMAKE_C_FLAGS "${MPI_COMPILE_FLAGS}" ) add_flag ( CMAKE_C_FLAGS "${MPI_COMPILE_FLAGS}" )
endif ( ) endif ( )
add_flag ( CMAKE_MODULE_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}" ) add_flag ( CMAKE_MODULE_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}" )
add_flag ( CMAKE_EXE_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}" ) add_flag ( CMAKE_EXE_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}" )
add_flag ( CMAKE_SHARED_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}" ) add_flag ( CMAKE_SHARED_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}" )
# When using Intel MPI, mpi.h has to be included before including the standard library # When using Intel MPI, mpi.h has to be included before including the standard library
# therefore we use the -include flag to enforce this. # therefore we use the -include flag to enforce this.
if ( MPI_INCLUDE_PATH MATCHES "intel" ) if ( MPI_INCLUDE_PATH MATCHES "intel" )
...@@ -828,14 +831,14 @@ if ( WALBERLA_ENABLE_GUI ) ...@@ -828,14 +831,14 @@ if ( WALBERLA_ENABLE_GUI )
find_package( Qt4 COMPONENTS QtCore QtGui QtOpenGL QtXml REQUIRED ) find_package( Qt4 COMPONENTS QtCore QtGui QtOpenGL QtXml REQUIRED )
find_package( OpenGL REQUIRED ) find_package( OpenGL REQUIRED )
INCLUDE( ${QT_USE_FILE} ) INCLUDE( ${QT_USE_FILE} )
list ( APPEND SERVICE_LIBS ${OPENGL_LIBRARIES} ${QT_LIBRARIES} ) list ( APPEND SERVICE_LIBS ${OPENGL_LIBRARIES} ${QT_LIBRARIES} )
# Workaround for Qt4 moc and newer boost versions - moc cannot parse BOOST_JOIN # Workaround for Qt4 moc and newer boost versions - moc cannot parse BOOST_JOIN
# so additional defines are passed to the moc compiler that prevent the problematic header to be parsed # so additional defines are passed to the moc compiler that prevent the problematic header to be parsed
set( QT_MOC_EXECUTABLE ${QT_MOC_EXECUTABLE} -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED ) set( QT_MOC_EXECUTABLE ${QT_MOC_EXECUTABLE} -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED )
endif(WALBERLA_ENABLE_GUI) endif(WALBERLA_ENABLE_GUI)
############################################################################################################################ ############################################################################################################################
...@@ -850,9 +853,9 @@ endif(WALBERLA_ENABLE_GUI) ...@@ -850,9 +853,9 @@ endif(WALBERLA_ENABLE_GUI)
if ( WALBERLA_BUILD_WITH_METIS ) if ( WALBERLA_BUILD_WITH_METIS )
find_package ( Metis QUIET ) find_package ( Metis QUIET )
if ( METIS_FOUND ) if ( METIS_FOUND )
include_directories( ${METIS_INCLUDE_DIRS} ) include_directories( ${METIS_INCLUDE_DIRS} )
link_directories ( ${METIS_LIBRARY_DIR} ) link_directories ( ${METIS_LIBRARY_DIR} )
list ( APPEND SERVICE_LIBS ${METIS_LIBRARIES} ) list ( APPEND SERVICE_LIBS ${METIS_LIBRARIES} )
set ( WALBERLA_BUILD_WITH_METIS TRUE ) set ( WALBERLA_BUILD_WITH_METIS TRUE )
...@@ -860,7 +863,7 @@ if ( WALBERLA_BUILD_WITH_METIS ) ...@@ -860,7 +863,7 @@ if ( WALBERLA_BUILD_WITH_METIS )
set ( WALBERLA_BUILD_WITH_METIS OFF CACHE BOOL "Build with metis graph partitioner" FORCE ) set ( WALBERLA_BUILD_WITH_METIS OFF CACHE BOOL "Build with metis graph partitioner" FORCE )
endif() endif()
else() else()
set ( METIS_FOUND OFF CACHE BOOL "Metis found" FORCE ) set ( METIS_FOUND OFF CACHE BOOL "Metis found" FORCE )
endif() endif()
############################################################################################################################ ############################################################################################################################
...@@ -877,7 +880,7 @@ if( WALBERLA_BUILD_WITH_MPI ) ...@@ -877,7 +880,7 @@ if( WALBERLA_BUILD_WITH_MPI )
find_package( PFFT ) find_package( PFFT )
find_package( FFTW3 ) find_package( FFTW3 )
set( FFT_REQUIRED_LIBRARIES pfft fftw3_mpi fftw3 ) set( FFT_REQUIRED_LIBRARIES pfft fftw3_mpi fftw3 )
if( PFFT_FOUND AND FFTW3_MPI_FOUND ) if( PFFT_FOUND AND FFTW3_MPI_FOUND )
set( WALBERLA_BUILD_WITH_FFT TRUE CACHE INTERNAL "Build with FFT" ) set( WALBERLA_BUILD_WITH_FFT TRUE CACHE INTERNAL "Build with FFT" )
include_directories( SYSTEM ${PFFT_INCLUDE_DIR} ${FFTW3_MPI_INCLUDE_DIR} ) include_directories( SYSTEM ${PFFT_INCLUDE_DIR} ${FFTW3_MPI_INCLUDE_DIR} )
list( APPEND SERVICE_LIBS ${PFFT_LIBRARIES} ${FFTW3_LIBRARIES} ${FFTW3_MPI_LIBRARIES} ) list( APPEND SERVICE_LIBS ${PFFT_LIBRARIES} ${FFTW3_LIBRARIES} ${FFTW3_MPI_LIBRARIES} )
...@@ -932,11 +935,11 @@ if ( WALBERLA_CXX_COMPILER_IS_MSVC ) ...@@ -932,11 +935,11 @@ if ( WALBERLA_CXX_COMPILER_IS_MSVC )
string(REPLACE "/Ob0" "/Ob2" CMAKE_CXX_FLAGS_DEBUGOPTIMIZED ${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED}) string(REPLACE "/Ob0" "/Ob2" CMAKE_CXX_FLAGS_DEBUGOPTIMIZED ${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED})
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUGOPTIMIZED ${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED}) string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUGOPTIMIZED ${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED})
elseif( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_INTEL OR WALBERLA_CXX_COMPILER_IS_CLANG ) elseif( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_INTEL OR WALBERLA_CXX_COMPILER_IS_CLANG )
set( CMAKE_C_FLAGS_DEBUGOPTIMIZED "${CMAKE_C_FLAGS_DEBUGOPTIMIZED} -O3" ) set( CMAKE_C_FLAGS_DEBUGOPTIMIZED "${CMAKE_C_FLAGS_DEBUGOPTIMIZED} -O3" )
set( CMAKE_CXX_FLAGS_DEBUGOPTIMIZED "${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED} -O3" ) set( CMAKE_CXX_FLAGS_DEBUGOPTIMIZED "${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED} -O3" )
endif() endif()
set(CMAKE_C_FLAGS_DEBUGOPTIMIZED ${CMAKE_C_FLAGS_DEBUGOPTIMIZED} CACHE STRING set(CMAKE_C_FLAGS_DEBUGOPTIMIZED ${CMAKE_C_FLAGS_DEBUGOPTIMIZED} CACHE STRING
"Flags used by the compiler during DebugOptimized builds") "Flags used by the compiler during DebugOptimized builds")
set(CMAKE_CXX_FLAGS_DEBUGOPTIMIZED ${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED} CACHE STRING set(CMAKE_CXX_FLAGS_DEBUGOPTIMIZED ${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED} CACHE STRING
"Flags used by the compiler during DebugOptimized builds") "Flags used by the compiler during DebugOptimized builds")
...@@ -968,7 +971,7 @@ endif() ...@@ -968,7 +971,7 @@ endif()
############################################################################################################################ ############################################################################################################################
## ##
## OpenMP ## OpenMP
...@@ -1011,7 +1014,7 @@ endif() ...@@ -1011,7 +1014,7 @@ endif()
############################################################################################################################ ############################################################################################################################
## ##
## Testing Coverage ## Testing Coverage
## ##
############################################################################################################################ ############################################################################################################################
if (WALBERLA_BUILD_WITH_GCOV AND CMAKE_COMPILER_IS_GNUCXX ) if (WALBERLA_BUILD_WITH_GCOV AND CMAKE_COMPILER_IS_GNUCXX )
...@@ -1030,7 +1033,7 @@ endif() ...@@ -1030,7 +1033,7 @@ endif()
if ( WALBERLA_BUILD_WITH_GPROF ) if ( WALBERLA_BUILD_WITH_GPROF )
if ( WALBERLA_CXX_COMPILER_IS_INTEL ) if ( WALBERLA_CXX_COMPILER_IS_INTEL )
add_flag ( CMAKE_CXX_FLAGS "-pg" ) add_flag ( CMAKE_CXX_FLAGS "-pg" )
add_flag ( CMAKE_EXE_LINKER_FLAGS "-pg" ) add_flag ( CMAKE_EXE_LINKER_FLAGS "-pg" )
elseif ( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_CLANG ) elseif ( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_CLANG )
add_flag ( CMAKE_CXX_FLAGS "-pg" ) add_flag ( CMAKE_CXX_FLAGS "-pg" )
...@@ -1048,7 +1051,7 @@ endif() ...@@ -1048,7 +1051,7 @@ endif()
if ( WALBERLA_BUILD_WITH_LIKWID_MARKERS ) if ( WALBERLA_BUILD_WITH_LIKWID_MARKERS )
find_library( LIKWID_LIB likwid HINTS $ENV{LIKWID_ROOT} ) find_library( LIKWID_LIB likwid HINTS $ENV{LIKWID_ROOT} )
if ( LIKWID_LIB ) if ( LIKWID_LIB )
set( LIKWID_FOUND 1) set( LIKWID_FOUND 1)
list ( APPEND SERVICE_LIBS ${LIKWID_LIB} ) list ( APPEND SERVICE_LIBS ${LIKWID_LIB} )
...@@ -1067,7 +1070,7 @@ endif() ...@@ -1067,7 +1070,7 @@ endif()
## ##
############################################################################################################################ ############################################################################################################################
if ( WALBERLA_BUILD_WITH_LTO ) if ( WALBERLA_BUILD_WITH_LTO )
if( WALBERLA_CXX_COMPILER_IS_INTEL ) if( WALBERLA_CXX_COMPILER_IS_INTEL )
add_flag( CMAKE_CXX_FLAGS_RELEASE "-ip -ipo3" ) add_flag( CMAKE_CXX_FLAGS_RELEASE "-ip -ipo3" )
add_flag( CMAKE_C_FLAGS_RELEASE "-ip -ipo3" ) add_flag( CMAKE_C_FLAGS_RELEASE "-ip -ipo3" )
...@@ -1078,25 +1081,39 @@ if ( WALBERLA_BUILD_WITH_LTO ) ...@@ -1078,25 +1081,39 @@ if ( WALBERLA_BUILD_WITH_LTO )
add_flag ( CMAKE_CXX_FLAGS_RELEASE "-flto=3" ) add_flag ( CMAKE_CXX_FLAGS_RELEASE "-flto=3" )
add_flag ( CMAKE_EXE_LINKER_FLAGS "-fuse-linker-plugin" ) add_flag ( CMAKE_EXE_LINKER_FLAGS "-fuse-linker-plugin" )
endif ( ) endif ( )
if( WALBERLA_CXX_COMPILER_IS_MSVC ) if( WALBERLA_CXX_COMPILER_IS_MSVC )
add_flag ( CMAKE_CXX_FLAGS_RELEASE "/GL" ) add_flag ( CMAKE_CXX_FLAGS_RELEASE "/GL" )
add_flag ( CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG" ) add_flag ( CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG" )
add_flag ( CMAKE_SHARED_LINKER_FLAGS_RELEASE "/LTCG" ) add_flag ( CMAKE_SHARED_LINKER_FLAGS_RELEASE "/LTCG" )
add_flag ( CMAKE_MODULE_LINKER_FLAGS_RELEASE "/LTCG" ) add_flag ( CMAKE_MODULE_LINKER_FLAGS_RELEASE "/LTCG" )
endif ( ) endif ( )
if( WALBERLA_CXX_COMPILER_IS_IBM ) if( WALBERLA_CXX_COMPILER_IS_IBM )
add_flag ( CMAKE_C_FLAGS_RELEASE "-qipa" ) add_flag ( CMAKE_C_FLAGS_RELEASE "-qipa" )
add_flag ( CMAKE_CXX_FLAGS_RELEASE "-qipa" ) add_flag ( CMAKE_CXX_FLAGS_RELEASE "-qipa" )
add_flag ( CMAKE_EXE_LINKER_FLAGS "-qipa" ) add_flag ( CMAKE_EXE_LINKER_FLAGS "-qipa" )
endif( ) endif( )
endif ( ) endif ( )
############################################################################################################################ ############################################################################################################################
############################################################################################################################
##
## Sanitizer
##
############################################################################################################################
if ( WALBERLA_SANITIZE_ADDRESS )
if ( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_CLANG )
add_flag( CMAKE_CXX_FLAGS "-fsanitize=address")
endif()
endif()
if ( WALBERLA_SANITIZE_UNDEFINED )
if ( WALBERLA_CXX_COMPILER_IS_GNU OR WALBERLA_CXX_COMPILER_IS_CLANG )
add_flag( CMAKE_CXX_FLAGS "-fsanitize=undefined")
endif()
endif()
############################################################################################################################ ############################################################################################################################
# Documentation Generation # Documentation Generation
...@@ -1111,17 +1128,17 @@ if ( HTML_HELP_COMPILER EQUAL "" ) ...@@ -1111,17 +1128,17 @@ if ( HTML_HELP_COMPILER EQUAL "" )
else ( ) else ( )
set ( HTML_HELP_FOUND "YES" ) set ( HTML_HELP_FOUND "YES" )
endif ( ) endif ( )
if ( DOXYGEN_FOUND ) if ( DOXYGEN_FOUND )
set ( DOXYGEN_HTML_HEADER ${walberla_SOURCE_DIR}/doc/header.html ) set ( DOXYGEN_HTML_HEADER ${walberla_SOURCE_DIR}/doc/header.html )
set ( DOXYGEN_HTML_FOOTER ${walberla_SOURCE_DIR}/doc/footer.html ) set ( DOXYGEN_HTML_FOOTER ${walberla_SOURCE_DIR}/doc/footer.html )
set ( DOXYGEN_HTML_OUTPUT "html" ) set ( DOXYGEN_HTML_OUTPUT "html" )
configure_file ( ${walberla_SOURCE_DIR}/doc/doxygen.in ${walberla_BINARY_DIR}/doc/doxygen.cfg @ONLY ) configure_file ( ${walberla_SOURCE_DIR}/doc/doxygen.in ${walberla_BINARY_DIR}/doc/doxygen.cfg @ONLY )
add_custom_target ( doc ${DOXYGEN_EXECUTABLE} ${walberla_BINARY_DIR}/doc/doxygen.cfg add_custom_target ( doc ${DOXYGEN_EXECUTABLE} ${walberla_BINARY_DIR}/doc/doxygen.cfg
COMMENT "Generating API documentation with Doxygen" VERBATIM ) COMMENT "Generating API documentation with Doxygen" VERBATIM )
endif ( ) endif ( )
############################################################################################################################ ############################################################################################################################
...@@ -1163,14 +1180,14 @@ endif() ...@@ -1163,14 +1180,14 @@ endif()
# Add binary dir for generated headers # Add binary dir for generated headers
include_directories ( ${CMAKE_CURRENT_BINARY_DIR}/src ) include_directories ( ${CMAKE_CURRENT_BINARY_DIR}/src )
# All include paths are specified relative to src/ directory # All include paths are specified relative to src/ directory
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/src )
# Generate file with compile options, and add install rule for it # Generate file with compile options, and add install rule for it
configure_file ( src/waLBerlaDefinitions.in.h configure_file ( src/waLBerlaDefinitions.in.h
src/waLBerlaDefinitions.h ) src/waLBerlaDefinitions.h )
install( FILES ${walberla_BINARY_DIR}/src/waLBerlaDefinitions.h DESTINATION walberla/ ) install( FILES ${walberla_BINARY_DIR}/src/waLBerlaDefinitions.h DESTINATION walberla/ )
# sources # sources
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment