Commit cd797a97 authored by Julien Wintz's avatar Julien Wintz
Browse files

Made SIP wrapping work on Mac.

parent 8b986f1b
......@@ -14,54 +14,53 @@
if(DTK_BUILD_WRAPPERS)
set(DTK_PYTHON_WRAPPER SWIG CACHE STRING "Choose the type of python wrapping")
set_property(CACHE DTK_PYTHON_WRAPPER PROPERTY STRINGS "SWIG" "SIP")
if(DTK_PYTHON_WRAPPER MATCHES "SIP")
if(APPLE)
set(SIP_DEFAULT_SIP_DIR "/System/Library/Frameworks/Python.framework/Versions/2.7/share/sip/")
set(SIP_MODULE_DIR ${SIP_DEFAULT_SIP_DIR})
set(PYQT5_MODULE_DIR "${SIP_DEFAULT_SIP_DIR}/PyQt5")
endif()
find_package(SIP)
else()
find_package(SWIG QUIET)
set(DTK_PYTHON_WRAPPER SWIG CACHE STRING "Choose the type of python wrapping")
set_property(CACHE DTK_PYTHON_WRAPPER PROPERTY STRINGS "SWIG" "SIP")
if(DTK_PYTHON_WRAPPER MATCHES "SIP")
if(APPLE)
set(SIP_DEFAULT_SIP_DIR "/System/Library/Frameworks/Python.framework/Versions/2.7/share/sip")
set(SIP_MODULE_DIR ${SIP_DEFAULT_SIP_DIR})
set(PYQT5_MODULE_DIR "${SIP_DEFAULT_SIP_DIR}/PyQt5")
endif()
find_package(SIP)
else()
find_package(SWIG QUIET)
endif()
if(SIP_FOUND)
set(SIP_PLATFORM "WS_X11")
if(APPLE)
set(SIP_PLATFORM "WS_MACX")
endif()
if(WIN32)
set(SIP_PLATFORM "WS_WIN")
endif()
if(SIP_FOUND)
set(SIP_PLATFORM "WS_X11")
if(APPLE)
set(SIP_PLATFORM "WS_MAC")
endif()
if(WIN32)
set(SIP_PLATFORM "WS_WIN")
endif()
macro(dtk_wrap_sip project target name input includes deps)
macro(dtk_wrap_sip project target name input includes deps)
set(wrap_output sip${name}cmodule.cpp ${includes})
set(wrap_output sip${name}cmodule.cpp ${includes})
add_custom_command(
OUTPUT ${wrap_output}
COMMAND ${SIP_EXECUTABLE}
ARGS
"-I" "${PYQT5_MODULE_DIR}/"
"-I" "${dtk_INCLUDE_DIR}/sip"
"-I" "${dtk_INCLUDE_DIR}/sip/dtkCore"
"-I" "${dtk_INCLUDE_DIR}/sip/dtkWidgets"
"-t" "${SIP_PLATFORM}"
"-c" "${CMAKE_CURRENT_BINARY_DIR}/"
${input}
MAIN_DEPENDENCY ${deps}
COMMENT "Wrapping ${input} to python SIP")
add_custom_command(
OUTPUT ${wrap_output}
COMMAND ${SIP_EXECUTABLE}
ARGS
"-I" "${PYQT5_MODULE_DIR}/"
"-I" "${CMAKE_SOURCE_DIR}/sip"
"-I" "${CMAKE_SOURCE_DIR}/sip/dtkCore"
"-I" "${CMAKE_SOURCE_DIR}/sip/dtkWidgets"
"-t" "${SIP_PLATFORM}"
"-c" "${CMAKE_CURRENT_BINARY_DIR}/"
${input}
MAIN_DEPENDENCY ${deps}
COMMENT "Wrapping ${input} to python SIP")
set(${target} ${${target}} ${wrap_output})
endmacro(dtk_wrap_sip)
set(${target} ${${target}} ${wrap_output})
endmacro(dtk_wrap_sip)
endif(SIP_FOUND)
endif(SIP_FOUND)
if(SWIG_FOUND)
if(SWIG_FOUND)
include(${SWIG_USE_FILE})
......@@ -94,7 +93,6 @@ if(DTK_BUILD_WRAPPERS)
endmacro(dtk_wrap)
if(DTK_BUILD_WRAPPERS)
option(DTK_WRAPPING_PYTHON "Build python wrapper" OFF)
......@@ -132,7 +130,7 @@ if(TCL_FOUND)
endif(TCL_FOUND)
if(TCL_FOUND)
add_definitions(-DHAVE_TCL) # Towards deprecation
add_definitions(-DHAVE_TCL)
set(DTK_HAVE_TCL 1)
else(TCL_FOUND)
set(DTK_HAVE_TCL 0)
......@@ -158,18 +156,19 @@ else(PYTHONLIBS_FOUND)
endif(PYTHONLIBS_FOUND)
mark_as_advanced(SWIG_DIR)
mark_as_advanced(SWIG_EXECUTABLE)
mark_as_advanced(SWIG_VERSION)
mark_as_advanced(SWIG_DIR)
mark_as_advanced(SWIG_EXECUTABLE)
mark_as_advanced(SWIG_VERSION)
mark_as_advanced(SIP_DIR)
mark_as_advanced(SIP_VERSION)
mark_as_advanced(SIP_EXECUTABLE)
mark_as_advanced(_find_sip_py)
mark_as_advanced(SIP_DIR)
mark_as_advanced(SIP_VERSION)
mark_as_advanced(SIP_EXECUTABLE)
mark_as_advanced(_find_sip_py)
mark_as_advanced(PYQT5_MODULE_DIR)
mark_as_advanced(Qt5DIR)
mark_as_advanced(SIP_MODULE_DIR)
mark_as_advanced(SIP_DEFAULT_SIP_DIR)
mark_as_advanced(PYQT5_MODULE_DIR)
mark_as_advanced(Qt5DIR)
mark_as_advanced(SIP_MODULE_DIR)
endif(DTK_BUILD_WRAPPERS)
......
......@@ -195,19 +195,19 @@ if(DTK_BUILD_WRAPPERS AND SIP_FOUND)
if(APPLE)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
DEPENDS ${PROJECT_SOURCE_DIR}/dtkCore.i
COMMAND ln -sf ../lib/libdtkCore.dylib _dtkCore.so
COMMAND ln -sf ../lib/libdtkCore.dylib dtkCore.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/_dtkcore.so)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/dtkCore.so)
endif(APPLE)
if(UNIX AND NOT APPLE)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
DEPENDS ${PROJECT_SOURCE_DIR}/dtkCore.i
COMMAND ln -fs ../${CMAKE_INSTALL_LIBDIR}/libdtkCore.so _dtkCore.so
COMMAND ln -fs ../${CMAKE_INSTALL_LIBDIR}/libdtkCore.so dtkCore.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/_dtkcore.so)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/dtkCore.so)
endif(UNIX AND NOT APPLE)
endif(DTK_BUILD_WRAPPERS AND SIP_FOUND)
......
......@@ -124,8 +124,7 @@ if(DTK_BUILD_WRAPPERS)
set(${PROJECT_NAME}_SIP_WRAPPERS
sip${PROJECT_NAME}dtkViewController.cpp
sip${PROJECT_NAME}dtkViewManager.cpp
sip${PROJECT_NAME}dtkViewWidget.cpp
)
sip${PROJECT_NAME}dtkViewWidget.cpp)
dtk_wrap_sip(${PROJECT_NAME} ${PROJECT_NAME}_SOURCES_WRAP dtkWidgets ${CMAKE_SOURCE_DIR}/sip/dtkWidgets/dtkWidgetsmod.sip "${${PROJECT_NAME}_SIP_WRAPPERS}" ${${PROJECT_NAME}_WRAP_DEPENDS})
endif(SIP_FOUND)
......@@ -228,20 +227,20 @@ if(DTK_BUILD_WRAPPERS AND SIP_FOUND)
if(APPLE)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
DEPENDS ${PROJECT_SOURCE_DIR}/dtkCore.i
COMMAND ln -sf ../lib/libdtkCore.dylib _dtkcore.so
DEPENDS ${PROJECT_SOURCE_DIR}/dtkWidgets.i
COMMAND ln -sf ../lib/libdtkWidgets.dylib dtkWidgets.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/_dtkwidgets.so)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/dtkWidget.so)
endif(APPLE)
if(UNIX AND NOT APPLE)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
DEPENDS ${PROJECT_SOURCE_DIR}/dtkCore.i
COMMAND ln -fs ../${CMAKE_INSTALL_LIBDIR}/libdtkWidgets.so _dtkWidgets.so
DEPENDS ${PROJECT_SOURCE_DIR}/dtkWidgets.i
COMMAND ln -fs ../${CMAKE_INSTALL_LIBDIR}/libdtkWidgets.so dtkWidgets.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/_dtkwidgets.so)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/dtkWidgets.so)
endif(UNIX AND NOT APPLE)
endif(DTK_BUILD_WRAPPERS AND SIP_FOUND)
......
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