[packages/qcommandline] build qt5 library

glen glen at pld-linux.org
Sun Oct 2 17:12:16 CEST 2016


commit 2c661bec7fecf97ee551f422125565806dc57aa6
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun Oct 2 17:55:01 2016 +0300

    build qt5 library
    
    patch from fedora
    
    but seems broken and incomplete:
    - conflicting files with qt4 vs qt5
    - cmake from qt5 lookups libraries from qt4 package
    - qt5 cmake uses pkg-config from qt4 package
    - ...

 0001-new-ParameterFence-flag.patch      |  2 +
 0001-qt5.patch                          | 59 ++++++++++++++++++++
 qcommandline-fix-pkg-config-paths.patch |  2 +
 qcommandline.spec                       | 99 ++++++++++++++++++++++++++++++---
 4 files changed, 154 insertions(+), 8 deletions(-)
---
diff --git a/qcommandline.spec b/qcommandline.spec
index 4e550ef..51e2080 100644
--- a/qcommandline.spec
+++ b/qcommandline.spec
@@ -1,3 +1,8 @@
+#
+# Conditional build:
+%bcond_without	qt4		# build Qt4
+%bcond_without	qt5		# build Qt5
+
 Summary:	Command line parser for Qt programs
 Name:		qcommandline
 Version:	0.3.0
@@ -6,20 +11,32 @@ License:	LGPL v2+
 Group:		X11/Libraries
 Source0:	http://xf.iksaif.net/dev/qcommandline/%{name}-%{version}.tar.bz2
 # Source0-md5:	89cb472a54306c7399c55285e142a84c
-# http://dev.iksaif.net/issues/253
 Patch0:		%{name}-fix-pkg-config-paths.patch
-# http://dev.iksaif.net/issues/252 -- enhancements for PhantomJS
+Patch1:		0001-qt5.patch
 Patch101:	0001-new-ParameterFence-flag.patch
 Patch102:	0002-new-NoShortName-flag-to-allow-options-with-no-short-.patch
 Patch103:	0003-new-SuppressHelp-flag.patch
 URL:		http://xf.iksaif.net/dev/qcommandline.html
+%if %{with qt4}
 BuildRequires:	QtCore-devel
-BuildRequires:	cmake
-BuildRequires:	pkgconfig
 BuildRequires:	qt4-build
 BuildRequires:	qt4-qmake
+%endif
+%if %{with qt5}
+BuildRequires:	Qt5Core-devel
+BuildRequires:	qt5-build
+BuildRequires:	qt5-qmake
+%endif
+BuildRequires:	cmake
+BuildRequires:	pkgconfig
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
+#    File(s) packaged into both qcommandline-devel-0.3.0-1.i686 and qcommandline-qt5-devel-0.3.0-1.i686:
+#        /usr/include/qcommandline/QCommandLine
+#        /usr/include/qcommandline/qcommandline.h
+#        /usr/share/cmake/Modules/FindQCommandLine.cmake
+%define	_duplicate_files_terminate_build	0
+
 %description
 QCommandLine is a command line parser for Qt programs (like getopt).
 
@@ -33,6 +50,23 @@ Requires:	%{name} = %{version}-%{release}
 %description devel
 Development files for building against %{name}.
 
+%package qt5
+Summary:	Command line parser for Qt5 programs
+
+%description qt5
+QCommandLine is a command line parsing library for Qt5 programs (like
+getopt).
+
+Features include options, switches, parameters and automatic
+'--version' and '--help' generation.
+
+%package qt5-devel
+Summary:	Development files for %{name}-qt5
+Requires:	%{name}-qt5 = %{version}-%{release}
+
+%description qt5-devel
+Development files for building against %{name}.
+
 %prep
 %setup -q
 %patch0 -p1
@@ -40,20 +74,52 @@ Development files for building against %{name}.
 %patch102 -p1
 %patch103 -p1
 
+%if %{with qt5}
+set -- *
+install -d qt5
+cp -al "$@" qt5
+cd qt5
+%patch1 -p1
+# rename the library to libqcommandline-qt5 to distinguish it from the Qt4 build
+echo "set_target_properties(qcommandline PROPERTIES OUTPUT_NAME qcommandline-qt5)" >>CMakeLists.txt
+sed -i -e 's/-lqcommandline/-lqcommandline-qt5/' QCommandLine.pc.in
+sed -i -e 's/QCommandLine\.pc$/QCommandLine-qt5.pc/' CMakeLists.txt
+%endif
+
 %build
-install -d build
-cd build
+%if %{with qt4}
+install -d build-qt4
+cd build-qt4
 %cmake .. \
 	-DCMAKE_MODULES_INSTALL_DIR=%{_datadir}/cmake/Modules
 %{__make}
+cd ..
+%endif
+
+%if %{with qt5}
+install -d build-qt5
+cd build-qt5
+%cmake ../qt5 \
+	-DCMAKE_MODULES_INSTALL_DIR=%{_datadir}/cmake/Modules
+%{__make}
+cd ..
+%endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
-%{__make} -C build install \
+%if %{with qt4}
+%{__make} -C build-qt4 install \
 	DESTDIR=$RPM_BUILD_ROOT
