Skip to content

Commit

Permalink
Remove 'CTK_WRAP_PYTHONQT_FULL' obsolete option. See commontk#449
Browse files Browse the repository at this point in the history
* Since PythonQtGenerator was only used for Python FULL wrapping, remove
the corresponding external project.

* Remove reference to Full wrapping

* Update ctkMacroWrapPythonQt to complain if existing code invoke
the macro with 'IS_WRAP_FULL' set to TRUE
  • Loading branch information
jcfr committed Apr 16, 2014
1 parent 3593a34 commit 1b051e5
Show file tree
Hide file tree
Showing 26 changed files with 46 additions and 287 deletions.
5 changes: 2 additions & 3 deletions Applications/ctkSimplePythonShell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ if(CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_
)
endif()

# Configure file will be configured using CTK_WRAP_PYTHONQT_{LIGHT, FULL} and
# Configure file will be configured using CTK_WRAP_PYTHONQT_LIGHT and
# CTK_BUILD_SHARED_LIBS variables
configure_file(
ctkSimplePythonShellConfigure.h.in
Expand All @@ -90,8 +90,7 @@ configure_file(

# The following block generate the code required to initialize the wrapper
# when CTK is statically built.
if(NOT CTK_BUILD_SHARED_LIBS
AND (CTK_WRAP_PYTHONQT_LIGHT OR CTK_WRAP_PYTHONQT_FULL))
if(NOT CTK_BUILD_SHARED_LIBS AND CTK_WRAP_PYTHONQT_LIGHT)

# Update list of target libraries with the list of available PythonQt libraries
# and set variables holding list of pythonqt initialization method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
// CTK includes
#include "ctkSimplePythonManager.h"
#include "ctkSimplePythonQtDecorators.h"
#include "ctkSimplePythonShellConfigure.h" // For CTK_WRAP_PYTHONQT_{LIGHT, FULL}, CTK_WRAP_PYTHONQT_USE_VTK and CTK_BUILD_SHARED_LIBS
#include "ctkSimplePythonShellConfigure.h" // For CTK_WRAP_PYTHONQT_LIGHT, CTK_WRAP_PYTHONQT_USE_VTK and CTK_BUILD_SHARED_LIBS
#ifdef CTK_WRAP_PYTHONQT_USE_VTK
# include "ctkVTKPythonQtWrapperFactory.h"
#endif


#if defined(CTK_WRAP_PYTHONQT_LIGHT) || defined(CTK_WRAP_PYTHONQT_FULL)
#if defined(CTK_WRAP_PYTHONQT_LIGHT)
# ifndef CTK_BUILD_SHARED_LIBS
// PythonQt wrapper initialization methods
@CTK_PYTHONQT_INITIALIZATION_METHOD_DEFINITION@
Expand Down Expand Up @@ -93,7 +93,7 @@ void ctkSimplePythonManager::preInitialization()
{
Superclass::preInitialization();

#if defined(CTK_WRAP_PYTHONQT_LIGHT) || defined(CTK_WRAP_PYTHONQT_FULL)
#if defined(CTK_WRAP_PYTHONQT_LIGHT)
# ifndef CTK_BUILD_SHARED_LIBS
// Initialize wrappers
@CTK_PYTHONQT_INITIALIZATION_METHOD_CALL@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#cmakedefine CTK_BUILD_SHARED_LIBS
#cmakedefine CTK_WRAP_PYTHONQT_LIGHT
#cmakedefine CTK_WRAP_PYTHONQT_FULL

//#define CTK_PYTHON_LIBRARY_DIR_BUILD "@LIBRARY_OUTPUT_DIRECTORY@"

Expand Down
5 changes: 1 addition & 4 deletions CMake/ctkMacroBuildLibWrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ macro(ctkMacroBuildLibWrapper)
if(NOT DEFINED MY_NAMESPACE)
set(MY_NAMESPACE "org.commontk")
endif()
if(NOT DEFINED CTK_WRAP_PYTHONQT_FULL)
set(CTK_WRAP_PYTHONQT_FULL FALSE)
endif()
foreach(type RUNTIME LIBRARY ARCHIVE)
if(NOT DEFINED MY_${type}_OUTPUT_DIRECTORY)
set(MY_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY})
Expand Down Expand Up @@ -93,7 +90,7 @@ macro(ctkMacroBuildLibWrapper)

set(KIT_PYTHONQT_SRCS) # Clear variable
ctkMacroWrapPythonQt(${MY_NAMESPACE} ${lib_name}
KIT_PYTHONQT_SRCS "${MY_SRCS}" ${CTK_WRAP_PYTHONQT_FULL} ${HAS_DECORATOR})
KIT_PYTHONQT_SRCS "${MY_SRCS}" FALSE ${HAS_DECORATOR})
if(HAS_DECORATOR)
list(APPEND KIT_PYTHONQT_SRCS ${DECORATOR_HEADER})
QT4_WRAP_CPP(KIT_PYTHONQT_SRCS ${DECORATOR_HEADER} OPTIONS -f${DECORATOR_HEADER})
Expand Down
54 changes: 20 additions & 34 deletions CMake/ctkMacroWrapPythonQt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#!
#! Depends on:
#! PythonQt
#! PythonQtGenerator (Only if IS_WRAP_FULL is TRUE)
#! PythonInterp (See function reSearchFile)
#!

Expand All @@ -41,8 +40,6 @@
#!
#! SOURCES ..........: List of source files that should be wrapped.
#!
#! IS_WRAP_FULL .....: Indicate if a Full wrapping if desired.
#!
#! HAS_DECORATOR ....: Indicate if a custom PythonQt decorator header is expected.
#!

Expand Down Expand Up @@ -102,8 +99,8 @@ endfunction()
macro(ctkMacroWrapPythonQt WRAPPING_NAMESPACE TARGET SRCS_LIST_NAME SOURCES IS_WRAP_FULL HAS_DECORATOR)

# Sanity check
if(IS_WRAP_FULL AND NOT EXISTS "${PYTHONQTGENERATOR_EXECUTABLE}")
message(FATAL_ERROR "PYTHONQTGENERATOR_EXECUTABLE not specified or inexistent when calling ctkMacroWrapPythonQt")
if(IS_WRAP_FULL)
message(FATAL_ERROR "IS_WRAP_FULL option is not supported anymore. See https://github.com/commontk/CTK/issues/449")
endif()

# TODO: this find package seems not to work when called form a superbuild, but the call is needed
Expand Down Expand Up @@ -168,30 +165,26 @@ macro(ctkMacroWrapPythonQt WRAPPING_NAMESPACE TARGET SRCS_LIST_NAME SOURCES IS_W
set(className ${TMP_FILENAME})

if(NOT skip_wrapping)
# Skip wrapping if IS_WRAP_FULL=FALSE and if file do NOT contain Q_OBJECT
if(NOT IS_WRAP_FULL)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} file_content)
if(NOT "${file_content}" MATCHES "Q_OBJECT")
set(skip_wrapping TRUE)
ctkMacroWrapPythonQt_log("${FILE}: skipping - No Q_OBJECT macro")
endif()
# Skip wrapping if file do NOT contain Q_OBJECT
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} file_content)
if(NOT "${file_content}" MATCHES "Q_OBJECT")
set(skip_wrapping TRUE)
ctkMacroWrapPythonQt_log("${FILE}: skipping - No Q_OBJECT macro")
endif()
endif()

