Skip to content

Commit 84946dd

Browse files
committed
[cmake] List headers and sources in CMakeLists, drop glob and load sofa/config in init*.cpp
1 parent 6f4d1cc commit 84946dd

File tree

3 files changed

+77
-24
lines changed

3 files changed

+77
-24
lines changed

CMakeLists.txt

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,66 @@
11
cmake_minimum_required(VERSION 3.12)
22
project(ConstraintGeometry VERSION 0.1 LANGUAGES CXX)
33

4-
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
5-
6-
file(GLOB_RECURSE HEADER_FILES "src/*.h" "src/*.inl")
7-
file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")
8-
file(GLOB_RECURSE SCENES_FILES "scenes/*.scn" "*.xml")
9-
file(GLOB_RECURSE IGNORED_FILES "ignored/*.h" "ignored/*.inl" "ignored/*.cpp")
10-
file(GLOB_RECURSE DEPRECATED_FILES "deprecated/*.h" "deprecated/*.inl" "deprecated/*.cpp")
11-
124
find_package(CollisionAlgorithm REQUIRED)
135
find_package(Sofa.Component.StateContainer REQUIRED)
146
find_package(Sofa.Component.Constraint.Lagrangian.Solver REQUIRED)
157
find_package(Sofa.GL REQUIRED)
168

17-
#include_directories("${CMAKE_CURRENT_SOURCE_DIR}/ignored")
18-
#include_directories("${CMAKE_CURRENT_SOURCE_DIR}/deprecated")
9+
set(CONSTRAINTGEOMETRY_SRC "src/${PROJECT_NAME}")
10+
11+
set(HEADER_FILES
12+
${CONSTRAINTGEOMETRY_SRC}/config.h.in
13+
${CONSTRAINTGEOMETRY_SRC}/initConstraintGeometry.h
14+
15+
${CONSTRAINTGEOMETRY_SRC}/BaseConstraint.h
16+
${CONSTRAINTGEOMETRY_SRC}/BaseNormalHandler.h
17+
${CONSTRAINTGEOMETRY_SRC}/ConstraintDirection.h
18+
${CONSTRAINTGEOMETRY_SRC}/ConstraintNormal.h
19+
${CONSTRAINTGEOMETRY_SRC}/ConstraintProximity.h
20+
${CONSTRAINTGEOMETRY_SRC}/ConstraintResponse.h
21+
${CONSTRAINTGEOMETRY_SRC}/InternalConstraint.h
22+
23+
${CONSTRAINTGEOMETRY_SRC}/constraint/BilateralResolution.h
24+
${CONSTRAINTGEOMETRY_SRC}/constraint/ConstraintBilateral.h
25+
${CONSTRAINTGEOMETRY_SRC}/constraint/ConstraintInsertion.h
26+
${CONSTRAINTGEOMETRY_SRC}/constraint/ConstraintUnilateral.h
27+
${CONSTRAINTGEOMETRY_SRC}/constraint/InsertionResolution.h
28+
${CONSTRAINTGEOMETRY_SRC}/constraint/UnilateralResolution.h
29+
30+
${CONSTRAINTGEOMETRY_SRC}/directions/BindDirection.h
31+
${CONSTRAINTGEOMETRY_SRC}/directions/ContactDirection.h
32+
${CONSTRAINTGEOMETRY_SRC}/directions/FirstDirection.h
33+
${CONSTRAINTGEOMETRY_SRC}/directions/FixedFrameDirection.h
34+
${CONSTRAINTGEOMETRY_SRC}/directions/SecondDirection.h
35+
36+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/EdgeNormalHandler.h
37+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/GouraudTriangleNormalHandler.h
38+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/GravityPointNormalHandler.h
39+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/PhongTriangleNormalHandler.h
40+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/VectorPointNormalHandler.h
1941

20-
set_source_files_properties(${IGNORED_FILES} PROPERTIES HEADER_FILE_ONLY TRUE)
42+
${CONSTRAINTGEOMETRY_SRC}/operations/ConstraintProximityOperation.h
43+
)
44+
45+
set(SOURCE_FILES
46+
${CONSTRAINTGEOMETRY_SRC}/initConstraintGeometry.cpp
47+
48+
${CONSTRAINTGEOMETRY_SRC}/constraint/ConstraintInsertion.cpp
49+
${CONSTRAINTGEOMETRY_SRC}/constraint/ConstraintBilateral.cpp
50+
${CONSTRAINTGEOMETRY_SRC}/constraint/ConstraintUnilateral.cpp
51+
52+
${CONSTRAINTGEOMETRY_SRC}/directions/BindDirection.cpp
53+
${CONSTRAINTGEOMETRY_SRC}/directions/ContactDirection.cpp
54+
${CONSTRAINTGEOMETRY_SRC}/directions/FirstDirection.cpp
55+
${CONSTRAINTGEOMETRY_SRC}/directions/FixedFrameDirection.cpp
56+
${CONSTRAINTGEOMETRY_SRC}/directions/SecondDirection.cpp
57+
58+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/EdgeNormalHandler.cpp
59+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/GouraudTriangleNormalHandler.cpp
60+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/GravityPointNormalHandler.cpp
61+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/PhongTriangleNormalHandler.cpp
62+
${CONSTRAINTGEOMETRY_SRC}/normalHandler/VectorPointNormalHandler.cpp
63+
)
2164

