forked from SofaDefrost/Cosserat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (125 loc) · 5.67 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
cmake_minimum_required(VERSION 3.12)
project(CosseratPlugin VERSION 21.12.0)
include(cmake/environment.cmake)
find_package(SofaFramework REQUIRED)
sofa_find_package(SofaUserInteraction REQUIRED)
sofa_find_package(SofaBaseMechanics REQUIRED)
sofa_find_package(SofaConstraint REQUIRED)
sofa_find_package(SofaRigid REQUIRED)
sofa_find_package(SofaMiscMapping REQUIRED)
sofa_find_package(SofaEngine REQUIRED)
sofa_find_package(SofaSparseSolver REQUIRED)
sofa_find_package(SofaBaseLinearSolver REQUIRED)
sofa_find_package(Sofa.GL QUIET)
sofa_find_package(SofaBaseTopology REQUIRED)
sofa_find_package(STLIB QUIET)
if(STLIB_FOUND)
message("-- Found dependency : 'STLIB' plugin .")
else()
message("-- The highly recommended 'STLIB' plugin is missing. You can compile Cosserat but some of the provided python examples will not work. ")
endif()
set(SRC_ROOT_DIR src/${PROJECT_NAME})
set(HEADER_FILES
${SRC_ROOT_DIR}/config.h.in
${SRC_ROOT_DIR}/mapping/BaseCosserat.h
${SRC_ROOT_DIR}/mapping/BaseCosserat.inl
${SRC_ROOT_DIR}/mapping/DiscreteCosseratMapping.h
${SRC_ROOT_DIR}/mapping/DiscreteCosseratMapping.inl
${SRC_ROOT_DIR}/mapping/DiscreteDynamicCosseratMapping.h
${SRC_ROOT_DIR}/mapping/DiscreteDynamicCosseratMapping.inl
${SRC_ROOT_DIR}/mapping/ProjectionEngine.h
${SRC_ROOT_DIR}/mapping/ProjectionEngine.inl
${SRC_ROOT_DIR}/mapping/DifferenceMultiMapping.h
${SRC_ROOT_DIR}/mapping/DifferenceMultiMapping.inl
${SRC_ROOT_DIR}/mapping/RigidDistanceMapping.h
${SRC_ROOT_DIR}/mapping/RigidDistanceMapping.inl
${SRC_ROOT_DIR}/forcefield/BeamHookeLawForceField.h
${SRC_ROOT_DIR}/forcefield/BeamHookeLawForceField.inl
${SRC_ROOT_DIR}/forcefield/BeamPlasticLawForceField.h
${SRC_ROOT_DIR}/forcefield/BeamPlasticLawForceField.inl
${SRC_ROOT_DIR}/forcefield/CosseratInternalActuation.h
${SRC_ROOT_DIR}/forcefield/CosseratInternalActuation.inl
${SRC_ROOT_DIR}/constraint/CosseratSlidingConstraint.h
${SRC_ROOT_DIR}/constraint/CosseratSlidingConstraint.inl
${SRC_ROOT_DIR}/mapping/LegendrePolynomialsMapping.h
${SRC_ROOT_DIR}/mapping/LegendrePolynomialsMapping.inl
)
set(SOURCE_FILES
${SRC_ROOT_DIR}/initCosseratPlugin.cpp
${SRC_ROOT_DIR}/mapping/BaseCosserat.cpp
${SRC_ROOT_DIR}/mapping/DiscreteCosseratMapping.cpp
${SRC_ROOT_DIR}/mapping/DiscreteDynamicCosseratMapping.cpp
${SRC_ROOT_DIR}/mapping/ProjectionEngine.cpp
${SRC_ROOT_DIR}/mapping/DifferenceMultiMapping.cpp
${SRC_ROOT_DIR}/mapping/RigidDistanceMapping.cpp
${SRC_ROOT_DIR}/forcefield/BeamHookeLawForceField.cpp
${SRC_ROOT_DIR}/forcefield/BeamPlasticLawForceField.cpp
${SRC_ROOT_DIR}/forcefield/CosseratInternalActuation.cpp
${SRC_ROOT_DIR}/constraint/CosseratSlidingConstraint.cpp
${SRC_ROOT_DIR}/mapping/LegendrePolynomialsMapping.cpp
)
sofa_find_package(SoftRobots QUIET)
if(SoftRobots_FOUND)
list(APPEND HEADER_FILES
${SRC_ROOT_DIR}/constraint/CosseratActuatorConstraint.h
${SRC_ROOT_DIR}/constraint/CosseratActuatorConstraint.inl
# ${SRC_ROOT_DIR}/constraint/CosseratUnilateralInteractionConstraint.h
# ${SRC_ROOT_DIR}/constraint/CosseratUnilateralInteractionConstraint.inl
${SRC_ROOT_DIR}/constraint/CosseratNeedleSlidingConstraint.h
${SRC_ROOT_DIR}/constraint/CosseratNeedleSlidingConstraint.inl
${SRC_ROOT_DIR}/constraint/QPSlidingConstraint.h
${SRC_ROOT_DIR}/constraint/QPSlidingConstraint.inl
)
list(APPEND SOURCE_FILES
${SRC_ROOT_DIR}/constraint/CosseratActuatorConstraint.cpp
${SRC_ROOT_DIR}/constraint/CosseratNeedleSlidingConstraint.cpp
# ${SRC_ROOT_DIR}/constraint/CosseratUnilateralInteractionConstraint.cpp
${SRC_ROOT_DIR}/constraint/QPSlidingConstraint.cpp
)
endif()
file(GLOB_RECURSE RESOURCE_FILES "*.md" "*.psl" "*.py" "*.pyscn" "*.py3scn" "*.scn" "*.ah")
if(WIN32)
add_definitions(-D_WINSOCKAPI_)
endif()
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${DOC_FILES} ${RESOURCE_FILES} )
target_link_libraries(${PROJECT_NAME} Sofa.Helper SofaCore SofaConstraint SofaBaseMechanics SofaUserInteraction SofaRigid SofaMiscMapping SofaSparseSolver SofaEngine)
if(Sofa.GL_FOUND)
target_link_libraries(${PROJECT_NAME} Sofa.GL)
endif()
if(SoftRobots_FOUND)
target_link_libraries(${PROJECT_NAME} SoftRobots)
message("-- Found dependency: 'SoftRobots' plugin.")
endif()
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)
message("-- Python3 packages will be installed.")
set(SP3_PYTHON_PACKAGES_DIRECTORY "python3/site-packages")
SP3_add_python_package(
SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python3/cosserat
TARGET_DIRECTORY cosserat
)
endif()
## Install rules for the library and headers; CMake package configurations files
sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
PACKAGE_VERSION ${PROJECT_VERSION}
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
INCLUDE_SOURCE_DIR "src"
INCLUDE_INSTALL_DIR ${PROJECT_NAME}
RELOCATABLE "plugins"
)
# Tests
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
cmake_dependent_option(COSSERATPLUGIN_BUILD_TESTS "Compile the tests" OFF "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(COSSERATPLUGIN_BUILD_TESTS)
add_subdirectory(tests)
endif()
include(cmake/packaging.cmake)