if(NOT skip_wrapping)
# Skip wrapping if IS_WRAP_FULL=FALSE and if constructor doesn't match:
# Skip wrapping if constructor doesn't match:
# my_class()
# my_class(QObject* newParent ...)
# my_class(QWidget* newParent ...)
if(NOT IS_WRAP_FULL)
# Constructor with either QWidget or QObject as first parameter
set(regex "[^~]${className}[\\s\\n]*\\([\\s\\n]*((QObject|QWidget)[\\s\\n]*\\*[\\s\\n]*\\w+[\\s\\n]*(\\=[\\s\\n]*(0|NULL)|,.*\\=.*\\)|\\)|\\)))")
ctkMacroWrapPythonQt_reSearchfile(${PYTHON_EXECUTABLE} ${PYTHON_LIBRARY_PATH}
${regex} ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} is_matching)
if(NOT is_matching)
set(skip_wrapping TRUE)
ctkMacroWrapPythonQt_log("${FILE}: skipping - Missing expected constructor signature")
endif()
# Constructor with either QWidget or QObject as first parameter
set(regex "[^~]${className}[\\s\\n]*\\([\\s\\n]*((QObject|QWidget)[\\s\\n]*\\*[\\s\\n]*\\w+[\\s\\n]*(\\=[\\s\\n]*(0|NULL)|,.*\\=.*\\)|\\)|\\)))")
ctkMacroWrapPythonQt_reSearchfile(${PYTHON_EXECUTABLE} ${PYTHON_LIBRARY_PATH}
${regex} ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} is_matching)
if(NOT is_matching)
set(skip_wrapping TRUE)
ctkMacroWrapPythonQt_log("${FILE}: skipping - Missing expected constructor signature")
endif()
endif()

