forked from SofaDefrost/ModelOrderReduction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
155 lines (130 loc) · 6.42 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
cmake_minimum_required(VERSION 3.12)
project(ModelOrderReduction VERSION 1.0)
include(CMakeDependentOption)
include(cmake/environment.cmake)
# Specify all required packages
find_package(Sofa.Core REQUIRED)
sofa_find_package(Sofa.Component.Collision.Response.Contact REQUIRED)
sofa_find_package(Sofa.Component.Mapping.MappedMatrix REQUIRED)
sofa_find_package(Sofa.Component.SolidMechanics.FEM.HyperElastic REQUIRED)
sofa_find_package(Sofa.Component.SolidMechanics.FEM.Elastic REQUIRED)
sofa_find_package(Sofa.GL REQUIRED)
sofa_find_package(CollisionOBBCapsule QUIET)
if (NOT CollisionOBBCapsule_FOUND)
message(WARNING "The package CollisionOBBCapsule has not been found. It is required to compile all the features of ${PROJECT_NAME}")
endif()
option(USE_COMPRESSED_ROW_SPARSE "Use compressed row sparse format in the mappings" ON)
set(MOR_SRC "src/ModelOrderReduction")
set(HEADER_FILES
${MOR_SRC}/config.h.in
${MOR_SRC}/component/forcefield/HyperReducedHelper.h
${MOR_SRC}/component/forcefield/HyperReducedHexahedronFEMForceField.h
${MOR_SRC}/component/forcefield/HyperReducedHexahedronFEMForceField.inl
${MOR_SRC}/component/forcefield/HyperReducedRestShapeSpringsForceField.h
${MOR_SRC}/component/forcefield/HyperReducedRestShapeSpringsForceField.inl
${MOR_SRC}/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.h
${MOR_SRC}/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.inl
${MOR_SRC}/component/forcefield/HyperReducedTetrahedronFEMForceField.h
${MOR_SRC}/component/forcefield/HyperReducedTetrahedronFEMForceField.inl
${MOR_SRC}/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.h
${MOR_SRC}/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.inl
${MOR_SRC}/component/forcefield/HyperReducedTriangleFEMForceField.h
${MOR_SRC}/component/forcefield/HyperReducedTriangleFEMForceField.inl
${MOR_SRC}/component/loader/MatrixLoader.h
${MOR_SRC}/component/loader/MatrixLoader.inl
${MOR_SRC}/component/mapping/ModelOrderReductionMapping.h
${MOR_SRC}/component/mapping/ModelOrderReductionMapping.inl
${MOR_SRC}/component/mapping/MORContactMapping.h
${MOR_SRC}/component/mapping/MORContactMapping.inl
${MOR_SRC}/component/contact/MORFrictionContact.h
${MOR_SRC}/component/contact/MORFrictionContact.inl
${MOR_SRC}/component/contact/MORUnilateralInteractionConstraint.h
${MOR_SRC}/component/contact/MORUnilateralInteractionConstraint.inl
${MOR_SRC}/component/contact/MORpointModel.h
${MOR_SRC}/component/contact/MORpointModel.inl
)
set(SOURCE_FILES
${MOR_SRC}/initModelOrderReduction.cpp
${MOR_SRC}/component/forcefield/HyperReducedHelper.cpp
${MOR_SRC}/component/forcefield/HyperReducedHexahedronFEMForceField.cpp
${MOR_SRC}/component/forcefield/HyperReducedRestShapeSpringsForceField.cpp
${MOR_SRC}/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.cpp
${MOR_SRC}/component/forcefield/HyperReducedTetrahedronFEMForceField.cpp
${MOR_SRC}/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.cpp
${MOR_SRC}/component/forcefield/HyperReducedTriangleFEMForceField.cpp
${MOR_SRC}/component/loader/MatrixLoader.cpp
${MOR_SRC}/component/mapping/ModelOrderReductionMapping.cpp
${MOR_SRC}/component/mapping/MORContactMapping.cpp
${MOR_SRC}/component/contact/MORFrictionContact.cpp
${MOR_SRC}/component/contact/MORUnilateralInteractionConstraint.cpp
${MOR_SRC}/component/contact/MORpointModel.cpp
)
set(README_FILES
README.md
)
if (CollisionOBBCapsule_FOUND)
list(APPEND SOURCE_FILES ${MOR_SRC}/component/contact/MORFrictionContact[OBBCapsule].cpp)
endif()
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${README_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-DSOFA_BUILD_MODELORDERREDUCTION")
target_link_libraries(${PROJECT_NAME}
Sofa.Core
Sofa.Component.Collision.Response.Contact
Sofa.Component.Mapping.MappedMatrix
Sofa.Component.SolidMechanics.FEM.HyperElastic
Sofa.Component.SolidMechanics.FEM.Elastic
Sofa.GL
)
if (CollisionOBBCapsule_FOUND)
target_link_libraries(${PROJECT_NAME} CollisionOBBCapsule)
endif()
# Config files and install rules for pythons scripts
sofa_install_pythonscripts(PLUGIN_NAME ${PROJECT_NAME} PYTHONSCRIPTS_SOURCE_DIR "python")
find_file(SofaPython3Tools NAMES "SofaPython3/lib/cmake/SofaPython3/SofaPython3Tools.cmake")
if(SofaPython3Tools)
message("-- Found SofaPython3Tools.")
include(${SofaPython3Tools})
else()
# try again with the find_package mechanism
find_package(SofaPython3 QUIET)
endif()
if(SofaPython3Tools OR SofaPython3_FOUND)
if(NOT SP3_PYTHON_PACKAGES_DIRECTORY)
set(SP3_PYTHON_PACKAGES_DIRECTORY "python3/site-packages")
endif()
message("-- Python3 packages will be installed in: ${SP3_PYTHON_PACKAGES_DIRECTORY}.")
SP3_add_python_package(
SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/mor
TARGET_DIRECTORY mor
)
SP3_add_python_package(
SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/morlib
TARGET_DIRECTORY morlib
)
endif()
# Move all resources when install: examples, doc and python files
install(FILES "README.md" "LICENSE" DESTINATION .)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doc")
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/ModelOrderReduction.pdf DESTINATION doc COMPONENT resources)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doc/examples")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/examples DESTINATION . COMPONENT resources)
endif()
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tools")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools DESTINATION . COMPONENT resources)
endif()
## Install rules for the library and headers; CMake package configurations files
sofa_create_package_with_targets(
PACKAGE_NAME ModelOrderReduction
PACKAGE_VERSION ${PROJECT_VERSION}
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
INCLUDE_SOURCE_DIR "src"
INCLUDE_INSTALL_DIR "ModelOrderReduction"
RELOCATABLE "plugins"
)
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
cmake_dependent_option(MODELORDERREDUCTION_BUILD_TESTS "Compile the tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(MODELORDERREDUCTION_BUILD_TESTS)
add_subdirectory(ModelOrderReduction_test)
endif()
include(cmake/packaging.cmake)