Skip to content

Commit 70fab1e

Browse files
FIX PYBIND11_SOFA_VERSION (#249)
* remove patch version to handle any pybind11 revision * FIX patch by parsing version with CMake * FIX patch by parsing version with CMake (2) * Update CMakeLists.txt * FIX config.h not found Co-authored-by: Guillaume Paran <guillaume.paran@sofa-framework.org>
1 parent 98c8cb2 commit 70fab1e

7 files changed

Lines changed: 16 additions & 9 deletions

File tree

Plugin/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project(Plugin VERSION 1.0)
22

33
set(HEADER_FILES
4-
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaPython3/config.h
4+
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaPython3/config.h.in
55
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaPython3/initModule.h
66
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaPython3/PythonEnvironment.h
77
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaPython3/SceneLoaderPY3.h
@@ -81,6 +81,8 @@ set_target_properties(
8181
CUDA_VISIBILITY_PRESET "hidden"
8282
)
8383

84+
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>")
85+
8486
sofa_create_component_in_package_with_targets(
8587
COMPONENT_NAME ${PROJECT_NAME}
8688
COMPONENT_VERSION ${SofaPython3_VERSION}

Plugin/src/SofaPython3/DataCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#pragma once
2222

2323
#include <pybind11/numpy.h>
24-
#include "config.h"
24+
#include <SofaPython3/config.h>
2525

2626
////////////////////////// FORWARD DECLARATION ///////////////////////////
2727
namespace sofa {

Plugin/src/SofaPython3/PythonEnvironment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include <pybind11/pybind11.h>
4545
#include <pybind11/eval.h>
4646

47-
#include "config.h"
47+
#include <SofaPython3/config.h>
4848

4949
namespace sofapython3
5050
{

Plugin/src/SofaPython3/PythonFactory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <sofa/core/objectmodel/Base.h>
2626
#include <sofa/core/objectmodel/Event.h>
2727
#include <pybind11/pybind11.h>
28-
#include "config.h"
28+
#include <SofaPython3/config.h>
2929

3030
/////////////////////////////// DECLARATION //////////////////////////////
3131
namespace sofapython3

Plugin/src/SofaPython3/SceneLoaderPY3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <sofa/simulation/Visitor.h>
2828
#include <sofa/simulation/Node.h>
2929

30-
#include "config.h"
30+
#include <SofaPython3/config.h>
3131

3232
namespace sofapython3
3333
{
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@
4040
#endif
4141

4242
// define own pybind version macro, much easier to test/read
43-
#define PYBIND11_SOFA_VERSION (PYBIND11_VERSION_MAJOR * 10000 \
44-
+ PYBIND11_VERSION_MINOR * 100 \
45-
+ PYBIND11_VERSION_PATCH)
43+
#define PYBIND11_SOFA_VERSION_MAJOR @pybind11_VERSION_MAJOR@
44+
#define PYBIND11_SOFA_VERSION_MINOR @pybind11_VERSION_MINOR@
45+
#define PYBIND11_SOFA_VERSION_PATCH @pybind11_VERSION_PATCH@
46+
#define PYBIND11_SOFA_VERSION ( \
47+
PYBIND11_SOFA_VERSION_MAJOR * 10000 \
48+
+ PYBIND11_SOFA_VERSION_MINOR * 100 \
49+
+ PYBIND11_SOFA_VERSION_PATCH )
50+
4651
// pybind11 already bind the attributeError starting from 2.8.1 version.
4752
// so if the version is >= 2.8.1, macro does nothing, otherwise bind attribute_error
4853
#if PYBIND11_SOFA_VERSION >= 20801

Plugin/src/SofaPython3/initModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Contact information: contact@sofa-framework.org *
1919
******************************************************************************/
2020

21-
#include "config.h"
21+
#include <SofaPython3/config.h>
2222

2323
#include "PythonEnvironment.h"
2424
using sofapython3::PythonEnvironment;

0 commit comments

Comments
 (0)