浏览代码

Modify CMakeList.txt file

Kandrashin Denis 13 年之前
父节点
当前提交
60a5c3a92b
共有 5 个文件被更改,包括 139 次插入14 次删除
  1. 28 10
      CMakeLists.txt
  2. 100 0
      rpmbuild/fb2edit.spec
  3. 9 2
      source/fb2app.cpp
  4. 1 1
      source/fb2code.cpp
  5. 1 1
      source/fb2main.cpp

+ 28 - 10
CMakeLists.txt

@@ -10,6 +10,13 @@
 cmake_minimum_required(VERSION 2.6.0)
 
 project(fb2edit)
+set(PACKAGE_VERSION "0.0.2")
+set(PACKAGE_NAME ${PROJECT_NAME})
+set(PACKAGE_VENDOR "LinTest")
+set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+set(PACKAGE_BUGREPORT "mail@lintest.ru")
+
+message( STATUS "PACKAGE_NAME = ${PACKAGE_STRING}")
 
 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/3rdparty/cmake)
 
@@ -17,19 +24,14 @@ find_package( Qt4 4.7.0 COMPONENTS QtCore QtGui QtMain QtNetwork QtWebkit QtXml
 find_package( QScintilla )
 find_package( LibXML2 )
 
-include(${QT_USE_FILE})
-add_definitions(${QT_DEFINITIONS})
-add_definitions(${LIBXML2_DEFINITIONS})
-
-if (LIBXML2_FOUND) 
-    add_definitions(-DFB2_USE_LIBXML2)
-endif (LIBXML2_FOUND) 
-
 file( GLOB FB2_HEAD source/*.hpp     )
 file( GLOB FB2_SRCS source/*.cpp     )
 file( GLOB FB2_UIS  source/*.ui      )
 file( GLOB FB2_TSS  source/ts/*.ts   )
 
+set(FB2_DEFINITIONS "PACKAGE_NAME=\"${PACKAGE_NAME}\"; PACKAGE_VENDOR=\"${PACKAGE_VENDOR}\"; PACKAGE_VERSION=\"${PACKAGE_VERSION}\"")
+set_source_files_properties( source/fb2app.cpp PROPERTIES COMPILE_DEFINITIONS "${FB2_DEFINITIONS}")
+
 set(FB2_RES
     3rdparty/gnome/gnome.qrc
     source/js/javascript.qrc
@@ -44,9 +46,25 @@ qt4_wrap_ui(UI_HEADERS ${FB2_UIS})
 qt4_wrap_cpp(MOC_SRCS ${FB2_HEAD})
 qt4_add_resources(RCC_SRCS ${FB2_RES})
 qt4_add_translation(QMS_FILES ${FB2_TSS})
-include_directories(${CMAKE_BINARY_DIR} ${QSCINTILLA_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIRS})
+
 add_executable(fb2edit ${FB2_SRCS} ${FB2_HEAD} ${UI_HEADERS} ${MOC_SRCS} ${RCC_SRCS} ${QMS_FILES})
-target_link_libraries(fb2edit ${QT_LIBRARIES} ${QSCINTILLA_LIBRARIES} ${LIBXML2_LIBRARIES})
+
+include(${QT_USE_FILE})
+include_directories(${CMAKE_BINARY_DIR})
+target_link_libraries(fb2edit ${QT_LIBRARIES})
+add_definitions(${QT_DEFINITIONS})
+
+if (QSCINTILLA_FOUND) 
+    include_directories(${QSCINTILLA_INCLUDE_DIR})
+    target_link_libraries(fb2edit ${QSCINTILLA_LIBRARIES})
+endif (QSCINTILLA_FOUND) 
+
+if (LIBXML2_FOUND) 
+    include_directories(${LIBXML2_INCLUDE_DIRS})
+    target_link_libraries(fb2edit ${LIBXML2_LIBRARIES})
+    add_definitions(${LIBXML2_DEFINITIONS})
+    add_definitions(-DFB2_USE_LIBXML2)
+endif (LIBXML2_FOUND) 
 
 set(LINUX_DESKTOP_FILE desktop/fb2edit.desktop)
 set(LINUX_DESKTOP_ICON desktop/fb2edit048.png)

+ 100 - 0
rpmbuild/fb2edit.spec

@@ -0,0 +1,100 @@
+#
+# spec file for package fb2edit
+#
+# Copyright (c) 2012 Denis Kandrashin, Kyrill Detinov
+# This file and all modifications and additions to the pristine
+# package are under the same license as the package itself.
+#
+
+Name:           fb2edit
+Version:        0.0.1
+Release:        0
+License:        GPL-3.0
+Summary:        FB2 Files Editor
+Url:            http://fb2edit.lintest.ru
+Group:          Productivity/Text/Editors
+Source0:        fb2edit-0.0.1.tar.bz2
+BuildRequires:  cmake
+BuildRequires:  desktop-file-utils
+BuildRequires:  gcc-c++
+BuildRequires:  pkgconfig(QtWebKit) >= 4.7.0
+BuildRequires:  pkgconfig(libxml-2.0)
+BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+
+%if 0%{?fedora_version}
+BuildRequires:  qscintilla-devel
+%endif
+
+%if 0%{?mandriva_version}
+BuildRequires:  qscintilla-qt4-devel
+%endif
+
+%if 0%{?suse_version}
+BuildRequires:  libqscintilla-devel
+BuildRequires:  update-desktop-files
+%endif
+
+%description
+fb2edit is an application for editing FB2 e-books files.
+
+Authors:
+--------
+    Denis Kandrashin <mail@lintest.ru>
+
+%prep
+%setup -q
+
+%build
+mkdir build
+cd build
+export CFLAGS="%{optflags}"
+export CXXFLAGS="%{optflags}"
+cmake .. -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?_smp_mflags} VERBOSE=1
+
+%install
+pushd build
+%make_install
+popd
+
+%if 0%{?fedora_version}
+desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop
+%endif
+
+%if 0%{?suse_version}
+%suse_update_desktop_file %{name}
+%endif
+
+%if 0%{?fedora_version}
+%post
+/usr/bin/update-desktop-database &> /dev/null || :
+
+%postun
+/usr/bin/update-desktop-database &> /dev/null || :
+%endif
+
+%if 0%{?mandriva_version}
+%post
+%update_desktop_database
+%update_menus
+
+%postun
+%clean_desktop_database
+%clean_menus
+%endif
+
+%if 0%{?suse_version}
+%post
+%desktop_database_post
+
+%postun
+%desktop_database_postun
+%endif
+
+%files
+%defattr(-,root,root,-)
+%{_bindir}/%{name}
+%{_datadir}/applications/%{name}.desktop
+%{_datadir}/pixmaps/%{name}.png
+
+%changelog

+ 9 - 2
source/fb2app.cpp

@@ -4,6 +4,12 @@
 #include "fb2app.hpp"
 #include "fb2main.hpp"
 
+#ifndef PACKAGE_NAME
+    #define PACKAGE_NAME "fb2edit"
+    #define PACKAGE_VENDOR "LinTest"
+    #define PACKAGE_VERSION "0.XX.XX"
+#endif  // PACKAGE_VERSION
+
 void Fb2Application::handleMessage(QtMsgType type, const char *msg)
 {
     /*
@@ -35,8 +41,9 @@ int main(int argc, char *argv[])
     Q_INIT_RESOURCE(fb2edit);
 
     Fb2Application app(argc, argv);
-    app.setApplicationName("fb2edit");
-    app.setOrganizationName("LinTest");
+    app.setApplicationName(QString(PACKAGE_NAME));
+    app.setOrganizationName(QString(PACKAGE_VENDOR));
+    app.setApplicationVersion(QString(PACKAGE_VERSION));
 
     QTranslator translator;
     translator.load(QLocale::system().name(), ":ts");

+ 1 - 1
source/fb2code.cpp

@@ -88,7 +88,7 @@ void Fb2CodeEdit::load(const QByteArray &array, const QList<int> &folds)
 
 void Fb2CodeEdit::zoomReset()
 {
-    if (codeEdit) codeEdit->zoomTo(1);
+    zoomTo(1);
 }
 
 #endif // FB2_USE_SCINTILLA

+ 1 - 1
source/fb2main.cpp

@@ -557,7 +557,7 @@ void Fb2MainWindow::setCurrentFile(const QString &filename)
         curFile = info.canonicalFilePath();
         title = info.fileName();
     }
-    title += QString(" - ") += qApp->applicationName();
+    title += QString(" - ") += qApp->applicationName() += QString(" ") += qApp->applicationVersion();
 
     setWindowModified(false);
     setWindowFilePath(curFile);