Skip to content

Commit

Permalink
Refs #4204. Ensure the same hidden registry for the new API.
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Dec 5, 2011
1 parent 4fa2fb2 commit 6da6fc5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
34 changes: 22 additions & 12 deletions Code/Mantid/Framework/PythonInterface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,29 @@ include_directories ( SYSTEM ${PYTHON_NUMPY_INCLUDE_DIR} )
set ( HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc/MantidPythonInterface )
include_directories ( inc )

# Note:
# On some Linux systems (seen on various Ubuntu versions) importing Mantid into a standalone python
# interpreter causes a segfault. It is some issue due to exception handling but the fix is
# to ensure that the stdc++ library appears as early in the link list as possible so that it
# is loaded first, hence the hard coding of it here rather than leaving it to be implicitly defined
# by the linker.
#
# MG 2011/11/15: A similar issue regarding the Nexus library has now been observed. Nexus 4.3 introduced
# thread-local variables and this now causes problems whenever we try and load the library from
# python if other libraries appear before it in the link list.
if ( UNIX )
set ( PYTHON_DEPS stdc++ ${NEXUS_C_LIBRARIES} ${MANTIDLIBS} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} )

if ( UNIX )
###########################################################################
# In order to keep the type registries for the two Python APIs separate
# we need to have a separate copy in each library. Once the old
# API is removed this will be deleted and we can link back to the dynamic
# library. This is only required on Unix like environments
###########################################################################
set ( BOOST_PYTHON_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../PythonAPI/src/boostpython.cpp )
include_directories ( SYSTEM ../PythonAPI/inc )

# On some Linux systems (seen on various Ubuntu versions) importing Mantid into a standalone python
# interpreter causes a segfault. It is some issue due to exception handling but the fix is
# to ensure that the stdc++ library appears as early in the link list as possible so that it
# is loaded first, hence the hard coding of it here rather than leaving it to be implicitly defined
# by the linker.
#
# MG 2011/11/15: A similar issue regarding the Nexus library has now been observed. Nexus 4.3 introduced
# thread-local variables and this now causes problems whenever we try and load the library from
# python if other libraries appear before it in the link list.
set ( PYTHON_DEPS stdc++ ${NEXUS_C_LIBRARIES} ${MANTIDLIBS} ${PYTHON_LIBRARIES} )
else ()
set ( BOOST_PYTHON_SRC ) # Not necessary on Windows
set ( PYTHON_DEPS ${MANTIDLIBS} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} )
endif ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ endforeach ( PYFILE )
# Create the target for this directory
#############################################################################################

add_library ( PythonKernelModule ${SRC_FILES} ${INC_FILES} ${PYTHON_INSTALL_FILES} )
add_library ( PythonKernelModule ${SRC_FILES} ${BOOST_PYTHON_SRC} ${INC_FILES} ${PYTHON_INSTALL_FILES} )
set_python_properties( PythonKernelModule _kernel )
set_target_output_directory ( PythonKernelModule ${OUTPUT_DIR} .pyd )
# Add the required dependencies
Expand Down

0 comments on commit 6da6fc5

Please sign in to comment.