0000964: Patch to allow use of external PyCXX

This commit is contained in:
wmayer 2013-07-13 16:25:16 +02:00
parent a81639afe1
commit 3e5168a0c1
3 changed files with 122 additions and 15 deletions

View File

@ -71,6 +71,13 @@ endif(WIN32)
SET(CMAKE_INSTALL_DATADIR data CACHE PATH "Output directory for data and resource files")
SET(CMAKE_INSTALL_INCLUDEDIR include CACHE PATH "Output directory for header files")
SET(CMAKE_INSTALL_DOCDIR doc CACHE PATH "Output directory for documentation and license files")
SET(PYCXX_INCLUDE_DIR
"${CMAKE_CURRENT_LIST_DIR}/src" CACHE PATH
"Path to the directory containing PyCXX's CXX/Config.hxx include file")
SET(PYCXX_SOURCE_DIR
"${CMAKE_CURRENT_LIST_DIR}/src/CXX" CACHE PATH
"Path to the directory containing PyCXX's cxxextensions.c source file")
# used as compiler defines
SET(RESOURCEDIR "${CMAKE_INSTALL_DATADIR}")
@ -203,6 +210,10 @@ MARK_AS_ADVANCED(FORCE FREECAD_LIBPACK_CHECKFILE6X FREECAD_LIBPACK_CHECKFILE7X)
# -------------------------------- ZLIB --------------------------------
find_package(ZLIB REQUIRED)
# -------------------------------- PyCXX --------------------------------
find_package(PyCXX REQUIRED)
# -------------------------------- OpenCasCade --------------------------------

108
cMake/FindPyCXX.cmake Normal file
View File

