From: vsr Date: Sat, 13 Mar 2021 07:03:48 +0000 (+0300) Subject: Porting: sip 5 X-Git-Tag: V9_7_0a1~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=80ae729fb04aa035120605a4e56f3c34084172fd;p=tools%2Fconfiguration.git Porting: sip 5 --- diff --git a/cmake/FindSIP.cmake b/cmake/FindSIP.cmake index 2a2a5d5..96ff220 100644 --- a/cmake/FindSIP.cmake +++ b/cmake/FindSIP.cmake @@ -17,11 +17,13 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# - Find SIP +# - Find sip # Sets the following variables: -# SIP_EXECUTABLE - path to the SIP executable -# SIP_INCLUDE_DIR - path to the SIP headers -# SIP_PYTHONPATH - path to the SIP Python packages +# SIP_VERSION - version of SIP +# SIP_MODULE_EXECUTABLE - path to the sip-module executable (sip >= 5) +# SIP_EXECUTABLE - path to the sip executable +# SIP_INCLUDE_DIR - path to the sip headers (sip < 5) +# SIP_PYTHONPATH - path to the sip Python packages # # The header sip.h is looked for. # The binary 'sip' is looked for. @@ -31,16 +33,44 @@ IF(NOT SIP_FIND_QUIETLY) MESSAGE(STATUS "Looking for SIP ...") ENDIF() -FIND_PROGRAM(SIP_EXECUTABLE sip) -FIND_PATH(SIP_INCLUDE_DIR sip.h PATH_SUFFIXES python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m) +# Find executable +FIND_PROGRAM(SIP_EXECUTABLE + NAMES sip5 sip4 sip + HINTS $ENV{SIP_ROOT_DIR} + PATH_SUFFIXES bin) -IF(SIP_INCLUDE_DIR) - GET_FILENAME_COMPONENT(SIP_PYTHONPATH "${SIP_INCLUDE_DIR}" PATH) - GET_FILENAME_COMPONENT(SIP_PYTHONPATH "${SIP_PYTHONPATH}" PATH) +IF(SIP_EXECUTABLE) + # Set path to sip's Python module + GET_FILENAME_COMPONENT(SIP_PYTHONPATH "${SIP_EXECUTABLE}" PATH) # /bin/sip -> /bin + GET_FILENAME_COMPONENT(SIP_PYTHONPATH "${SIP_PYTHONPATH}" PATH) # /bin -> SET(SIP_PYTHONPATH "${SIP_PYTHONPATH}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages") + + # Detect sip version + EXECUTE_PROCESS(COMMAND ${SIP_EXECUTABLE} "-V" + OUTPUT_VARIABLE SIP_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) ENDIF() -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SIP REQUIRED_VARS SIP_INCLUDE_DIR SIP_EXECUTABLE SIP_PYTHONPATH) +# Find sip-module executable (only for version >= 5) +IF(SIP_VERSION AND SIP_VERSION VERSION_GREATER_EQUAL "5") + FIND_PROGRAM(SIP_MODULE_EXECUTABLE + NAMES sip-module + HINTS $ENV{SIP_ROOT_DIR} + PATH_SUFFIXES bin) +ENDIF() +# Find header file (only for version < 5) +IF(NOT SIP_VERSION OR SIP_VERSION VERSION_LESS "5") + FIND_PATH(SIP_INCLUDE_DIR + NAMES sip.h + HINTS $ENV{SIP_ROOT_DIR} + PATH_SUFFIXES include python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m) +ENDIF() +INCLUDE(FindPackageHandleStandardArgs) +IF(SIP_VERSION AND SIP_VERSION VERSION_GREATER_EQUAL "5") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(SIP REQUIRED_VARS SIP_EXECUTABLE SIP_MODULE_EXECUTABLE SIP_PYTHONPATH) +ELSE() + FIND_PACKAGE_HANDLE_STANDARD_ARGS(SIP REQUIRED_VARS SIP_INCLUDE_DIR SIP_EXECUTABLE SIP_PYTHONPATH) +ENDIF() diff --git a/cmake/UseSIP.cmake b/cmake/UseSIP.cmake index 33ce2a4..7ca342f 100644 --- a/cmake/UseSIP.cmake +++ b/cmake/UseSIP.cmake @@ -109,9 +109,18 @@ MACRO(SIP_WRAP_SIP outfiles) SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_class_source}) ENDFOREACH() ENDFOREACH() + IF(SIP_VERSION AND SIP_VERSION VERSION_GREATER_EQUAL "5") + LIST(GET _sip_files 0 _main_sip_file) + ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sip.h + COMMAND ${SIP_MODULE_EXECUTABLE} --sip-h --target-dir ${CMAKE_CURRENT_BINARY_DIR} ${_main_sip_file} + DEPENDS ${_sip_files} + ) + SET(_extra_deps ${CMAKE_CURRENT_BINARY_DIR}/sip.h) + ENDIF() ADD_CUSTOM_COMMAND( OUTPUT ${_output} COMMAND ${SIP_EXECUTABLE} ${_options} ${CMAKE_CURRENT_SOURCE_DIR}/${_module_input} - MAIN_DEPENDENCY ${_module_input} + DEPENDS ${_module_input} ${_extra_deps} ) ENDMACRO(SIP_WRAP_SIP)