forked from SAP-archive/fedem-mdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
112 lines (91 loc) · 4.03 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
# 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 model database library.
################################################################################
cmake_minimum_required ( VERSION 2.8...3.5 )
# Project setup
set ( APPLICATION_ID fedemDB )
set ( DOMAIN_ID FEDEM )
set ( PACKAGE_ID MDB )
set ( LIB_ID FedemDB )
set ( LIB_ID_LIST Admin FFaLib FFlLib FFaFunctionLib FFaMathExpr
FiDeviceFunctions FiUserElmPlugin )
set ( USE_VISUALS ON ) # Visualization attribute classes must be included
option ( USE_FORTRAN "Build with Fortran code included" OFF )
option ( USE_CHSHAPE "Use ChainShape library for mooring line calculation" OFF )
option ( USE_QT "Use Qt file system handling" OFF )
option ( USE_MEMPOOL "Use memory pool for heap allocation in FE library" OFF )
option ( USE_PROFILER "Use CPU and Memory profiler" OFF )
mark_as_advanced ( USE_FORTRAN USE_CHSHAPE USE_QT USE_MEMPOOL USE_PROFILER )
if ( USE_FORTRAN)
project ( ${APPLICATION_ID} CXX C Fortran )
else ( USE_FORTRAN)
project ( ${APPLICATION_ID} CXX C )
endif ( USE_FORTRAN)
message ( STATUS "Generating build project for ${PROJECT_SOURCE_DIR}" )
get_filename_component ( PROJECT_PARENT_DIR "${PROJECT_SOURCE_DIR}" PATH )
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 )
# Enable unit- and regression testing
enable_testing ()
set ( CTEST_OPTIONS --force-new-ctest-process --output-on-failure -O CTest.txt )
if ( CMAKE_CONFIGURATION_TYPES )
list ( APPEND CTEST_OPTIONS --build-config \"$<CONFIGURATION>\" )
endif ( CMAKE_CONFIGURATION_TYPES )
add_custom_target ( check COMMAND ${CMAKE_CTEST_COMMAND} ${CTEST_OPTIONS} )
include ( GTest ) # Using the google test framework for C++ unit tests
if ( USE_FORTRAN )
include ( pFUnit ) # Using the pFUnit test framework for Fortran unit tests
endif ( USE_FORTRAN )
find_package ( PythonInterp 3 ) # Enforce using python3
# Library setup
# Include dependent libraries from fedem-foundation
include_directories ( "${PROJECT_SOURCE_DIR}/fedem-foundation/src" )
foreach ( FOLDER ${LIB_ID_LIST} )
add_subdirectory ( fedem-foundation/src/${FOLDER} "${CMAKE_CURRENT_BINARY_DIR}/${FOLDER}" )
endforeach ( FOLDER ${LIB_ID_LIST} )
if ( USE_FORTRAN AND USE_CHSHAPE )
add_subdirectory ( chainShape )
endif ( USE_FORTRAN AND USE_CHSHAPE )
# Exclude some targets from sub-projects that are not needed here
set_target_properties ( FFaOperation
PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1 )
# Include the main library
set ( NO_FATIGUE true )
string ( APPEND CMAKE_CXX_FLAGS_DEBUG " -DFM_DEBUG=${FT_DEBUG}" )
include_directories ( "${CMAKE_CURRENT_SOURCE_DIR}" )
add_subdirectory ( vpmDB )
# Build and install the shared library
message ( STATUS "Building shared library ${LIB_ID}" )
add_library ( ${LIB_ID} SHARED FedemDB.C )
target_link_libraries ( ${LIB_ID} vpmDB )
install ( TARGETS ${LIB_ID}
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
# Perform the unit- and regression tests
if ( GTest_FOUND )
add_subdirectory ( test )
endif ( GTest_FOUND )
if ( TARGET ChainShape )
add_subdirectory ( test/chainShape )
endif ( TARGET ChainShape )
set ( PYTHON_DIR "${PROJECT_PARENT_DIR}/fedem-solvers/PythonAPI/src" )
if ( PythonInterp_FOUND AND IS_DIRECTORY "${PYTHON_DIR}" )
add_subdirectory ( test/fedempy )
endif ( PythonInterp_FOUND AND IS_DIRECTORY "${PYTHON_DIR}" )