-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
79 lines (69 loc) · 2.76 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
cmake_minimum_required(VERSION 3.12)
project(PluginExample VERSION 1.0 LANGUAGES CXX)
# Find and load CMake configuration of packages containing this plugin's dependencies
## Mandatory dependencies
find_package(Sofa.Component.Visual REQUIRED) # Needed for VisualModelImpl
## Optional dependencies
sofa_find_package(Sofa.GUI.Qt)
sofa_find_package(Qt5 COMPONENTS Core) # Dependency to Qt5Core (needed for qt5_wrap_cpp)
# List all files
set(PLUGINEXAMPLE_SRC_DIR src/PluginExample)
set(HEADER_FILES
${PLUGINEXAMPLE_SRC_DIR}/config.h.in
${PLUGINEXAMPLE_SRC_DIR}/MyBehaviorModel.h
${PLUGINEXAMPLE_SRC_DIR}/MyVisualModel.h
${PLUGINEXAMPLE_SRC_DIR}/MyMappingPendulumInPlane.h
${PLUGINEXAMPLE_SRC_DIR}/MyMappingPendulumInPlane.inl
${PLUGINEXAMPLE_SRC_DIR}/MyProjectiveConstraintSet.h
${PLUGINEXAMPLE_SRC_DIR}/MyProjectiveConstraintSet.inl
)
set(HEADER_FILES_TO_MOC
)
set(SOURCE_FILES
${PLUGINEXAMPLE_SRC_DIR}/initPluginExample.cpp
${PLUGINEXAMPLE_SRC_DIR}/MyBehaviorModel.cpp
${PLUGINEXAMPLE_SRC_DIR}/MyVisualModel.cpp
${PLUGINEXAMPLE_SRC_DIR}/MyMappingPendulumInPlane.cpp
${PLUGINEXAMPLE_SRC_DIR}/MyProjectiveConstraintSet.cpp
)
set(README_FILES
README.md
)
if(Qt5Core_FOUND AND Sofa.GUI.Qt_FOUND)
message(STATUS "GUI components have been detected, enable GUI-related components")
list(APPEND HEADER_FILES_TO_MOC
${PLUGINEXAMPLE_SRC_DIR}/MyDataWidgetUnsigned.h
)
list(APPEND SOURCE_FILES
${PLUGINEXAMPLE_SRC_DIR}/MyDataWidgetUnsigned.cpp
)
# [Qt] Create moc code.
qt5_wrap_cpp(MOCCED_HEADER_FILES ${HEADER_FILES_TO_MOC})
endif()
# Create the plugin library.
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES_TO_MOC} ${MOCCED_HEADER_FILES} ${HEADER_FILES} ${SOURCE_FILES} ${README_FILES})
# Link the plugin library to its dependency(ies).
target_link_libraries(${PROJECT_NAME} Sofa.Component.Visual)
# Link with the optional GUI dependencies.
if(Qt5Core_FOUND AND Sofa.GUI.Qt_FOUND)
target_link_libraries(${PROJECT_NAME} Sofa.GUI.Qt)
endif()
# Create package Config, Version & Target files.
# Deploy the headers, resources, scenes & examples.
# Set the plugin 'relocatable' if built within SOFA.
# --> see SofaMacros.cmake
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(PLUGINEXAMPLE_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(PLUGINEXAMPLE_BUILD_TESTS)
enable_testing()
add_subdirectory(PluginExample_test)
endif()