Skip to content
Snippets Groups Projects
Commit 7163d39d authored by Dominik Thoennes's avatar Dominik Thoennes
Browse files

removes empty lines and trailing white spaces

parent 5679e9dc
Branches
Tags
No related merge requests found
include ( waLBerlaHelperFunctions )
include ( waLBerlaModuleDependencySystem )
set ( WALBERLA_GLOB_FILES *.cpp
*.c
*.h
*.cu
*.c
*.h
*.cu
CACHE INTERNAL "File endings to glob for source files" )
#######################################################################################################################
#
# Creates a walberla module library
#
#
#
# Keywords:
# DEPENDS [required] list of modules, that this module depends on
# FILES [optional] list of all source and header files belonging to that module
# if this is not given, all source and header files in the directory are added.
# Careful: when file was added or deleted, cmake has to be run again
# EXCLUDE [optional] Files that should not be included in the module (but are located in module directory).
# EXCLUDE [optional] Files that should not be included in the module (but are located in module directory).
# This makes only sense if FILES was not specified, and all files have been added automatically.
# BUILD_ONLY_IF_FOUND Before building the module test if all libraries specified here are availbable.
# [optional] This is done using the ${arg}_FOUND variable.
# Example: waLBerla_add_module( DEPENDS someModule BUILD_ONLY_IF_FOUND pe)
# Example: waLBerla_add_module( DEPENDS someModule BUILD_ONLY_IF_FOUND pe)
# This module is only built if PE_FOUND is true.
#
#######################################################################################################################
......@@ -34,11 +33,11 @@ function ( waLBerla_add_module )
set( oneValueArgs )
set( multiValueArgs DEPENDS EXCLUDE FILES BUILD_ONLY_IF_FOUND )
cmake_parse_arguments( ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
# Module name is the directory relative to WALBERLA_MODULE_DIRS
get_current_module_name ( moduleName )
get_module_library_name ( moduleLibraryName ${moduleName} )
# Test if all required libraries are available
# this is detected using the _FOUND variable
foreach ( externalName ${ARG_BUILD_ONLY_IF_FOUND} )
......@@ -49,7 +48,7 @@ function ( waLBerla_add_module )
endif()
endforeach()
# Take source files either from parameter or search all source files
# Take source files either from parameter or search all source files
file ( GLOB_RECURSE allFiles "*" ) # Find all files
if ( ARG_FILES )
foreach( sourceFile ${ARG_FILES} )
......@@ -60,7 +59,7 @@ function ( waLBerla_add_module )
file ( GLOB_RECURSE sourceFiles ${WALBERLA_GLOB_FILES} ) # Find all source files
endif()
# Remove exclude files from the sources
# Remove exclude files from the sources
if ( ARG_EXCLUDE )
foreach ( fileToExclude ${ARG_EXCLUDE} )
get_filename_component( fileToExclude ${fileToExclude} ABSOLUTE )
......@@ -77,17 +76,17 @@ function ( waLBerla_add_module )
endif ( )
# Dependency Check
check_dependencies( missingDeps additionalDeps FILES ${sourceFiles} EXPECTED_DEPS ${ARG_DEPENDS} ${moduleName} )
check_dependencies( missingDeps additionalDeps FILES ${sourceFiles} EXPECTED_DEPS ${ARG_DEPENDS} ${moduleName} )
if ( missingDeps )
message ( WARNING "The module ${moduleName} depends on ${missingDeps} which are not listed as dependencies!" )
endif()
set( hasSourceFiles FALSE )
foreach ( sourceFile ${sourceFiles} )
set( hasSourceFiles FALSE )
foreach ( sourceFile ${sourceFiles} )
if ( ${sourceFile} MATCHES "\\.(c|cpp|cu)" )
set( hasSourceFiles TRUE )
endif( )
endforeach( )
set( hasSourceFiles TRUE )
endif( )
endforeach( )
if ( hasSourceFiles )
set( generatedSourceFiles )
......@@ -103,11 +102,11 @@ function ( waLBerla_add_module )
else()
add_library( ${moduleLibraryName} STATIC ${sourceFiles} ${generatedSourceFiles} ${generatorSourceFiles} ${otherFiles} )
endif( CUDA_FOUND )
set_source_files_properties( ${generatedSourceFiles} PROPERTIES GENERATED TRUE )
else( )
add_custom_target( ${moduleLibraryName} SOURCES ${sourceFiles} ${generatedSourceFiles} ${otherFiles} ) # dummy IDE target
endif( )
else( )
add_custom_target( ${moduleLibraryName} SOURCES ${sourceFiles} ${generatedSourceFiles} ${otherFiles} ) # dummy IDE target
endif( )
waLBerla_register_dependency ( ${moduleName} ${ARG_DEPENDS} )
......@@ -117,36 +116,36 @@ function ( waLBerla_add_module )
if( WALBERLA_GROUP_PROJECTS )
set_property( TARGET ${moduleLibraryName} PROPERTY FOLDER "SRC" )
endif()
# Install rule for library
get_target_property( module_type ${moduleLibraryName} TYPE )
if( ${module_type} MATCHES LIBRARY )
if( ${module_type} MATCHES LIBRARY )
install ( TARGETS ${moduleLibraryName} RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib )
endif( )
# Install rule for header
install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION "walberla/${moduleName}"
install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION "walberla/${moduleName}"
FILES_MATCHING PATTERN "*.h"
PATTERN "*.in.h" EXCLUDE
PATTERN "*.in.h" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE )
# Install generated headers if necessary
if ( NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} )
install ( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
DESTINATION "walberla/${moduleName}"
# Install generated headers if necessary
if ( NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} )
install ( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
DESTINATION "walberla/${moduleName}"
FILES_MATCHING PATTERN "*.h"
PATTERN "*.in.h" EXCLUDE
PATTERN "*.in.h" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE )
endif()
endif()
# Report module statistics - which is later on written out to a json file
# This file is used in the doxygen documentation to display a module graph
#waLBerla_module_statistics ( FILES ${sourceFiles} DEPENDS ${ARG_DEPENDS} )
endfunction ( waLBerla_add_module )
#######################################################################################################################
......@@ -160,7 +159,7 @@ endfunction ( waLBerla_add_module )
# The application is linked against all waLBerla modules that are listed after DEPENDS
#
#
# NAME [required] Name of application
# NAME [required] Name of application
# GROUP [optional] IDE group name (e.g. VS)
# DEPENDS [required] list of modules, that this application depends on
# FILES [optional] list of all source and header files belonging to that application
......@@ -178,9 +177,9 @@ function ( waLBerla_add_executable )
cmake_parse_arguments( ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
if( NOT ARG_NAME )
message ( FATAL_ERROR "waLBerla_add_executable called without a NAME" )
message ( FATAL_ERROR "waLBerla_add_executable called without a NAME" )
endif()
# Skip this app, if it depends on modules that have not been built ( because they for example depend on PE)
foreach ( depMod ${ARG_DEPENDS} )
get_module_library_name ( depModLibraryName ${depMod} )
......@@ -189,8 +188,8 @@ function ( waLBerla_add_executable )
return()
endif()
endforeach()
# Take source files either from parameter or search all source files
# Take source files either from parameter or search all source files
set( sourceFiles )
if ( ARG_FILES )
foreach( sourceFile ${ARG_FILES} )
......@@ -218,14 +217,14 @@ function ( waLBerla_add_executable )
message(STATUS "Skipping ${ARG_NAME} since pystencils code generation is not enabled")
return()
endif()
if ( CUDA_FOUND )
cuda_add_executable( ${ARG_NAME} ${sourceFiles} ${generatedSourceFiles} ${generatorSourceFiles} )
else()
add_executable( ${ARG_NAME} ${sourceFiles} ${generatedSourceFiles} ${generatorSourceFiles} )
endif()
set_source_files_properties( ${generatedSourceFiles} PROPERTIES GENERATED TRUE )
target_link_modules ( ${ARG_NAME} ${ARG_DEPENDS} )
......@@ -238,7 +237,7 @@ function ( waLBerla_add_executable )
endif()
set_property( TARGET ${ARG_NAME} PROPERTY FOLDER ${ARG_GROUP} )
endif()
endfunction ( waLBerla_add_executable )
#######################################################################################################################
......@@ -257,20 +256,20 @@ function ( waLBerla_compile_test )
set( oneValueArgs NAME )
set( multiValueArgs FILES DEPENDS )
cmake_parse_arguments( ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
# Module name is the directory relative to WALBERLA_MODULE_DIRS
get_current_module_name ( moduleName )
# Filename of first source file is used as name for testcase if no name was given
if( NOT ARG_NAME )
list( GET ARG_FILES 0 ARG_NAME )
get_filename_component( ARG_NAME ${ARG_NAME} NAME_WE )
endif()
waLBerla_add_executable ( NAME ${ARG_NAME} GROUP "TESTS/${moduleName}"
waLBerla_add_executable ( NAME ${ARG_NAME} GROUP "TESTS/${moduleName}"
DEPENDS ${ARG_DEPENDS} ${moduleName} FILES ${ARG_FILES} )
endfunction ( waLBerla_compile_test )
#######################################################################################################################
......@@ -280,9 +279,9 @@ endfunction ( waLBerla_compile_test )
#######################################################################################################################
#
# Links all files in current source dir matching a globbing expression to the build directory
#
#
# first parameter is glob expression
#
#
# Typical usage: link all parameter files in same folder as the binary was produced
# Assuming the parameter files end with prm, write this to your CMakeLists in the
# app or test folder:
......@@ -293,15 +292,15 @@ endfunction ( waLBerla_compile_test )
#######################################################################################################################
function ( waLBerla_link_files_to_builddir globExpression )
# don't need links for in-source builds
if( CMAKE_CURRENT_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" )
return()
endif()
file( GLOB filesToLink RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${globExpression} )
foreach( f ${filesToLink} )
foreach( f ${filesToLink} )
if( CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" )
configure_file( ${f} ${f} COPYONLY )
else()
......@@ -309,9 +308,9 @@ function ( waLBerla_link_files_to_builddir globExpression )
${CMAKE_CURRENT_SOURCE_DIR}/${f}
${CMAKE_CURRENT_BINARY_DIR}/${f} )
endif()
endforeach()
endfunction ( waLBerla_link_files_to_builddir )
......@@ -319,37 +318,37 @@ endfunction ( waLBerla_link_files_to_builddir )
#######################################################################################################################
#
# Adds an executable to CTest.
#
# Adds an executable to CTest.
#
# Wrapper around add_test, that handles test labels and parallel runs
# Adds the module name as test label, plus optional user defined labels.
#
# NAME [required] Name of test
# PROCESSES [optional] Number of MPI processes, that are used to start this test.
# PROCESSES [optional] Number of MPI processes, that are used to start this test.
# If walberla is built without MPI, and PROCESSES > 1, the test is not added
# Defaults to 1
# COMMAND [optional] The command that is executed. Use this to start with parameter files or other
# command line options.
# command line options.
# Defaults to $<TARGET_FILE:${NAME}> (for this syntax see cmake documentation of add_test )
# LABELS [optional] Additional test labels.
# LABELS [optional] Additional test labels.
#
#######################################################################################################################
function ( waLBerla_execute_test )
set( options NO_MODULE_LABEL )
set( oneValueArgs NAME PROCESSES )
set( multiValueArgs COMMAND LABELS CONFIGURATIONS DEPENDS_ON_TARGETS )
cmake_parse_arguments( ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
if( NOT ARG_NAME )
message ( FATAL_ERROR "waLBerla_execute_test called without a NAME" )
message ( FATAL_ERROR "waLBerla_execute_test called without a NAME" )
endif()
if( NOT ARG_COMMAND AND NOT TARGET ${ARG_NAME} )
message ( STATUS "Skipping test ${ARG_NAME} since the corresponding target is not built" )
return()
endif()
endif()
foreach( dependency_target ${ARG_DEPENDS_ON_TARGETS} )
if( NOT TARGET ${dependency_target} )
......@@ -357,7 +356,7 @@ function ( waLBerla_execute_test )
return()
endif()
endforeach( dependency_target )
if( NOT ARG_PROCESSES )
set ( numProcesses 1 )
else()
......@@ -372,24 +371,22 @@ function ( waLBerla_execute_test )
list( INSERT ARG_COMMAND 0 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${numProcesses} ${MPIEXEC_PREFLAGS} )
elseif( numProcesses GREATER 1 )
return()
endif()
endif()
if( ARG_CONFIGURATIONS )
add_test( NAME ${ARG_NAME} ${ARG_UNPARSED_ARGUMENTS} COMMAND ${ARG_COMMAND} CONFIGURATIONS ${ARG_CONFIGURATIONS} )
else()
add_test( NAME ${ARG_NAME} ${ARG_UNPARSED_ARGUMENTS} COMMAND ${ARG_COMMAND} )
endif()
if( ARG_NO_MODULE_LABEL )
set_tests_properties ( ${ARG_NAME} PROPERTIES LABELS "${ARG_LABELS}" )
else()
get_current_module_name ( moduleName )
get_current_module_name ( moduleName )
set_tests_properties ( ${ARG_NAME} PROPERTIES LABELS "${moduleName} ${ARG_LABELS}" )
endif()
set_tests_properties ( ${ARG_NAME} PROPERTIES PROCESSORS ${numProcesses} )
endfunction ( waLBerla_execute_test )
#######################################################################################################################
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