Ticket #46902: cmake_gui_qt4_qt5.diff

File cmake_gui_qt4_qt5.diff, 12.0 KB (added by michaelld (Michael Dickens), 9 years ago)
  • Portfile

     
    118118    }
    119119}
    120120
    121 variant gui description {Qt4 based cmake-gui} {
    122     PortGroup qt4 1.0
    123     patchfiles-append patch-CMakeLists.txt.diff
    124     configure.args-append --qt-gui --qt-qmake=${qt_qmake_cmd}
     121variant gui description {Build Qt-based cmake-gui} {
     122    configure.args-append --qt-gui
    125123}
    126124
     125if {[variant_isset gui]} {
     126
     127    variant qt4 conflicts qt5 description {Build Qt GUI using Qt4} {
     128        PortGroup qt4 1.0
     129        patchfiles-append patch-qt4gui.diff
     130        configure.args-append --qt-qmake=${qt_qmake_cmd}
     131    }
     132
     133    variant qt5 conflicts qt4 description {Build Qt GUI using Qt5} {
     134        PortGroup qt5 1.0
     135        patchfiles-append patch-qt5gui.diff
     136        configure.args-append --qt-qmake=${qt_qmake_cmd}
     137    }
     138
     139    if {![variant_isset qt4] && ![variant_isset qt5]} {
     140        default_variants +qt4
     141    }
     142
     143    if {![variant_isset qt4] && ![variant_isset qt5]} {
     144        ui_error "\n\nYou must select either the +qt4 or +qt5 variant when building the GUI.\n"
     145        return -code error "Invalid variant selection"
     146    }
     147} else {
     148    configure.args-append --no-qt-gui
     149}
     150
    127151variant docs description {Build documentation: HTML and manpages} {
    128152    configure.args-append \
    129153        --mandir=share/man \
  • files/patch-CMakeLists.txt.diff

     
    1 --- CMakeLists.txt.orig
    2 +++ CMakeLists.txt
    3 @@ -476,7 +476,7 @@ if(BUILD_CursesDialog)
    4  endif()
    5  
    6  if(BUILD_QtDialog)
    7 -  if(APPLE)
    8 +  if(FALSE)
    9      set(CMAKE_BUNDLE_VERSION
    10        "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
    11      set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
    12 --- Source/QtDialog/CMakeLists.txt
    13 +++ Source/QtDialog/CMakeLists.txt
    14 @@ -99,7 +99,7 @@ set(SRCS ${SRCS} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS})
    15  if(WIN32)
    16    set(SRCS ${SRCS} CMakeSetup.rc)
    17  endif()
    18 -if(APPLE)
    19 +if(FALSE)
    20    set(SRCS ${SRCS} CMakeSetup.icns)
    21    set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
    22    set_source_files_properties(CMakeSetup.icns PROPERTIES
    23 @@ -115,13 +115,13 @@ endif()
    24  
    25  set(CMAKE_INCLUDE_CURRENT_DIR ON)
    26  
    27 -add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS})
    28 +add_executable(cmake-gui WIN32 ${SRCS})
    29  target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${CMake_QT_LIBRARIES})
    30  if(Qt_BIN_DIR)
    31    set_property(TARGET cmake-gui PROPERTY Qt_BIN_DIR ${Qt_BIN_DIR})
    32  endif()
    33  
    34 -if(APPLE)
    35 +if(FALSE)
    36    file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line
    37      LIMIT_COUNT 1 REGEX "^Copyright 2000-20[0-9][0-9] Kitware")
    38  
    39 @@ -153,7 +153,7 @@ if(UNIX)
    40    install(FILES cmakecache.xml DESTINATION share/mime/packages )
    41  endif()
    42  
    43 -if(APPLE)
    44 +if(FALSE)
    45    set(CMAKE_POSTFLIGHT_SCRIPT
    46      "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
    47    set(CMAKE_POSTUPGRADE_SCRIPT
    48 @@ -166,7 +166,7 @@ if(APPLE)
    49                  WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
    50  endif()
    51  
    52 -if(APPLE OR WIN32)
    53 +if(WIN32)
    54    # install rules for including 3rd party libs such as Qt
    55    # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
    56    set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}")
  • files/patch-qt4gui.diff

     
     1--- Source/QtDialog/CMakeLists.txt.orig
     2+++ Source/QtDialog/CMakeLists.txt
     3@@ -14,58 +14,6 @@ project(QtDialog)
     4 if(POLICY CMP0020)
     5   cmake_policy(SET CMP0020 NEW) # Drop when CMake >= 2.8.11 required
     6 endif()
     7-find_package(Qt5Widgets QUIET)
     8-if (Qt5Widgets_FOUND)
     9-  include_directories(${Qt5Widgets_INCLUDE_DIRS})
     10-  add_definitions(${Qt5Widgets_DEFINITONS})
     11-  macro(qt4_wrap_ui)
     12-    qt5_wrap_ui(${ARGN})
     13-  endmacro()
     14-  macro(qt4_wrap_cpp)
     15-    qt5_wrap_cpp(${ARGN})
     16-  endmacro()
     17-  macro(qt4_add_resources)
     18-    qt5_add_resources(${ARGN})
     19-  endmacro()
     20-  set(CMake_QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
     21-  set(QT_QTMAIN_LIBRARY ${Qt5Core_QTMAIN_LIBRARIES})
     22-
     23-  # Remove this when the minimum version of Qt is 4.6.
     24-  add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
     25-
     26-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
     27-
     28-  # We need to install Cocoa platform plugin and add qt.conf for Qt5 on Mac.
     29-  # FIXME: This should be part of Qt5 CMake scripts, but unfortunatelly
     30-  # Qt5 Mac support is missing there.
     31-  if(APPLE)
     32-    macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var)
     33-      get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION)
     34-      if(EXISTS "${_qt_plugin_path}")
     35-        get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME)
     36-        get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH)
     37-        get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME)
     38-        set(_qt_plugin_dest "${CMAKE_INSTALL_PREFIX}/PlugIns/${_qt_plugin_type}")
     39-        install(FILES "${_qt_plugin_path}"
     40-          DESTINATION "${_qt_plugin_dest}")
     41-        set(${_qt_plugins_var}
     42-          "${${_qt_plugins_var}};${_qt_plugin_dest}/${_qt_plugin_file}")
     43-      else()
     44-        message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found")
     45-      endif()
     46-    endmacro()
     47-    install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS)
     48-    file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
     49-      "[Paths]\nPlugins = PlugIns\n")
     50-    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
     51-      DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources")
     52-  endif()
     53-
     54-  if(WIN32 AND TARGET Qt5::Core)
     55-    get_property(_Qt5_Core_LOCATION TARGET Qt5::Core PROPERTY LOCATION)
     56-    get_filename_component(Qt_BIN_DIR "${_Qt5_Core_LOCATION}" PATH)
     57-  endif()
     58-else()
     59   set(QT_MIN_VERSION "4.4.0")
     60   find_package(Qt4 REQUIRED)
     61   if(NOT QT4_FOUND)
     62@@ -83,7 +31,6 @@ else()
     63       set(Qt_BIN_DIR ${_Qt_BIN_DIR})
     64     endif()
     65   endif()
     66-endif()
     67 
     68 set(SRCS
     69   AddCacheEntry.cxx
     70@@ -125,7 +72,7 @@ set(SRCS ${SRCS} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS})
     71 if(WIN32)
     72   set(SRCS ${SRCS} CMakeSetup.rc)
     73 endif()
     74-if(APPLE)
     75+if(APPLEBUNDLE)
     76   set(SRCS ${SRCS} CMakeSetup.icns)
     77   set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
     78   set_source_files_properties(CMakeSetup.icns PROPERTIES
     79@@ -141,13 +88,13 @@ endif()
     80 
     81 set(CMAKE_INCLUDE_CURRENT_DIR ON)
     82 
     83-add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS})
     84+add_executable(cmake-gui WIN32 ${SRCS})
     85 target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${CMake_QT_LIBRARIES})
     86 if(Qt_BIN_DIR)
     87   set_property(TARGET cmake-gui PROPERTY Qt_BIN_DIR ${Qt_BIN_DIR})
     88 endif()
     89 
     90-if(APPLE)
     91+if(APPLEBUNDLE)
     92   file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line
     93     LIMIT_COUNT 1 REGEX "^Copyright 2000-20[0-9][0-9] Kitware")
     94 
     95@@ -179,16 +126,16 @@ if(UNIX)
     96   install(FILES cmakecache.xml DESTINATION share/mime/packages )
     97 endif()
     98 
     99-if(APPLE)
     100+if(APPLEBUNDLE)
     101   install(CODE "execute_process(COMMAND ln -s \"../MacOS/CMake\" cmake-gui
     102                 WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
     103 endif()
     104 
     105-if(APPLE OR WIN32)
     106+if(APPLEBUNDLE OR WIN32)
     107   # install rules for including 3rd party libs such as Qt
     108   # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
     109   set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}")
     110-  if(APPLE)
     111+  if(APPLEBUNDLE)
     112     set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/CMake")
     113   endif()
     114   install(CODE "
     115--- CMakeLists.txt.orig
     116+++ CMakeLists.txt
     117@@ -505,15 +505,6 @@
     118       set(CMAKE_BUNDLE_VERSION
     119         "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
     120       set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
     121-      # make sure CMAKE_INSTALL_PREFIX ends in /
     122-      string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
     123-      math(EXPR LEN "${LEN} -1" )
     124-      string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
     125-      if(NOT "${ENDCH}" STREQUAL "/")
     126-        set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
     127-      endif()
     128-      set(CMAKE_INSTALL_PREFIX
     129-        "${CMAKE_INSTALL_PREFIX}CMake.app/Contents")
     130     endif()
     131 
     132     set(QT_NEED_RPATH FALSE)
  • files/patch-qt5gui.diff

     
     1--- Source/QtDialog/CMakeLists.txt.orig
     2+++ Source/QtDialog/CMakeLists.txt
     3@@ -15,7 +15,10 @@ if(POLICY CMP0020)
     4   cmake_policy(SET CMP0020 NEW) # Drop when CMake >= 2.8.11 required
     5 endif()
     6 find_package(Qt5Widgets QUIET)
     7-if (Qt5Widgets_FOUND)
     8+if (NOT Qt5Widgets_FOUND)
     9+  message(FATAL_ERROR "Qt5 required but not found")
     10+endif()
     11+
     12   include_directories(${Qt5Widgets_INCLUDE_DIRS})
     13   add_definitions(${Qt5Widgets_DEFINITONS})
     14   macro(qt4_wrap_ui)
     15@@ -65,25 +68,6 @@ if (Qt5Widgets_FOUND)
     16     get_property(_Qt5_Core_LOCATION TARGET Qt5::Core PROPERTY LOCATION)
     17     get_filename_component(Qt_BIN_DIR "${_Qt5_Core_LOCATION}" PATH)
     18   endif()
     19-else()
     20-  set(QT_MIN_VERSION "4.4.0")
     21-  find_package(Qt4 REQUIRED)
     22-  if(NOT QT4_FOUND)
     23-    message(SEND_ERROR "Failed to find Qt 4.4 or greater.")
     24-    return()
     25-  endif()
     26-
     27-  include(${QT_USE_FILE})
     28-
     29-  set(CMake_QT_LIBRARIES ${QT_LIBRARIES})
     30-
     31-  if(WIN32 AND EXISTS "${QT_QMAKE_EXECUTABLE}")
     32-    get_filename_component(_Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH)
     33-    if(EXISTS "${_Qt_BIN_DIR}/QtCore4.dll")
     34-      set(Qt_BIN_DIR ${_Qt_BIN_DIR})
     35-    endif()
     36-  endif()
     37-endif()
     38 
     39 set(SRCS
     40   AddCacheEntry.cxx
     41@@ -125,7 +72,7 @@
     42 if(WIN32)
     43   set(SRCS ${SRCS} CMakeSetup.rc)
     44 endif()
     45-if(APPLE)
     46+if(APPLEBUNDLE)
     47   set(SRCS ${SRCS} CMakeSetup.icns)
     48   set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
     49   set_source_files_properties(CMakeSetup.icns PROPERTIES
     50@@ -141,13 +88,13 @@ endif()
     51 
     52 set(CMAKE_INCLUDE_CURRENT_DIR ON)
     53 
     54-add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS})
     55+add_executable(cmake-gui WIN32 ${SRCS})
     56 target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${CMake_QT_LIBRARIES})
     57 if(Qt_BIN_DIR)
     58   set_property(TARGET cmake-gui PROPERTY Qt_BIN_DIR ${Qt_BIN_DIR})
     59 endif()
     60 
     61-if(APPLE)
     62+if(APPLEBUNDLE)
     63   file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line
     64     LIMIT_COUNT 1 REGEX "^Copyright 2000-20[0-9][0-9] Kitware")
     65 
     66@@ -179,16 +126,16 @@
     67   install(FILES cmakecache.xml DESTINATION share/mime/packages )
     68 endif()
     69 
     70-if(APPLE)
     71+if(APPLEBUNDLE)
     72   install(CODE "execute_process(COMMAND ln -s \"../MacOS/CMake\" cmake-gui
     73                 WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
     74 endif()
     75 
     76-if(APPLE OR WIN32)
     77+if(APPLEBUNDLE OR WIN32)
     78   # install rules for including 3rd party libs such as Qt
     79   # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
     80   set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}")
     81-  if(APPLE)
     82+  if(APPLEBUNDLE)
     83     set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/CMake")
     84   endif()
     85   install(CODE "
     86--- CMakeLists.txt.orig
     87+++ CMakeLists.txt
     88@@ -505,15 +505,6 @@
     89       set(CMAKE_BUNDLE_VERSION
     90         "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
     91       set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
     92-      # make sure CMAKE_INSTALL_PREFIX ends in /
     93-      string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
     94-      math(EXPR LEN "${LEN} -1" )
     95-      string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
     96-      if(NOT "${ENDCH}" STREQUAL "/")
     97-        set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
     98-      endif()
     99-      set(CMAKE_INSTALL_PREFIX
     100-        "${CMAKE_INSTALL_PREFIX}CMake.app/Contents")
     101     endif()
     102 
     103     set(QT_NEED_RPATH FALSE)