Expand Down Expand Up @@ -235,14 +228,8 @@ macro(ctkMacroWrapPythonQt WRAPPING_NAMESPACE TARGET SRCS_LIST_NAME SOURCES IS_W
endforeach()

# Define wrap type and wrap intermediate directory
set(wrap_type "Light")
set(wrap_int_dir generated_cpp/${WRAPPING_NAMESPACE_UNDERSCORE}_${TARGET}/)
set(extra_files )
if(${IS_WRAP_FULL})
set(wrap_type "Full")
set(extra_files ${wrap_int_dir}ctkPythonQt_${TARGET}_masterinclude.h)
endif()
#message("wrap_type:${wrap_type} - wrap_int_dir:${wrap_int_dir}")
#message("wrap_int_dir:${wrap_int_dir}")

# Create intermediate output directory
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${wrap_int_dir})
Expand All @@ -269,10 +256,9 @@ macro(ctkMacroWrapPythonQt WRAPPING_NAMESPACE TARGET SRCS_LIST_NAME SOURCES IS_W
OUTPUT
${wrap_int_dir}${wrapper_init_cpp_filename}
${wrap_int_dir}${wrapper_module_init_cpp_filename}
${extra_files}
DEPENDS
${SOURCES_TO_WRAP}
${CTK_CMAKE_DIR}/ctkScriptWrapPythonQt_${wrap_type}.cmake
${CTK_CMAKE_DIR}/ctkScriptWrapPythonQt_Light.cmake
${CTK_CMAKE_DIR}/ctkMacroWrapPythonQtModuleInit.cpp.in
COMMAND ${CMAKE_COMMAND}
-DPYTHONQTGENERATOR_EXECUTABLE:FILEPATH=${PYTHONQTGENERATOR_EXECUTABLE}
Expand All @@ -286,8 +272,8 @@ macro(ctkMacroWrapPythonQt WRAPPING_NAMESPACE TARGET SRCS_LIST_NAME SOURCES IS_W
-DWRAP_INT_DIR:STRING=${wrap_int_dir}
-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
-DHAS_DECORATOR:BOOL=${HAS_DECORATOR}
-P ${CTK_CMAKE_DIR}/ctkScriptWrapPythonQt_${wrap_type}.cmake
COMMENT "PythonQt ${wrap_type} Wrapping - Generating ${wrapper_init_cpp_filename}"
-P ${CTK_CMAKE_DIR}/ctkScriptWrapPythonQt_Light.cmake
COMMENT "PythonQt Wrapping - Generating ${wrapper_init_cpp_filename}"
VERBATIM
)

Expand Down Expand Up @@ -333,7 +319,7 @@ macro(ctkMacroWrapPythonQt WRAPPING_NAMESPACE TARGET SRCS_LIST_NAME SOURCES IS_W
-DOUTPUT_DIR:PATH=${CMAKE_CURRENT_BINARY_DIR}
-DQT_MOC_EXECUTABLE:FILEPATH=${QT_MOC_EXECUTABLE}
-P ${CTK_CMAKE_DIR}/ctkScriptMocPythonQtWrapper.cmake
COMMENT "PythonQt ${wrap_type} Wrapping - Moc'ing ${WRAPPING_NAMESPACE_UNDERSCORE}_${TARGET} wrapper headers"
COMMENT "PythonQt Wrapping - Moc'ing ${WRAPPING_NAMESPACE_UNDERSCORE}_${TARGET} wrapper headers"
VERBATIM
)

Expand Down
153 changes: 0 additions & 153 deletions CMake/ctkScriptWrapPythonQt_Full.cmake

This file was deleted.

Loading

0 comments on commit 1b051e5

Please sign in to comment.