Преглед изворни кода

Create file: CMakeLists.txt

Kandrashin Denis пре 13 година
родитељ
комит
f40ead0e2e
6 измењених фајлова са 155 додато и 79 уклоњено
  1. 61 0
      CMakeLists.txt
  2. 29 0
      cmake/FindLibXML2.cmake
  3. 57 0
      cmake/FindQScintilla.cmake
  4. 8 0
      desktop/fb2edit.desktop
  5. BIN
      desktop/fb2edit48.png
  6. 0 79
      source/fb2icon.cpp

+ 61 - 0
CMakeLists.txt

@@ -0,0 +1,61 @@
+########################################################
+#  
+#  This is a CMake configuration file.
+#  To use it you need CMake which can be 
+#  downloaded from here: 
+#    http://www.cmake.org/cmake/resources/software.html
+#
+#########################################################
+
+cmake_minimum_required(VERSION 2.6.0)
+
+project(fb2edit)
+
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
+
+find_package( Qt4 4.7.0 COMPONENTS QtCore QtGui QtMain QtNetwork QtWebkit QtXml QtXmlPatterns REQUIRED )
+find_package( QScintilla REQUIRED )
+find_package( LibXML2 REQUIRED )
+
+INCLUDE(${QT_USE_FILE})
+ADD_DEFINITIONS(${QT_DEFINITIONS})
+ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
+
+file( GLOB FB2_HEAD source/*.h       )
+file( GLOB FB2_SRCS source/*.cpp     )
+file( GLOB FB2_UIS  source/*.ui      )
+file( GLOB FB2_RES  source/res/*.qrc )
+file( GLOB FB2_TS   source/ts/*.ts   )
+
+set(CMAKE_IN_SOURCE_BUILD TRUE)
+
+add_definitions(-Wall -g)
+
+include(${QT_USE_FILE})
+qt4_wrap_ui(UI_HEADERS ${FB2_UIS})
+qt4_wrap_cpp(MOC_SRCS ${FB2_HEAD})
+qt4_add_resources(RCC_SRCS ${FB2_RES})
+qt4_create_translation(QM_FILES ${FB2_TS})
+#QT4_CREATE_TRANSLATION(LangSrcs ${Lang_files})
+include_directories(${CMAKE_BINARY_DIR} ${QSCINTILLA_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIRS})
+add_executable(fb2edit ${FB2_SRCS} ${FB2_HEAD} ${MOC_SRCS} ${RCC_SRCS} ${QM_FILES})
+target_link_libraries(fb2edit ${QT_LIBRARIES} ${QSCINTILLA_LIBRARIES} ${LIBXML2_LIBRARIES})
+
+set(LINUX_DESKTOP_FILE desktop/fb2edit.desktop)
+set(LINUX_DESKTOP_ICON desktop/fb2edit48.png)
+    
+#############################################################################
+# You can change the install location by 
+# running cmake like this:
+#
+#   cmake -DCMAKE_INSTALL_PREFIX=/new/install/prefix
+#
+# By default, the prefix is "/usr/local"
+# 
+if( UNIX AND NOT APPLE )
+    install( TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
+    install( FILES ${LINUX_DESKTOP_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications )
+    install( FILES ${LINUX_DESKTOP_ICON} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps RENAME fb2edit.png )
+    install( FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/fb2edit/translations )
+endif()
+

+ 29 - 0
cmake/FindLibXML2.cmake

@@ -0,0 +1,29 @@
+# - Try to find LibXml2
+# Once done this will define
+#  LIBXML2_FOUND - System has LibXml2
+#  LIBXML2_INCLUDE_DIRS - The LibXml2 include directories
+#  LIBXML2_LIBRARIES - The libraries needed to use LibXml2
+#  LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2
+
+find_package(PkgConfig)
+pkg_check_modules(PC_LIBXML QUIET libxml-2.0)
+set(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER})
+
+find_path(LIBXML2_INCLUDE_DIR libxml/xpath.h
+          HINTS ${PC_LIBXML_INCLUDEDIR} ${PC_LIBXML_INCLUDE_DIRS}
+          PATH_SUFFIXES libxml2 )
+
+find_library(LIBXML2_LIBRARY NAMES xml2 libxml2
+             HINTS ${PC_LIBXML_LIBDIR} ${PC_LIBXML_LIBRARY_DIRS} )
+
+set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY} )
+set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR} )
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(LibXml2  DEFAULT_MSG
+                                  LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
+
+mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY )
+

+ 57 - 0
cmake/FindQScintilla.cmake

@@ -0,0 +1,57 @@
+# - Try to find the QScintilla2 includes and library
+# which defines
+#
+# QSCINTILLA_FOUND - system has QScintilla2
+# QSCINTILLA_INCLUDE_DIR - where to find qextscintilla.h
+# QSCINTILLA_LIBRARIES - the libraries to link against to use QScintilla
+# QSCINTILLA_LIBRARY - where to find the QScintilla library (not for general use)
+
+# copyright (c) 2007 Thomas Moenicke thomas.moenicke@kdemail.net
+#
+# Redistribution and use is allowed according to the terms of the FreeBSD license.
+
+IF(NOT QT4_FOUND)
+    INCLUDE(FindQt4)
+ENDIF(NOT QT4_FOUND)
+
+SET(QSCINTILLA_FOUND FALSE)
+
+IF(QT4_FOUND)
+    FIND_PATH(QSCINTILLA_INCLUDE_DIR qsciglobal.h
+    "${QT_INCLUDE_DIR}/Qsci" /usr/include /usr/include/Qsci
+    )
+
+    SET(QSCINTILLA_NAMES ${QSCINTILLA_NAMES} qscintilla2 libqscintilla2)
+    FIND_LIBRARY(QSCINTILLA_LIBRARY
+        NAMES ${QSCINTILLA_NAMES}
+        PATHS ${QT_LIBRARY_DIR}
+    )
+
+    IF (QSCINTILLA_LIBRARY AND QSCINTILLA_INCLUDE_DIR)
+
+        SET(QSCINTILLA_LIBRARIES ${QSCINTILLA_LIBRARY})
+        SET(QSCINTILLA_FOUND TRUE)
+
+        IF (CYGWIN)
+            IF(BUILD_SHARED_LIBS)
+            # No need to define QSCINTILLA_USE_DLL here, because it's default for Cygwin.
+            ELSE(BUILD_SHARED_LIBS)
+            SET (QSCINTILLA_DEFINITIONS -DQSCINTILLA_STATIC)
+            ENDIF(BUILD_SHARED_LIBS)
+        ENDIF (CYGWIN)
+
+    ENDIF (QSCINTILLA_LIBRARY AND QSCINTILLA_INCLUDE_DIR)
+ENDIF(QT4_FOUND)
+
+IF (QSCINTILLA_FOUND)
+  IF (NOT QScintilla_FIND_QUIETLY)
+    MESSAGE(STATUS "Found QScintilla2: ${QSCINTILLA_LIBRARY}")
+  ENDIF (NOT QScintilla_FIND_QUIETLY)
+ELSE (QSCINTILLA_FOUND)
+  IF (QScintilla_FIND_REQUIRED)
+    MESSAGE(FATAL_ERROR "Could not find QScintilla library")
+  ENDIF (QScintilla_FIND_REQUIRED)
+ENDIF (QSCINTILLA_FOUND)
+
+MARK_AS_ADVANCED(QSCINTILLA_INCLUDE_DIR QSCINTILLA_LIBRARY)
+

+ 8 - 0
desktop/fb2edit.desktop

@@ -0,0 +1,8 @@
+[Desktop Entry]
+Name=fb2edit
+Exec=fb2edit
+Icon=fb2edit
+Type=Application
+Comment=FB2 file editor
+Categories=Office;FileTools;Qt;Viewer;TextTools;TextEditor;Utility;
+MimeType=application/x-fb2;

BIN
desktop/fb2edit48.png


+ 0 - 79
source/fb2icon.cpp

@@ -1,79 +0,0 @@
-#include <QApplication>
-#include <QTextDocument>
-#include <QTextCharFormat>
-#include <QVariant>
-
-static const int IconFormatType = 0x1000;
-
-//----------------------------------------------------------------------------
-// TextIconFormat
-//----------------------------------------------------------------------------
-
-class TextIconFormat : public QTextCharFormat
-{
-public:
-    static void TextIconFormat::insert(QTextCursor &cursor, const QString &name, const QString &text);
-
-    TextIconFormat(const QString &iconName, const QString &text);
-
-    enum Property {
-            IconName = QTextFormat::UserProperty + 1,
-            IconText = QTextFormat::UserProperty + 2
-    };
-};
-
-TextIconFormat::TextIconFormat(const QString &iconName, const QString &text)
-{
-    setObjectType(IconFormatType);
-    QTextFormat::setProperty(IconName, iconName);
-    QTextFormat::setProperty(IconText, text);
-}
-
-void TextIconFormat::insertIcon(QTextCursor &cursor, const QString &name, const QString &text)
-{
-    QTextCharFormat format = cursor.charFormat();
-    TextIconFormat icon(iconName, iconText);
-    cursor.insertText(QString(QChar::ObjectReplacementCharacter), icon);
-    cursor.setCharFormat(format);
-}
-
-//----------------------------------------------------------------------------
-// IconTextObjectInterface
-//----------------------------------------------------------------------------
-
-class TextIconHandler : public QObject, public QTextObjectInterface
-{
-    Q_OBJECT
-    Q_INTERFACES(QTextObjectInterface)
-public:
-    static void TextIconHandler::install(QTextDocument *doc);
-    TextIconHandler(QObject *parent = 0): QObject(parent) {}
-    virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format);
-    virtual void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format);
-};
-
-QSizeF TextIconHandler::intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format)
-{
-    Q_UNUSED(doc);
-    Q_UNUSED(posInDocument);
-
-    const QTextCharFormat charFormat = format.toCharFormat();
-    return IconsetFactory::iconPixmap(charFormat.stringProperty(TextIconFormat::IconName)).size();
-}
-
-void TextIconHandler::drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format)
-{
-    Q_UNUSED(doc);
-    Q_UNUSED(posInDocument);
-
-    const QTextCharFormat charFormat = format.toCharFormat();
-    const QPixmap pixmap = IconsetFactory::iconPixmap(charFormat.stringProperty(TextIconFormat::IconName));
-    painter->drawPixmap(rect, pixmap, pixmap.rect());
-}
-
-void TextIconHandler::install(QTextDocument *doc)
-{
-    static TextIconHandler *handler = 0;
-    if (!handler) handler = new TextIconHandler(qApp);
-    doc->documentLayout()->registerHandler(IconFormatType, handler);
-}