-
 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+%endif
+
+%if %{with qt5}
+%{__make} -C build-qt5 install \
+	DESTDIR=$RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-qt5-%{version}
+cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-qt5-%{version}
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -61,6 +127,7 @@ rm -rf $RPM_BUILD_ROOT
 %post	-p /sbin/ldconfig
 %postun	-p /sbin/ldconfig
 
+%if %{with qt4}
 %files
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_libdir}/lib%{name}.so.*.*
@@ -73,3 +140,19 @@ rm -rf $RPM_BUILD_ROOT
 %{_pkgconfigdir}/QCommandLine.pc
 %{_datadir}/cmake/Modules/FindQCommandLine.cmake
 %{_examplesdir}/%{name}-%{version}
+%endif
+
+%if %{with qt5}
+%files qt5
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/lib%{name}-qt5.so.*.*
+%attr(755,root,root) %ghost %{_libdir}/lib%{name}-qt5.so.0
+
+%files qt5-devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/lib%{name}-qt5.so
+%{_includedir}/%{name}
+%{_pkgconfigdir}/QCommandLine-qt5.pc
+%{_datadir}/cmake/Modules/FindQCommandLine.cmake
+%{_examplesdir}/%{name}-qt5-%{version}
+%endif
diff --git a/0001-new-ParameterFence-flag.patch b/0001-new-ParameterFence-flag.patch
index 1b9db7b..f1405e3 100644
--- a/0001-new-ParameterFence-flag.patch
+++ b/0001-new-ParameterFence-flag.patch
@@ -1,3 +1,5 @@
+http://dev.iksaif.net/issues/252 -- enhancements for PhantomJS
+
 From 5a3e26fb4d2d3e90778d38e61854e193c9b26124 Mon Sep 17 00:00:00 2001
 From: Dan Callaghan <dcallagh at redhat.com>
 Date: Wed, 9 Jan 2013 19:40:22 +1000
diff --git a/0001-qt5.patch b/0001-qt5.patch
new file mode 100644
index 0000000..e142d9e
--- /dev/null
+++ b/0001-qt5.patch
@@ -0,0 +1,59 @@
+https://gitorious.org/qcommandline/qcommandline/merge_requests/3
+
+From fcdf5c29ac5a349fc7cce18f699075f262758ed9 Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <djc at djc.id.au>
+Date: Sat, 1 Jun 2013 20:07:44 +1000
+Subject: [PATCH] qt5
+
+---
+ CMakeLists.txt     | 7 ++-----
+ src/CMakeLists.txt | 4 ++--
+ 2 files changed, 4 insertions(+), 7 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index bdec0bf..4c3588d 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -42,8 +42,8 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*")
+   add_definitions("-DQT_NO_DEBUG_OUTPUT")
+ endif("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*")
+ 
+-# Find Qt4
+-find_package( Qt4 REQUIRED )
++# Find Qt5
++find_package( Qt5Core REQUIRED )
+ 
+ set( QT_DONT_USE_QTGUI TRUE )
+ 
+@@ -72,9 +72,6 @@ if (NOT WIN32)
+ 	   COMPONENT devel)
+ endif (NOT WIN32)
+ 
+-# Include the cmake file needed to use qt4
+-include( ${QT_USE_FILE} )
+-
+ # Subdirs
+ add_subdirectory(src)
+ if (QCOMMANDLINE_BUILD_EXAMPLES)
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 8b66e36..6b0dc41 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -32,12 +32,12 @@ install(FILES
+ 
+ set(qcommandline_MOC_HDRS qcommandline.h)
+ 
+-qt4_wrap_cpp(qcommandline_MOC_SRCS ${qcommandline_MOC_HDRS})
++qt5_wrap_cpp(qcommandline_MOC_SRCS ${qcommandline_MOC_HDRS})
+ 
+ set (qcommandline_SRCS qcommandline.cpp)
+ 
+ add_library (qcommandline ${qcommandline_SRCS} ${qcommandline_MOC_SRCS})
+-target_link_libraries( qcommandline ${QT_LIBRARIES})
++qt5_use_modules(qcommandline Core)
+ 
+ if(BUILD_SHARED_LIBS)
+   set_target_properties(qcommandline PROPERTIES
+-- 
+1.8.1.4
+
diff --git a/qcommandline-fix-pkg-config-paths.patch b/qcommandline-fix-pkg-config-paths.patch
index c374d8f..8578d9c 100644
--- a/qcommandline-fix-pkg-config-paths.patch
+++ b/qcommandline-fix-pkg-config-paths.patch
@@ -1,3 +1,5 @@
+http://dev.iksaif.net/issues/253
+
 From 8ea45650e589ad3db45e56d130841027542956df Mon Sep 17 00:00:00 2001
 From: Dan Callaghan <dcallagh at redhat.com>
 Date: Thu, 10 Jan 2013 10:45:27 +1000
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/qcommandline.git/commitdiff/fcf3722251a50cb8bd4ad4927ab29fb04bb27f74



More information about the pld-cvs-commit mailing list