Commit e2cc7b5b authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline

Fix broken CMake SIP code:

* Generate one SIP C++ file per wrapped class
* Move lima_init_numpy.cpp to separate compilation unit
parent be9c6510
......@@ -263,13 +263,6 @@ if(LIMA_ENABLE_SPS_IMAGE)
set(ct_srcs ${ct_srcs} control/src/CtSpsImage.cpp third-party/Sps/Src/sps.c)
endif()
#--------------------------------------------------------------------------------
# Option for openGL real-time display support
#--------------------------------------------------------------------------------
if(LIMA_ENABLE_GLDISPLAY)
add_subdirectory(third-party/gldisplay)
endif()
#--------------------------------------------------------------------------------
# Option for extra saving formats edf.gz, edf.lz4, cbf, hdf5, tiff, fits ...
#--------------------------------------------------------------------------------
......@@ -514,7 +507,6 @@ if(LIMA_ENABLE_PYTHON)
configure_file(sip/core/limacore.sip.in sip/core/limacore.sip)
configure_file(hardware/sip/HwFrameInfo.sip_after_4_12 sip/core/HwFrameInfo.sip)
endif()
set(SIP_CONCAT_PARTS 1)
set(SIP_INCLUDES ${SIP_INCLUDES}
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/Processlib/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/Processlib/tasks/sip"
......@@ -543,6 +535,13 @@ if(LIMA_ENABLE_PYTHON)
install(FILES common/python/__init__.py common/python/Debug.py DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima/Core")
endif()
#--------------------------------------------------------------------------------
# Option for openGL real-time display support
#--------------------------------------------------------------------------------
if(LIMA_ENABLE_GLDISPLAY)
add_subdirectory(third-party/gldisplay)
endif()
#--------------------------------------------------------------------------------
#TESTS, run ctest or make test
#--------------------------------------------------------------------------------
......
......@@ -37,7 +37,6 @@
set(SIP_INCLUDES)
set(SIP_TAGS)
set(SIP_CONCAT_PARTS 8)
set(SIP_DISABLE_FEATURES)
set(SIP_EXTRA_OPTIONS)
......@@ -78,12 +77,40 @@ macro(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
endforeach (_x ${SIP_DISABLE_FEATURES})
set(_message "-DMESSAGE=Generating CPP code for module ${MODULE_NAME}")
set(_module_sbf ${_module_path}/${MODULE_NAME}.sbf)
execute_process(
COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS}
${_sip_includes} -b ${_module_sbf}
${_abs_module_sip}
)
set(_lima_init_numpy_cpp)
if(NOT (${MODULE_NAME} STREQUAL "processlib"))
set(_lima_init_numpy "lima_init_numpy.cpp")
set(_lima_init_numpy_cpp ${_module_path}/${_lima_init_numpy})
add_custom_command(
OUTPUT ${_lima_init_numpy_cpp}
COMMAND cp ${CMAKE_SOURCE_DIR}/sip/${_lima_init_numpy}
${_module_path}
DEPENDS ${CMAKE_SOURCE_DIR}/sip/${_lima_init_numpy}
)
endif()
set(_sip_output_files_list)
execute_process(
COMMAND grep "^sources[ ]*=[ ]*" ${_module_sbf}
COMMAND sed "s/^sources[ ]*=[ ]*//"
COMMAND bash -c "sed 's:\\([^ \\.]\\+\\.cpp\\):'$0'/\\1:g'"
${_module_path}
COMMAND sed "s/ /;/g"
OUTPUT_VARIABLE _sip_output_files_list
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(_sip_output_files)
foreach(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
if( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
set(_sip_output_files ${_sip_output_files} ${_module_path}/sip${_child_module_name}part${CONCAT_NUM}.cpp )
endif( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
endforeach(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
foreach(filename IN LISTS _sip_output_files_list)
set(_sip_output_files ${_sip_output_files} ${filename})
endforeach(filename)
if(NOT WIN32)
set(TOUCH_COMMAND touch)
......@@ -95,29 +122,39 @@ macro(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
file(APPEND filename "")
endforeach(filename ${_sip_output_files})
endif(NOT WIN32)
# TODO: add all SIP files with the %Include directive + Exceptions.sip
add_custom_command(
OUTPUT ${_sip_output_files}
COMMAND ${CMAKE_COMMAND} -E echo ${message}
COMMAND ${TOUCH_COMMAND} ${_sip_output_files}
COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS} -b ${MODULE_NAME}.sbf -c ${_module_path} ${_sip_includes} ${_abs_module_sip}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/checksipexc.py ${_sip_output_files}
COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS}
${_sip_includes} -c ${_module_path}
${_abs_module_sip}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/checksipexc.py
${_sip_output_files}
DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
)
# not sure if type MODULE could be uses anywhere, limit to cygwin for now
set(_sip_all_files ${_lima_init_numpy_cpp} ${_sip_output_files})
if (CYGWIN)
add_library(${_logical_name} MODULE ${_sip_output_files} )
add_library(${_logical_name} MODULE ${_sip_all_files} )
else (CYGWIN)
add_library(${_logical_name} SHARED ${_sip_output_files} )
add_library(${_logical_name} SHARED ${_sip_all_files} )
endif (CYGWIN)
target_link_libraries(${_logical_name} ${PYTHON_LIBRARY})
target_link_libraries(${_logical_name} ${EXTRA_LINK_LIBRARIES})
set_target_properties(${_logical_name} PROPERTIES PREFIX "" OUTPUT_NAME ${_child_module_name})
set_target_properties(${_logical_name} PROPERTIES
PREFIX "" OUTPUT_NAME ${_child_module_name}
LINKER_LANGUAGE CXX)
if (WIN32)
set_target_properties(${_logical_name} PROPERTIES SUFFIX ".pyd")
set_target_properties(${_logical_name} PROPERTIES IMPORT_SUFFIX ".dll")
endif (WIN32)
install(TARGETS ${_logical_name} DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/${_parent_module_path}")
install(TARGETS ${_logical_name}
DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/${_parent_module_path}")
endmacro(ADD_SIP_PYTHON_MODULE)
......@@ -517,10 +517,20 @@ return aReturnListPt;
};
%UnitCode
#include <lima_init_numpy.cpp>
#include <lima_repr_attr.cpp>
%End
%ModuleCode
extern "C"
{
#if PY_VERSION_HEX >= 0x03000000
int lima_import_array();
#else
void lima_import_array();
#endif
}
%End
%PostInitialisationCode
lima_import_array();
%End
......
%Module(name=lima@NAME@,version=0)
%ModuleHeaderCode
%ModuleCode
extern "C" {
#if PY_VERSION_HEX >= 0x03000000
int lima_import_array();
......@@ -12,7 +12,6 @@ void lima_import_array();
%End
%UnitCode
#include <lima_init_numpy.cpp>
#include <lima_repr_attr.cpp>
%End
......
Subproject commit 3d04cfd8aafb61f6198c79754ad6ce68d844c450
Subproject commit 7e55804aefa2c3065af42e1a987b0ee302e19b44
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