Skip to content

Commit

Permalink
refactor cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Aug 2, 2013
1 parent 524023b commit cd65505
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 112 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ catkin_package(CFG_EXTRAS python_qt_binding-extras.cmake)

catkin_python_setup()

install(DIRECTORY cmake
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(FILES
cmake/shiboken_helper.cmake
cmake/sip_configure.py
cmake/sip_helper.cmake
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake)
7 changes: 7 additions & 0 deletions cmake/python_qt_binding-extras.cmake.em
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@[if DEVELSPACE]@
# location of cmake files in develspace
set(python_qt_binding_EXTRAS_DIR "@(CMAKE_CURRENT_SOURCE_DIR)/cmake")
@[else]@
# location of cmake files in installspace
set(python_qt_binding_EXTRAS_DIR "${python_qt_binding_DIR}")
@[end if]@
5 changes: 0 additions & 5 deletions cmake/python_qt_binding-extras.cmake.in

This file was deleted.

49 changes: 0 additions & 49 deletions cmake/shiboken_check_compiles.cmake

This file was deleted.

25 changes: 0 additions & 25 deletions cmake/shiboken_check_qgenericreturnargument.cmake

This file was deleted.

44 changes: 43 additions & 1 deletion cmake/shiboken_helper.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
if(__PYTHON_QT_BINDING_SHIBOKEN_HELPER_INCLUDED)
return()
endif()
set(__PYTHON_QT_BINDING_SHIBOKEN_HELPER_INCLUDED TRUE)

find_package(Shiboken)
find_package(PySide)
find_package(PythonLibs)
Expand Down Expand Up @@ -30,6 +35,27 @@ macro(_shiboken_generator_command VAR GLOBAL TYPESYSTEM INCLUDE_PATH BUILD_DIR)
endmacro()


#
# Run the Shiboken generator.
#
# :param PROJECT_NAME: The name of the shiboken project is only use for
# the custom command comment
# :type PROJECT_NAME: string
# :param GLOBAL: the SIP file
# :type GLOBAL: string
# :param TYPESYSTEM: the typesystem file
# :type TYPESYSTEM: string
# :param WORKING_DIR: the working directory
# :type WORKING_DIR: string
# :param GENERATED_SRCS: the generated source files
# :type GENERATED_SRCS: list of strings
# :param HDRS: the processed header files
# :type HDRS: list of strings
# :param INCLUDE_PATH: the include path
# :type INCLUDE_PATH: list of strings
# :param BUILD_DIR: the build directory
# :type BUILD_DIR: string
#
function(shiboken_generator PROJECT_NAME GLOBAL TYPESYSTEM WORKING_DIR GENERATED_SRCS HDRS INCLUDE_PATH BUILD_DIR)
_shiboken_generator_command(COMMAND "${GLOBAL}" "${TYPESYSTEM}" "${INCLUDE_PATH}" "${BUILD_DIR}")
add_custom_command(
Expand All @@ -42,6 +68,14 @@ function(shiboken_generator PROJECT_NAME GLOBAL TYPESYSTEM WORKING_DIR GENERATED
endfunction()


#
# Add the Shiboken/PySide specific include directories.
#
# :param PROJECT_NAME: The namespace of the binding
# :type PROJECT_NAME: string
# :param QT_COMPONENTS: the Qt components
# :type QT_COMPONENTS: list of strings
#
function(shiboken_include_directories PROJECT_NAME QT_COMPONENTS)
set(shiboken_INCLUDE_DIRECTORIES
${PYTHON_INCLUDE_DIR}
Expand All @@ -59,13 +93,21 @@ function(shiboken_include_directories PROJECT_NAME QT_COMPONENTS)
endfunction()


#
# Add the Shiboken/PySide specific link libraries.
#
# :param PROJECT_NAME: The target name of the binding library
# :type PROJECT_NAME: string
# :param QT_COMPONENTS: the Qt components
# :type QT_COMPONENTS: list of strings
#
function(shiboken_target_link_libraries PROJECT_NAME QT_COMPONENTS)
set(shiboken_LINK_LIBRARIES
${SHIBOKEN_PYTHON_LIBRARIES}
${SHIBOKEN_LIBRARY}
${PYSIDE_LIBRARY}
)

foreach(component ${QT_COMPONENTS})
string(TOUPPER ${component} component)
set(shiboken_LINK_LIBRARIES ${shiboken_LINK_LIBRARIES} ${QT_${component}_LIBRARY})
Expand Down
54 changes: 38 additions & 16 deletions cmake/sip_helper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ if(__PYTHON_QT_BINDING_SIP_HELPER_INCLUDED)
endif()
set(__PYTHON_QT_BINDING_SIP_HELPER_INCLUDED TRUE)

set(__PYTHON_QT_BINDING_SIP_HELPER_DIR ${CMAKE_CURRENT_LIST_DIR})

find_package(PythonInterp REQUIRED)
assert(PYTHON_EXECUTABLE)

find_program(SIP_EXECUTABLE sip)
if(NOT SIP_EXECUTABLE_NOTFOUND)
message(STATUS "SIP binding generator available.")
set(sip_helper_FOUND TRUE)
else()
message(WARNING "SIP binding generator NOT available.")
set(sip_helper_NOTFOUND TRUE)
endif()

# Provide cmake_parse_arguments() for versions of cmake before 2.8.3.
if(${CMAKE_VERSION} VERSION_LESS 2.8.3)
Expand Down Expand Up @@ -139,28 +151,39 @@ if(${CMAKE_VERSION} VERSION_LESS 2.8.3)
endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs)
endif()

if(NOT SIP_EXECUTABLE_NOTFOUND)
message(STATUS "SIP binding generator available.")
set(sip_helper_FOUND TRUE)
else()
message(WARNING "SIP binding generator NOT available.")
set(sip_helper_NOTFOUND TRUE)
endif()

#
# Run the SIP generator and compile the generated code into a library.
#
# .. note:: The target lib${PROJECT_NAME} is created.
#
# :param PROJECT_NAME: The name of the sip project
# :type PROJECT_NAME: string
# :param SIP_FILE: the SIP file to be processed
# :type SIP_FILE: string
#
# The following options can be used to override the default behavior:
# SIP_CONFIGURE: the used configure script for SIP
# (default: sip_configure.py in the same folder as this file)
# SOURCE_DIR: the source dir (default: ${PROJECT_SOURCE_DIR}/src)
# LIBRARY_DIR: the library dir (default: ${PROJECT_SOURCE_DIR}/src)
# BINARY_DIR: the binary dir (default: ${PROJECT_BINARY_DIR})
#
# The following keywords arguments can be used to specify:
# DEPENDS: depends for the custom command
# (should list all sip and header files)
# DEPENDENCIES: target dependencies
# (should list the library for which SIP generates the bindings)
#
function(build_sip_binding PROJECT_NAME SIP_FILE)
set(oneValueArgs SIP_CONFIGURE SOURCE_DIR LIBRARY_DIR BINARY_DIR)
set(multiValueArgs DEPENDS DEPENDENCIES)
cmake_parse_arguments(sip "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
cmake_parse_arguments(sip "" "SIP_CONFIGURE;SOURCE_DIR;LIBRARY_DIR;BINARY_DIR" "DEPENDS;DEPENDENCIES" ${ARGN})
if(sip_UNPARSED_ARGUMENTS)
message(WARNING "build_sip_binding(${PROJECT_NAME}) called with unused arguments: ${sip_UNPARSED_ARGUMENTS}")
endif()

# set default values for optional arguments
if(NOT sip_SIP_CONFIGURE)
# without catkin and CFG_EXTRAS the variable can not be set inside that script
message(FATAL_ERROR "build_sip_binding(${PROJECT_NAME}) missing argument: SIP_CONFIGURE")
# in the future set default value to sip_configure.py in this directory
#set(sip_SIP_CONFIGURE ${python_qt_binding_SOURCE_DIR}/cmake/sip_configure.py)
# default to sip_configure.py in this directory
set(sip_SIP_CONFIGURE ${__PYTHON_QT_BINDING_SIP_HELPER_DIR}/sip_configure.py)
endif()
if(NOT sip_SOURCE_DIR)
set(sip_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src)
Expand All @@ -179,7 +202,6 @@ function(build_sip_binding PROJECT_NAME SIP_FILE)
set(LIBRARY_DIRS ${${PROJECT_NAME}_LIBRARY_DIRS})
set(LDFLAGS_OTHER ${${PROJECT_NAME}_LDFLAGS_OTHER})

assert(PYTHON_EXECUTABLE)
add_custom_command(
OUTPUT ${SIP_BUILD_DIR}/Makefile
COMMAND ${PYTHON_EXECUTABLE} ${sip_SIP_CONFIGURE} ${SIP_BUILD_DIR} ${SIP_FILE} ${sip_LIBRARY_DIR} \"${INCLUDE_DIRS}\" \"${LIBRARIES}\" \"${LIBRARY_DIRS}\" \"${LDFLAGS_OTHER}\"
Expand Down
14 changes: 0 additions & 14 deletions mainpage.dox

This file was deleted.

0 comments on commit cd65505

Please sign in to comment.