Skip to content

Commit

Permalink
Merge pull request #16 from SeisSol/carsten/the-end-of-header-only
Browse files Browse the repository at this point in the history
The end of header only
  • Loading branch information
krenzland committed Oct 28, 2021
2 parents 93f9e15 + 9961024 commit ce945bf
Show file tree
Hide file tree
Showing 76 changed files with 3,609 additions and 4,661 deletions.
124 changes: 124 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never

203 changes: 118 additions & 85 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,109 +1,142 @@
##
# @file
# This file is part of SeisSol.
#
# @author Carsten Uphoff (c.uphoff AT tum.de, http://www5.in.tum.de/wiki/index.php/Carsten_Uphoff,_M.Sc.)
#
# @section LICENSE
# Copyright (c) 2017, SeisSol Group
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# @section DESCRIPTION
# Builds easi unit tests.
#

project (easi)
cmake_minimum_required (VERSION 3.8)
cmake_minimum_required (VERSION 3.13)

include (GNUInstallDirs)
include (CMakePackageConfigHelpers)

enable_language (CXX)
enable_language (Fortran)

option (ASAGI "Enable support for ASAGI" ON)

# Compiler settings
add_compile_options (-Wall -Werror)
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
### external packages ###

# easi library
include_directories (include)

# external packages
find_package (PkgConfig REQUIRED)
pkg_check_modules (YAMLCPP REQUIRED IMPORTED_TARGET yaml-cpp)
pkg_check_modules (IMPALAJIT REQUIRED IMPORTED_TARGET impalajit)
find_package (yaml-cpp REQUIRED)
find_package (impalajit REQUIRED)
find_package (OpenMP)

if (${ASAGI})
if (ASAGI)
find_package (PkgConfig REQUIRED)
find_package (HDF5 REQUIRED COMPONENTS C HL)
pkg_check_modules (NETCDF REQUIRED IMPORTED_TARGET netcdf)
pkg_check_modules (ASAGI REQUIRED IMPORTED_TARGET asagi)
endif ()

find_package (OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

function (set_dependencies target)
target_link_libraries (${target} PRIVATE
PkgConfig::YAMLCPP
PkgConfig::IMPALAJIT
### easi lib ###

set (EASI_SOURCES
src/component/AffineMap.cpp
src/component/AndersonianStress.cpp
src/component/Composite.cpp
src/component/ConstantMap.cpp
src/component/DomainFilter.cpp
src/component/EvalModel.cpp
src/component/FunctionMap.cpp
src/component/LayeredModelBuilder.cpp
src/component/OptimalStress.cpp
src/component/PolynomialMap.cpp
src/component/SCECFile.cpp
src/component/Special.cpp
src/component/Switch.cpp
src/parser/YAMLComponentParsers.cpp
src/parser/YAMLHelpers.cpp
src/util/FunctionWrapper.cpp
src/util/RegularGrid.cpp
src/Query.cpp
src/YAMLParser.cpp
)
if (ASAGI)
list (APPEND EASI_SOURCES
src/component/ASAGI.cpp
src/util/AsagiReader.cpp
)
if (${ASAGI})
target_link_libraries (${target} PRIVATE
endif ()

add_library (easi ${EASI_SOURCES})
target_compile_features (easi PUBLIC cxx_std_14)
set_target_properties(easi PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
target_link_libraries (easi
PUBLIC
yaml-cpp
PRIVATE
impalajit::impalajit
)
if (${OpenMP_CXX_FOUND})
target_link_libraries (easi PRIVATE OpenMP::OpenMP_CXX)
endif ()
if (ASAGI)
target_link_libraries (easi
PRIVATE
${HDF5_C_HL_LIBRARIES} ${HDF5_C_LIBRARIES}
PkgConfig::ASAGI
PkgConfig::NETCDF
)
endif ()
endfunction ()

function (easi_add_executable name files libs)
add_executable (${name} ${files})
set_dependencies (${name})
target_link_libraries (${name} PRIVATE ${libs})
endfunction (easi_add_executable)

if (${ASAGI})
easi_add_executable (easicube tools/easicube.cpp "")
)
target_compile_definitions (easi PUBLIC -DUSE_ASAGI)
endif ()
target_include_directories (easi
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

add_library (easitest tests/easitest.cpp tests/special.f90)
set_dependencies (easitest)
if (${ASAGI})
add_definitions (-DUSE_ASAGI)
# installation

set(CONFIG_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/easi)

install (TARGETS easi EXPORT easi-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install (DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install (EXPORT easi-targets
FILE easiTargets.cmake
NAMESPACE easi::
DESTINATION ${CONFIG_DESTINATION}
)

configure_package_config_file (
cmake/easiConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/easiConfig.cmake"
INSTALL_DESTINATION ${CONFIG_DESTINATION}
)
install (
FILES "${CMAKE_CURRENT_BINARY_DIR}/easiConfig.cmake"
DESTINATION ${CONFIG_DESTINATION}
)


### easicube ###

if (ASAGI)
add_executable (easicube tools/easicube.cpp)
target_link_libraries(easicube PRIVATE easi)
set_target_properties (easicube PROPERTIES
INSTALL_RPATH_USE_LINK_PATH TRUE
)
install (TARGETS easicube)
endif ()


### tests ###

enable_testing ()
add_library (easitest
tests/easitest.cpp
tests/special.f90
)
target_link_libraries(easitest PUBLIC easi)

function (easi_add_test name)
easi_add_executable (${name} tests/${name}.cpp easitest)
string (TOUPPER ${name} NAME_UP)
add_test (${NAME_UP}_TEST ${name} ${CMAKE_CURRENT_SOURCE_DIR}/examples/${name}.yaml)
add_executable (${name} tests/${name}.cpp)
target_link_libraries (${name} PRIVATE easitest)
string (TOUPPER ${name} NAME_UP)
add_test (${NAME_UP}_TEST ${name} ${CMAKE_CURRENT_SOURCE_DIR}/examples/${name}.yaml)
endfunction (easi_add_test)

easi_add_test (0_constant)
Expand All @@ -113,7 +146,7 @@ easi_add_test (3_layered_linear)
easi_add_test (5_function)
easi_add_test (26_function)
easi_add_test (33_layered_constant)
if (${ASAGI})
if (ASAGI)
easi_add_test (101_asagi)
easi_add_test (101_asagi_nearest)
endif ()
Expand Down
10 changes: 10 additions & 0 deletions cmake/easiConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include (CMakeFindDependencyMacro)

find_dependency (yaml-cpp REQUIRED)
find_dependency (impalajit REQUIRED)
find_dependency (OpenMP)

if (NOT TARGET easi::easi)
include ("${CMAKE_CURRENT_LIST_DIR}/easiTargets.cmake")
endif ()

3 changes: 3 additions & 0 deletions easi.imp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{ include: ["@<yaml-cpp/node/.*>", "private", "<yaml-cpp/yaml.h>", "public"] },
]

0 comments on commit ce945bf

Please sign in to comment.