This repository has been archived by the owner on May 15, 2024. It is now read-only.
generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
172 lines (138 loc) · 6.59 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# SPDX-FileCopyrightText: 2023 SAP SE
#
# SPDX-License-Identifier: Apache-2.0
#
# This file is part of FEDEM - https://openfedem.org
################################################################################
# This is the top-level cmake project file for the Fedem solver sources.
################################################################################
cmake_minimum_required ( VERSION 2.8...3.5 )
if ( POLICY CMP0076 )
cmake_policy ( SET CMP0076 NEW ) # convert relative target source path names
endif ( POLICY CMP0076 )
# Project setup
set ( APPLICATION_ID fedemKernel )
set ( DOMAIN_ID FEDEM )
set ( PACKAGE_ID SOLVERS )
project ( ${APPLICATION_ID} CXX C Fortran )
message ( STATUS "Generating build project for ${PROJECT_SOURCE_DIR}" )
find_path ( _MODULES FedemConfig.cmake
PATHS $ENV{CMAKE_MODULES}
"${PROJECT_SOURCE_DIR}/fedem-foundation/cmake/Modules/"
)
if ( _MODULES )
message ( STATUS "NOTE : Using ${_MODULES}" )
list ( APPEND CMAKE_MODULE_PATH ${_MODULES} )
else ( _MODULES )
message ( STATUS "ERROR : Missing path to FedemConfig.cmake" )
message ( FATAL_ERROR "Set environment variable CMAKE_MODULES and try again" )
endif ( _MODULES )
unset ( _MODULES CACHE )
include ( CheckPFUnit )
include ( FedemConfig )
option ( USE_MEMPOOL "Use memory pool for heap allocation in FE library" false )
option ( USE_PROFILER "Use CPU and Memory profiler" false )
mark_as_advanced ( USE_MEMPOOL USE_PROFILER )
# Enable unit and regression testing
set ( CTEST_OPTIONS --force-new-ctest-process --output-on-failure -O CTest.txt )
option ( BUILD_TEST_REPORTS "Enable test and profiling reports" false )
if ( BUILD_TEST_REPORTS )
list ( APPEND CTEST_OPTIONS --test-action Test --no-compress-output )
# Needed by the profiling execution (see below)
set ( MEMORYCHECK_COMMAND_OPTIONS "--tool=callgrind -v" )
include ( CTest )
else ( BUILD_TEST_REPORTS )
enable_testing ()
endif ( BUILD_TEST_REPORTS )
if ( CMAKE_CONFIGURATION_TYPES )
list ( APPEND CTEST_OPTIONS --build-config \"$<CONFIGURATION>\" )
endif ( CMAKE_CONFIGURATION_TYPES )
# The target check is to be used (instead of test) to ensure that
# all test executables are built before executing the tests.
add_custom_target ( check COMMAND ${CMAKE_CTEST_COMMAND} ${CTEST_OPTIONS} )
include ( GTest ) # Using the google test framework for C++ unit tests
include ( pFUnit ) # Using the pFUnit test framework for Fortran unit tests
# Copy scripts to build directory file (script execution place)
message ( STATUS "INFORMATION : Copying run scripts to build directory")
file ( GLOB SCRIPT_FILES scripts/*.sh )
foreach ( FILE ${SCRIPT_FILES} )
configure_file ( ${FILE} ${CMAKE_CURRENT_BINARY_DIR} )
endforeach ( FILE ${SCRIPT_FILES} )
# Setting up profiling with callgrind without using a script.
# Set PROF_RANGE for running a specific number of tests by numbers
# (must be specified at cmake level, see CTest documentation).
# cmake ....... -DPROF_RANGE=3,3 (for example)
if ( BUILD_TEST_REPORTS )
set ( CTEST_OPTIONS --force-new-ctest-process
-D ExperimentalMemCheck -O CTest.log )
if ( PROF_RANGE )
list ( APPEND CTEST_OPTIONS -I ${PROF_RANGE} )
endif ( PROF_RANGE )
add_custom_target ( code_profile
COMMAND ${CMAKE_CTEST_COMMAND} ${CTEST_OPTIONS}
COMMENT "Generating profiling with callgrind"
VERBATIM )
endif ( BUILD_TEST_REPORTS )
# Generate documentation for code coverage
if ( LINUX )
include ( CodeCoverage )
# skip coverage reporting for all sources under these folders
set ( EXCLUDES src/vpmReducer src/vpmStress
src/vpmCommon/vpmLinAlg/vpmLinAlgDummy
fedem-foundation/src/FemLib fedem-foundation/src/FFlLib
fedem-foundation/src/Admin *vpmLinAlg/fe *Tests )
# build html coverage report with gcovr
gcovr_target ( NAME gcoverage HTML EXCLUDE ${EXCLUDES} )
# build xml (Cobertura) coverage report with gcovr
gcovr_target ( NAME gcoverage XML EXCLUDE ${EXCLUDES} )
# build xml (Sonarqube) coverage report with gcovr
gcovr_target ( NAME gcoverage SONAR EXCLUDE ${EXCLUDES} )
# build html and xml (both Coberture and Sonarqube) coverage report with gcovr
gcovr_target ( NAME gcoverage ALL EXCLUDE ${EXCLUDES} )
# build html report with lcov
list ( APPEND EXCLUDES src/OP2converter
src/vpmGraphExp src/vpmSolver/ResponsePos
${CMAKE_CURRENT_BINARY_DIR}/Admin )
lcov_html_target ( NAME lcoverage EXCLUDE ${EXCLUDES} /usr/include
EXECUTABLE ${CMAKE_CTEST_COMMAND} -j ${PROCESSOR_COUNT} )
endif ( LINUX )
# Generate source code documentation with doxygen, if available
find_program ( DOXYGEN "doxygen" )
if ( DOXYGEN )
message ( STATUS "Found Doxygen : ${DOXYGEN}" )
add_custom_target ( doc )
configure_file ( src/Doxyfile.solver Doxyfile.solver )
add_custom_target ( solver_doc
COMMAND ${DOXYGEN} ${PROJECT_BINARY_DIR}/Doxyfile.solver
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generating solver source code documentation"
VERBATIM )
add_dependencies ( doc solver_doc )
endif ( DOXYGEN )
# Process the sub-folders
set ( USE_FORTRAN true )
set ( SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/src" )
add_subdirectory ( fedem-foundation/src "${CMAKE_CURRENT_BINARY_DIR}/fedem-foundation" )
add_subdirectory ( SAM/src "${CMAKE_CURRENT_BINARY_DIR}/src/SAM" )
add_subdirectory ( src )
add_subdirectory ( PythonAPI )
# Install the Fortran redistributables
if ( WIN AND DEFINED ENV{IFORT_COMPILER23} )
file ( TO_CMAKE_PATH $ENV{IFORT_COMPILER23}redist/intel64_win/compiler IFORT_PATH )
file ( GLOB FTN_REDIST ${IFORT_PATH}/*md.dll )
if ( FTENV_VERBOSE )
message ( STATUS "Installing Fortran redistributables from ${IFORT_PATH} to ${CMAKE_INSTALL_PREFIX}" )
endif ( FTENV_VERBOSE )
install ( FILES ${FTN_REDIST} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
endif ( WIN AND DEFINED ENV{IFORT_COMPILER23} )
if ( WIN AND DEFINED ENV{MKLROOT} )
file ( TO_CMAKE_PATH $ENV{MKLROOT}/redist/intel64 MKL_PATH )
if ( FTENV_VERBOSE )
message ( STATUS "Installing MKL redistributables from ${MKL_PATH} to ${CMAKE_INSTALL_PREFIX}" )
endif ( FTENV_VERBOSE )
set ( MKL_REDIST ${MKL_PATH}/mkl_core.2.dll ${MKL_PATH}/mkl_def.2.dll
${MKL_PATH}/mkl_avx2.2.dll ${MKL_PATH}/mkl_vml_avx2.2.dll
${MKL_PATH}/mkl_avx512.2.dll ${MKL_PATH}/mkl_vml_avx512.2.dll
${MKL_PATH}/mkl_intel_thread.2.dll )
install ( FILES ${MKL_REDIST} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
endif ( WIN AND DEFINED ENV{MKLROOT} )