Commit 90a75f0f authored by Jan Möbius's avatar Jan Möbius

Merge branch 'BuildPythonWindows' into 'master'

Build python windows

Fixes a linker problem as well as issue #29.

See merge request !89
parents 4f209d9f 8dc194e8
Pipeline #2811 passed with stage
in 21 minutes and 27 seconds
......@@ -11,6 +11,10 @@ IF(NOT DEFINED OPENMESH_PYTHON_VERSION)
ENDIF()
IF(OPENMESH_BUILD_PYTHON_BINDINGS)
# Create log file
SET(PYTHONLOG "${CMAKE_CURRENT_BINARY_DIR}/PythonLog.txt")
FILE(WRITE ${PYTHONLOG} "")
# Look for the python libs
MESSAGE(STATUS "Looking for PythonLibs")
FIND_PACKAGE(PythonLibs ${OPENMESH_PYTHON_VERSION} QUIET)
......@@ -29,13 +33,15 @@ IF(OPENMESH_BUILD_PYTHON_BINDINGS)
FOREACH(NAME ${BOOST_PYTHON_COMPONENT_NAMES})
IF(NOT Boost_FOUND)
FILE(APPEND ${PYTHONLOG} "Looking for component ${NAME}\n")
FIND_PACKAGE(Boost QUIET COMPONENTS ${NAME})
ENDIF()
ENDFOREACH()
FILE(APPEND ${PYTHONLOG} "\n")
IF(Boost_FOUND)
MESSAGE(STATUS "Looking for Boost Python -- found")
MESSAGE(STATUS "Checking the Boost Python configuration")
SET(CMAKE_TRY_COMPILE_CONFIGURATION "Release")
......@@ -47,9 +53,16 @@ IF(OPENMESH_BUILD_PYTHON_BINDINGS)
Example
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES:STRING=${PYTHON_INCLUDE_DIRS};${Boost_INCLUDE_DIRS}"
"-DLINK_DIRECTORIES:STRING=${Boost_LIBRARY_DIRS}"
"-DLINK_LIBRARIES:STRING=${PYTHON_LIBRARIES};${Boost_LIBRARIES}"
OUTPUT_VARIABLE OUTPUT_TRY_COMPILE
)
FILE(APPEND ${PYTHONLOG} "INCLUDE_DIRECTORIES: ${PYTHON_INCLUDE_DIRS};${Boost_INCLUDE_DIRS}\n")
FILE(APPEND ${PYTHONLOG} "LINK_DIRECTORIES: ${Boost_LIBRARY_DIRS}\n")
FILE(APPEND ${PYTHONLOG} "LINK_LIBRARIES: ${PYTHON_LIBRARIES};${Boost_LIBRARIES}\n\n")
FILE(APPEND ${PYTHONLOG} "${OUTPUT_TRY_COMPILE}")
IF(COMPILE_WORKS)
# Look for the python interpreter to check if the example works
......@@ -88,12 +101,14 @@ IF(OPENMESH_BUILD_PYTHON_BINDINGS)
FILE(MAKE_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
FILE(GLOB SOURCES *.cc *hh)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ../)
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
ADD_LIBRARY(openmesh SHARED ${SOURCES})
install(TARGETS openmesh DESTINATION ${ACG_PROJECT_LIBDIR}/python )
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ../)
TARGET_LINK_LIBRARIES(
openmesh
OpenMeshCore
......
......@@ -3,10 +3,10 @@ PROJECT(Example)
FILE(GLOB SOURCES *.cc *hh)
ADD_LIBRARY(example SHARED ${SOURCES})
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})
LINK_DIRECTORIES(${LINK_DIRECTORIES})
ADD_LIBRARY(example SHARED ${SOURCES})
TARGET_LINK_LIBRARIES(example ${LINK_LIBRARIES})
SET_TARGET_PROPERTIES(
......
......@@ -41,59 +41,56 @@ Scalar get_item(Vector& _vec, int _index) {
namespace {
template<class Scalar>
struct Factory {
typedef OpenMesh::VectorT<Scalar, 2> Vector2;
typedef OpenMesh::VectorT<Scalar, 3> Vector3;
typedef OpenMesh::VectorT<Scalar, 4> Vector4;
static Vector2 *vec2_default() {
return new Vector2(Scalar(), Scalar());
}
static Vector2 *vec2_user_defined(const Scalar& _v0, const Scalar& _v1) {
return new Vector2(_v0, _v1);
}
static Vector3 *vec3_default() {
return new Vector3(Scalar(), Scalar(), Scalar());
}
static Vector3 *vec3_user_defined(const Scalar& _v0, const Scalar& _v1, const Scalar& _v2) {
return new Vector3(_v0, _v1, _v2);
}
static Vector4 *vec4_default() {
return new Vector4(Scalar(), Scalar(), Scalar(), Scalar());
}
static Vector4 *vec4_user_defined(const Scalar& _v0, const Scalar& _v1, const Scalar& _v2, const Scalar& _v3) {
return new Vector4(_v0, _v1, _v2, _v3);
}
typedef OpenMesh::VectorT<Scalar, 2> Vector2;
typedef OpenMesh::VectorT<Scalar, 3> Vector3;
typedef OpenMesh::VectorT<Scalar, 4> Vector4;
static Vector2 *vec2_default() {
return new Vector2(Scalar(), Scalar());
}
static Vector2 *vec2_user_defined(const Scalar& _v0, const Scalar& _v1) {
return new Vector2(_v0, _v1);
}
static Vector3 *vec3_default() {
return new Vector3(Scalar(), Scalar(), Scalar());
}
static Vector3 *vec3_user_defined(const Scalar& _v0, const Scalar& _v1, const Scalar& _v2) {
return new Vector3(_v0, _v1, _v2);
}
static Vector4 *vec4_default() {
return new Vector4(Scalar(), Scalar(), Scalar(), Scalar());
}
static Vector4 *vec4_user_defined(const Scalar& _v0, const Scalar& _v1, const Scalar& _v2, const Scalar& _v3) {
return new Vector4(_v0, _v1, _v2, _v3);
}
};
}
template<class Scalar>
template<class Scalar, class Vector>
void defInitMod(class_< OpenMesh::VectorT<Scalar, 2> > &classVector) {
classVector
.def("__init__", make_constructor(&Factory<Scalar>::vec2_default))
.def("__init__", make_constructor(&Factory<Scalar>::vec2_user_defined))
;
classVector
.def("__init__", make_constructor(&Factory<Scalar>::vec2_default))
.def("__init__", make_constructor(&Factory<Scalar>::vec2_user_defined))
;
}
template<class Scalar>
template<class Scalar, class Vector>
void defInitMod(class_< OpenMesh::VectorT<Scalar, 3> > &classVector) {
classVector
.def("__init__", make_constructor(&Factory<Scalar>::vec3_default))
.def("__init__", make_constructor(&Factory<Scalar>::vec3_user_defined))
#if ((defined(_MSC_VER) && (_MSC_VER >= 1900)) || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY)
.def("__mod__", &Factory<Scalar>::Vector3::template operator%<Scalar>)
;
def("cross", &Factory<Scalar>::Vector3::template operator%<Scalar>);
#else
.def("__mod__", &Factory<Scalar>::Vector3::operator%)
;
def("cross", &Factory<Scalar>::Vector3::operator%);
#endif
Vector (Vector::*cross)(const Vector&) const = &Vector::operator%;
classVector
.def("__init__", make_constructor(&Factory<Scalar>::vec3_default))
.def("__init__", make_constructor(&Factory<Scalar>::vec3_user_defined))
.def("__mod__", cross)
;
def("cross", cross);
}
template<class Scalar>
template<class Scalar, class Vector>
void defInitMod(class_< OpenMesh::VectorT<Scalar, 4> > &classVector) {
classVector
.def("__init__", make_constructor(&Factory<Scalar>::vec4_default))
.def("__init__", make_constructor(&Factory<Scalar>::vec4_user_defined))
;
classVector
.def("__init__", make_constructor(&Factory<Scalar>::vec4_default))
.def("__init__", make_constructor(&Factory<Scalar>::vec4_user_defined))
;
}
/**
......@@ -119,6 +116,19 @@ void expose_vec(const char *_name) {
Vector (Vector::*max_vector)(const Vector&) const = &Vector::max;
Vector (Vector::*min_vector)(const Vector&) const = &Vector::min;
Scalar (Vector::*dot )(const Vector&) const = &Vector::operator|;
Scalar (Vector::*norm )(void ) const = &Vector::norm;
Scalar (Vector::*length )(void ) const = &Vector::length;
Scalar (Vector::*sqrnorm )(void ) const = &Vector::sqrnorm;
Vector& (Vector::*normalize )(void ) = &Vector::normalize;
Vector& (Vector::*normalize_cond)(void ) = &Vector::normalize_cond;
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY)
Vector (Vector::*normalized)() const = &Vector::normalized;
#else
const Vector (Vector::*normalized)() const = &Vector::normalized;
#endif
class_<Vector> classVector = class_<Vector>(_name);
classVector
......@@ -144,23 +154,13 @@ void expose_vec(const char *_name) {
.def("vectorize", &Vector::vectorize, return_internal_reference<>())
.def(self < self)
#if ((defined(_MSC_VER) && (_MSC_VER >= 1900)) || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY)
.def("dot", &Vector::template operator|<Scalar>)
.def("norm", &Vector::template norm<Scalar>)
.def("length", &Vector::template length<Scalar>)
.def("sqrnorm", &Vector::template sqrnorm<Scalar>)
.def("normalize", &Vector::template normalize<Scalar>, return_internal_reference<>())
.def("normalized", &Vector::template normalized<Scalar>)
.def("normalize_cond", &Vector::template normalize_cond<Scalar>, return_internal_reference<>())
#else
.def("dot", &Vector::operator|)
.def("norm", &Vector::norm)
.def("length", &Vector::length)
.def("sqrnorm", &Vector::sqrnorm)
.def("normalize", &Vector::normalize, return_internal_reference<>())
.def("normalized", &Vector::normalized)
.def("normalize_cond", &Vector::normalize_cond, return_internal_reference<>())
#endif
.def("dot", dot)
.def("norm", norm)
.def("length", length)
.def("sqrnorm", sqrnorm)
.def("normalized", normalized)
.def("normalize", normalize, return_internal_reference<>())
.def("normalize_cond", normalize_cond, return_internal_reference<>())
.def("l1_norm", &Vector::l1_norm)
.def("l8_norm", &Vector::l8_norm)
......@@ -184,10 +184,10 @@ void expose_vec(const char *_name) {
.staticmethod("vectorized")
;
defInitMod<Scalar>(classVector);
defInitMod<Scalar, Vector>(classVector);
}
} // namespace OpenMesh
} // namespace Python
#endif
#endif
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment