Merge branch 'BuildPythonWindows' into 'master'
Build python windows Fixes a linker problem as well as issue #29. See merge request !89
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -66,29 +66,26 @@ struct Factory {
|
||||
};
|
||||
}
|
||||
|
||||
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))
|
||||
;
|
||||
}
|
||||
template<class Scalar>
|
||||
|
||||
template<class Scalar, class Vector>
|
||||
void defInitMod(class_< OpenMesh::VectorT<Scalar, 3> > &classVector) {
|
||||
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))
|
||||
#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("__mod__", cross)
|
||||
;
|
||||
def("cross", &Factory<Scalar>::Vector3::template operator%<Scalar>);
|
||||
#else
|
||||
.def("__mod__", &Factory<Scalar>::Vector3::operator%)
|
||||
;
|
||||
def("cross", &Factory<Scalar>::Vector3::operator%);
|
||||
#endif
|
||||
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))
|
||||
@@ -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,7 +184,7 @@ void expose_vec(const char *_name) {
|
||||
.staticmethod("vectorized")
|
||||
;
|
||||
|
||||
defInitMod<Scalar>(classVector);
|
||||
defInitMod<Scalar, Vector>(classVector);
|
||||
}
|
||||
|
||||
} // namespace OpenMesh
|
||||
|
||||
Reference in New Issue
Block a user