@ -0,0 +1,108 @@
# Locate PyCXX headers and source files
# This module defines
# PYCXX_INCLUDE_DIR
# PYCXX_SOURCE_DIR
# PYCXX_FOUND
# PYCXX_SOURCES
#
# The PYCXX_*_DIR variables can be set to tell this module where
# the files are.
# There's no standard location for PyCXX.
#
# The authors' example is to put it in "~\" [sic].
#
# Ubuntu puts the includes into /usr/include/python2.7/CXX and sources into
# /usr/share/python2.7/CXX.
#
# The Zultron Fedora RPM does the same as Ubuntu.
set(PYCXX_FOUND "YES")
# find the header directory
if(PYCXX_INCLUDE_DIR)
# headers better be in there
if(NOT EXISTS "${PYCXX_INCLUDE_DIR}/CXX/Config.hxx")
if(PYCXX_FIND_REQUIRED)
MESSAGE(FATAL_ERROR
"PyCXX: could not find CXX/Config.hxx in PYCXX_INCLUDE_DIR "
"${PYCXX_INCLUDE_DIR}")
else(PYCXX_FIND_REQUIRED)
MESSAGE(WARNING
"PyCXX: could not find CXX/Config.hxx in PYCXX_INCLUDE_DIR "
"${PYCXX_INCLUDE_DIR}")
unset(PYCXX_FOUND)
endif(PYCXX_FIND_REQUIRED)
endif(NOT EXISTS "${PYCXX_INCLUDE_DIR}/CXX/Config.hxx")
else(PYCXX_INCLUDE_DIR)
# check in 'standard' places
find_path(PYCXX_INCLUDE_DIR CXX/Config.hxx
${PYTHON_INCLUDE_DIR}
"${CMAKE_CURRENT_LIST_DIR}/..")
if(NOT PYCXX_INCLUDE_DIR)
if(PYCXX_FIND_REQUIRED)
MESSAGE(FATAL_ERROR
"PyCXX not found; please set PYCXX_INCLUDE_DIR to "
"the location of CXX/Config.hxx")
else(PYCXX_FIND_REQUIRED)
MESSAGE(STATUS "PyCXX not found")
unset(PYCXX_FOUND)
endif(PYCXX_FIND_REQUIRED)
endif(NOT PYCXX_INCLUDE_DIR)
endif(PYCXX_INCLUDE_DIR)
# find the sources directory
if(PYCXX_SOURCE_DIR)
# source directory specified, they'd better be there
if(NOT EXISTS "${PYCXX_SOURCE_DIR}/cxxextensions.c")
if(PYCXX_FIND_REQUIRED)
MESSAGE(FATAL_ERROR
"PyCXX: cxxextensions.c not found in PYCXX_INCLUDE_DIR "
"${PYCXX_INCLUDE_DIR}")
else(PYCXX_FIND_REQUIRED)
MESSAGE(WARNING
"PyCXX: cxxextensions.c not found in PYCXX_INCLUDE_DIR "
"${PYCXX_INCLUDE_DIR}")
unset(PYCXX_FOUND)
endif(PYCXX_FIND_REQUIRED)
endif(NOT EXISTS "${PYCXX_SOURCE_DIR}/cxxextensions.c")
else(PYCXX_SOURCE_DIR)
# check in 'standard' places
find_path(PYCXX_SOURCE_DIR cxxextensions.c
"${PYCXX_INCLUDE_DIR}/CXX"
"${PYCXX_INCLUDE_DIR}/Src"
"${PYTHON_INCLUDE_DIR}/CXX"
"${PYTHON_INCLUDE_DIR}/Src"
"${CMAKE_CURRENT_LIST_DIR}/../Src"
"${CMAKE_CURRENT_LIST_DIR}/../CXX")
if(NOT PYCXX_SOURCE_DIR)
if(PYCXX_FIND_REQUIRED)
MESSAGE(FATAL_ERROR
"PyCXX not found; please set PYCXX_SOURCE_DIR to "
"the location of cxxextensions.c")
else(PYCXX_FIND_REQUIRED)
MESSAGE(STATUS "PyCXX not found")
unset(PYCXX_FOUND)
endif(PYCXX_FIND_REQUIRED)
endif(NOT PYCXX_SOURCE_DIR)
endif(PYCXX_SOURCE_DIR)
# see what we've got
if(PYCXX_FOUND)
MESSAGE(STATUS "PyCXX found:")
MESSAGE(STATUS " Headers: ${PYCXX_INCLUDE_DIR}")
MESSAGE(STATUS " Sources: ${PYCXX_SOURCE_DIR}")
# Build the list of sources for convenience
set(PYCXX_SOURCES
${PYCXX_SOURCE_DIR}/cxxextensions.c
${PYCXX_SOURCE_DIR}/cxx_extensions.cxx
${PYCXX_SOURCE_DIR}/cxxsupport.cxx
${PYCXX_SOURCE_DIR}/IndirectPythonInterface.cxx
)
else(PYCXX_FOUND)
MESSAGE(STATUS "PyCXX not found")
endif(PYCXX_FOUND)

View File

@ -14,6 +14,7 @@ include_directories(
${XERCESC_INCLUDE_DIR}
${QT_QTCORE_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${PYCXX_INCLUDE_DIR}
)
if(MSVC)
@ -124,20 +125,7 @@ SET(zipios_SRCS
SOURCE_GROUP("zipios" FILES ${zipios_SRCS})
endif ()
SET(pycxx_SRCS
../CXX/Config.hxx
../CXX/cxxextensions.c
../CXX/cxx_extensions.cxx
../CXX/cxxsupport.cxx
../CXX/Exception.hxx
../CXX/Extensions.hxx
../CXX/IndirectPythonInterface.cxx
../CXX/IndirectPythonInterface.hxx
../CXX/Objects.hxx
../CXX/Version.hxx
../CXX/WrapPython.h
)
SOURCE_GROUP("pycxx" FILES ${pycxx_SRCS})
SOURCE_GROUP("pycxx" FILES ${PYCXX_SOURCES})
SET(FreeCADBase_XML_SRCS
AxisPy.xml
@ -279,7 +267,7 @@ SET(FreeCADBase_HPP_SRCS
)
SET(FreeCADBase_SRCS
${pycxx_SRCS}
${PYCXX_SOURCES}
${FreeCADBase_CPP_SRCS}
${FreeCADBase_HPP_SRCS}
${FreeCADBase_XML_SRCS}