2265
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${HEADER_FILES} ${README_FILES})
2366

@@ -34,4 +77,6 @@ sofa_create_package_with_targets(
3477
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
3578
INCLUDE_SOURCE_DIR "src"
3679
INCLUDE_INSTALL_DIR ${PROJECT_NAME}
80+
EXAMPLE_INSTALL_DIR "scenes"
81+
RELOCATABLE "plugins"
3782
)

src/ConstraintGeometry/initPlugin.cpp renamed to src/ConstraintGeometry/initConstraintGeometry.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <ConstraintGeometry/initConstraintGeometry.h>
2+
13
#include <sofa/core/ObjectFactory.h>
24
#include <sofa/helper/system/FileRepository.h>
35
#include <sofa/helper/system/PluginManager.h>
@@ -29,25 +31,25 @@ extern void registerGouraudTriangleNormalHandler(sofa::core::ObjectFactory* fact
2931
extern void registerGravityPointNormalHandler(sofa::core::ObjectFactory* factory);
3032
extern void registerPhongTriangleNormalHandler(sofa::core::ObjectFactory* factory);
3133
extern void registerVectorPointNormalHandler(sofa::core::ObjectFactory* factory);
32-
} // namespace sofa::constraintgeometry
3334

34-
namespace sofa::component
35-
{
3635
extern "C"
3736
{
38-
void initExternalModule();
39-
const char* getModuleName();
40-
const char* getModuleVersion();
41-
const char* getModuleLicense();
42-
const char* getModuleDescription();
43-
void registerObjects(sofa::core::ObjectFactory* factory);
37+
SOFA_CONSTRAINTGEOMETRY_API void initExternalModule();
38+
SOFA_CONSTRAINTGEOMETRY_API const char* getModuleName();
39+
SOFA_CONSTRAINTGEOMETRY_API const char* getModuleVersion();
40+
SOFA_CONSTRAINTGEOMETRY_API const char* getModuleLicense();
41+
SOFA_CONSTRAINTGEOMETRY_API const char* getModuleDescription();
42+
SOFA_CONSTRAINTGEOMETRY_API void registerObjects(sofa::core::ObjectFactory* factory);
4443
}
4544

4645
void initConstraintGeometry()
4746
{
4847
static bool first = true;
4948
if (first)
5049
{
50+
// make sure that this plugin is registered into the PluginManager
51+
sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME);
52+
5153
first = false;
5254
#ifdef PLUGIN_DATA_DIR
5355
sofa::helper::system::DataRepository.addLastPath(std::string(QUOTE(PLUGIN_DATA_DIR)));
@@ -62,7 +64,7 @@ void initExternalModule()
6264
initConstraintGeometry();
6365
}
6466

65-
const char* getModuleName() { return "ConstraintGeometry"; }
67+
const char* getModuleName() { return MODULE_NAME; }
6668

6769
const char* getModuleVersion()
6870
{
@@ -75,11 +77,10 @@ const char* getModuleVersion()
7577

7678
const char* getModuleLicense() { return "LGPL"; }
7779

78-
const char* getModuleDescription() { return "Plugin to hendle constraints"; }
80+
const char* getModuleDescription() { return "Plugin to handle constraints"; }
7981

8082
void registerObjects(sofa::core::ObjectFactory* factory)
8183
{
82-
using namespace sofa::constraintgeometry;
8384
// Constraints
8485
registerConstraintUnilateral(factory);
8586
registerConstraintBilateral(factory);
@@ -100,4 +101,4 @@ void registerObjects(sofa::core::ObjectFactory* factory)
100101
registerVectorPointNormalHandler(factory);
101102
}
102103

103-
} // namespace sofa::component
104+
} // namespace sofa::constraintgeometry
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
#include <ConstraintGeometry/config.h>
3+
4+
namespace sofa::constraintgeometry
5+
{
6+
void SOFA_CONSTRAINTGEOMETRY_API initConstraintGeometry();
7+
} // namespace sofa::constraintgeometry

0 commit comments

Comments
 (0)