Skip to content
This repository has been archived by the owner on May 8, 2021. It is now read-only.

Commit

Permalink
Add CMake build system
Browse files Browse the repository at this point in the history
add cmake building, with support for:
 * Qt4 / Qt5
 * Enable Updater support
 * Enable check for only one instance
  • Loading branch information
arthurzam committed Oct 30, 2015
1 parent 3c5d869 commit d8e5e45
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pro.user
build/
126 changes: 126 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
project(dukto)
cmake_minimum_required(VERSION 2.8.12)

OPTION(USE_QT5 "Build with qt5" OFF)
OPTION(USE_UPDATER "Add updater for application" OFF)
OPTION(USE_SINGLE_APP "Enable only single instance" OFF)

if(USE_UPDATER)
add_definitions("-DUPDATER")
endif()
if(USE_SINGLE_APP)
add_definitions("-DSINGLE_APP")
endif()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

if(USE_QT5)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Declarative REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
else()
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork QtDeclarative REQUIRED)
include("${QT_USE_FILE}")
add_definitions(${QT_DEFINITIONS})
include_directories(${QT_MKSPECS_DIR}/default)
endif()

set(DUKTO_HDR
platform.h
buddylistitemmodel.h
peer.h
ipaddressitemmodel.h
)

set(DUKTO_MOC_HDR
destinationbuddy.h
duktoprotocol.h
duktowindow.h
guibehind.h
miniwebserver.h
recentlistitemmodel.h
settings.h
systemtray.h
theme.h
qmlapplicationviewer/qmlapplicationviewer.h
)

set(DUKTO_SRC
main.cpp
guibehind.cpp
platform.cpp
buddylistitemmodel.cpp
duktoprotocol.cpp
miniwebserver.cpp
ipaddressitemmodel.cpp
recentlistitemmodel.cpp
settings.cpp
destinationbuddy.cpp
duktowindow.cpp
theme.cpp
systemtray.cpp
qmlapplicationviewer/qmlapplicationviewer.cpp
)

set(DUKTO_RESOURCES
qml.qrc
)

if(USE_UPDATER)
list(APPEND DUKTO_SRC updateschecker.cpp)
list(APPEND DUKTO_MOC_HDR updateschecker.h)
endif()

if(WIN32)
list(APPEND DUKTO_SRC ecwin7.cpp)
list(APPEND DUKTO_HDR ecwin7.h)
endif()

if(USE_QT5)
qt5_add_resources(DUKTO_RESOURCES_RCC ${DUKTO_RESOURCES})
else()
QT4_WRAP_CPP(DUKTO_MOC ${DUKTO_MOC_HDR})
QT4_ADD_RESOURCES(DUKTO_RESOURCES_RCC ${DUKTO_RESOURCES})
endif()

include_directories(qmlapplicationviewer)

if(USE_SINGLE_APP)
add_subdirectory(qtsingleapplication)
include_directories(qtsingleapplication)
endif()

add_executable(${PROJECT_NAME}
${DUKTO_HDR}
${DUKTO_SRC}
${DUKTO_MOC}
${DUKTO_RESOURCES_RCC})
if(USE_QT5)
qt5_use_modules(${PROJECT_NAME} Gui Widgets Network Declarative)
set(QT_LIBRARIES "")
endif()

if(USE_SINGLE_APP)
add_dependencies(${PROJECT_NAME} qtsingleapplication)
link_directories("${CMAKE_CURRENT_BINARY_DIR}/qtsingleapplication")
target_link_libraries(${PROJECT_NAME} qtsingleapplication)
endif()

target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})

if(WIN32)
target_link_libraries(${PROJECT_NAME} libWs2_32 libole32 libNetapi32)
endif()

if(UNIX AND NOT APPLE)
install(TARGETS ${PROJECT_NAME}
DESTINATION bin)
install(FILES dukto.png
DESTINATION share/pixmaps/)
install(FILES dukto.desktop
DESTINATION share/applications/)
endif()
58 changes: 25 additions & 33 deletions dukto.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,18 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = dukto
TEMPLATE = app

win32:RC_FILE = dukto.rc
win32:LIBS += libWs2_32 libole32 libNetapi32

mac:ICON = dukto.icns

VERSION = 6.0.0

# Smart Installer package's UID
# This UID is from the protected range and therefore the package will
# fail to install if self-signed. By default qmake uses the unprotected
# range value if unprotected UID is defined for the application and
# 0x2002CCCF value if protected UID is given to the application
#symbian:DEPLOYMENT.installer_header = 0x2002CCCF

# Allow network access on Symbian
symbian:TARGET.CAPABILITY += NetworkServices
unix {
target.path = /usr/bin

icon.path = /usr/share/pixmaps
icon.files = dukto.png
INSTALLS += icon

unix {
target.path = /usr/bin

icon.path = /usr/share/pixmaps
icon.files = dukto.png
INSTALLS += icon

desktop.path = /usr/share/applications/
desktop.files = dukto.desktop
INSTALLS += desktop
desktop.path = /usr/share/applications/
desktop.files = dukto.desktop
INSTALLS += desktop
}

# If your application uses the Qt Mobility libraries, uncomment the following
Expand All @@ -59,7 +43,6 @@ SOURCES += main.cpp \
settings.cpp \
destinationbuddy.cpp \
duktowindow.cpp \
ecwin7.cpp \
theme.cpp \
updateschecker.cpp \
systemtray.cpp
Expand All @@ -80,24 +63,33 @@ HEADERS += \
settings.h \
destinationbuddy.h \
duktowindow.h \
ecwin7.h \
theme.h \
updateschecker.h \
systemtray.h

RESOURCES += \
qml.qrc

DEFINES += UPDATER SINGLE_APP
include(qtsingleapplication/qtsingleapplication.pri)

OTHER_FILES +=






OTHER_FILES += CMakeLists.txt

win32 {
RC_FILE = dukto.rc
LIBS += libWs2_32 libole32 libNetapi32
HEADERS += ecwin7.h
SOURCES += ecwin7.cpp
}

mac:ICON = dukto.icns

# Smart Installer package's UID
# This UID is from the protected range and therefore the package will
# fail to install if self-signed. By default qmake uses the unprotected
# range value if unprotected UID is defined for the application and
# 0x2002CCCF value if protected UID is given to the application
#symbian:DEPLOYMENT.installer_header = 0x2002CCCF

# Allow network access on Symbian
symbian:TARGET.CAPABILITY += NetworkServices
3 changes: 1 addition & 2 deletions ecwin7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "ecwin7.h"

// Windows only GUID definitions
#if defined(Q_OS_WIN)
#include "ecwin7.h"
DEFINE_GUID(CLSID_TaskbarList,0x56fdf344,0xfd6d,0x11d0,0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90);
DEFINE_GUID(IID_ITaskbarList3,0xea1afb91,0x9e28,0x4b86,0x90,0xE9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf);

Expand Down
10 changes: 8 additions & 2 deletions guibehind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@

GuiBehind::GuiBehind(DuktoWindow* view) :
QObject(NULL), mView(view), mShowBackTimer(NULL), mPeriodicHelloTimer(NULL),
mClipboard(NULL), mMiniWebServer(NULL), mSettings(NULL), mDestBuddy(NULL),
mUpdatesChecker(NULL)
mClipboard(NULL), mMiniWebServer(NULL), mSettings(NULL), mDestBuddy(NULL)
#ifdef UPDATER
,mUpdatesChecker(NULL)
#endif
{
// Status variables
mView->setGuiBehindReference(this);
Expand Down Expand Up @@ -138,10 +140,12 @@ GuiBehind::GuiBehind(DuktoWindow* view) :
qsrand(QDateTime::currentDateTime().toTime_t());;
mShowBackTimer->start(10000);

#ifdef UPDATER
// Enqueue check for updates
mUpdatesChecker = new UpdatesChecker();
connect(mUpdatesChecker, SIGNAL(updatesAvailable()), this, SLOT(showUpdatesMessage()));
QTimer::singleShot(2000, mUpdatesChecker, SLOT(start()));
#endif

// TEMP
// Peer p(QHostAddress("172.16.3.3"), "Pippo at Pluto (Macintosh)");
Expand All @@ -153,7 +157,9 @@ GuiBehind::~GuiBehind()
{
mDuktoProtocol.sayGoodbye();

#ifdef UPDATER
if (mUpdatesChecker) mUpdatesChecker->deleteLater();
#endif
if (mMiniWebServer) mMiniWebServer->deleteLater();
if (mShowBackTimer) mShowBackTimer->deleteLater();
if (mPeriodicHelloTimer) mPeriodicHelloTimer->deleteLater();
Expand Down
4 changes: 4 additions & 0 deletions guibehind.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#include "duktoprotocol.h"
#include "theme.h"

#ifdef UPDATER
class UpdatesChecker;
#endif
class MiniWebServer;
class Settings;
class DuktoWindow;
Expand Down Expand Up @@ -190,7 +192,9 @@ public slots:
IpAddressItemModel mIpAddresses;
DuktoProtocol mDuktoProtocol;
Theme mTheme;
#ifdef UPDATER
UpdatesChecker *mUpdatesChecker;
#endif

int mCurrentTransferProgress;
QString mCurrentTransferBuddy;
Expand Down
6 changes: 3 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define SYMBIAN
#endif

#ifndef SYMBIAN
#if !defined(SYMBIAN) && defined(SINGLE_APP)
#include "qtsingleapplication.h"
#endif

Expand All @@ -42,7 +42,7 @@ int main(int argc, char *argv[])
qputenv("QML_ENABLE_TEXT_IMAGE_CACHE", "true");
#endif

#if defined(SYMBIAN)
#if defined(SYMBIAN) || !defined(SINGLE_APP)
QApplication app(argc, argv);
#else
// Check for single running instance
Expand All @@ -54,7 +54,7 @@ int main(int argc, char *argv[])
#endif

DuktoWindow viewer;
#ifndef SYMBIAN
#if !defined(SYMBIAN) && defined(SINGLE_APP)
app.setActivationWindow(&viewer, true);
SystemTray tray(viewer);
tray.show();
Expand Down
34 changes: 34 additions & 0 deletions qtsingleapplication/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 2.8.12)

set(SINGLEAPP-SOURCES
qtsingleapplication.cpp
qtlocalpeer.cpp
)

set(SINGLEAPP-MOC-HEADERS
qtsingleapplication.h
qtlocalpeer.h
)

if(USE_QT5)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
set(QT_LIBRARIES "")
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
else()
find_package(Qt4 COMPONENTS QtCore QtNetwork REQUIRED)
include("${QT_USE_FILE}")
add_definitions(${QT_DEFINITIONS})
QT4_WRAP_CPP(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS})
include_directories(${QT_MKSPECS_DIR}/default)
endif()

ADD_LIBRARY(qtsingleapplication STATIC
${SINGLEAPP-SOURCES}
${SINGLEAPP-SOURCES-MOC}
)

if(USE_QT5)
qt5_use_modules(qtsingleapplication Network Widgets)
endif()
2 changes: 2 additions & 0 deletions qtsingleapplication/qtsingleapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
**
****************************************************************************/

#ifdef SINGLE_APP

#include "qtsingleapplication.h"
#include "qtlocalpeer.h"
Expand Down Expand Up @@ -296,3 +297,4 @@ void QtSingleApplication::activateWindow()
\obsolete
*/
#endif
3 changes: 1 addition & 2 deletions qtsingleapplication/qtsingleapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
** contact the sales department at [email protected].
**
****************************************************************************/

#ifndef QT_SINGALAPPLICATION_H
#if defined(SINGLE_APP) && !defined(QT_SINGALAPPLICATION_H)
#define QT_SINGALAPPLICATION_H

#include <QApplication>
Expand Down
2 changes: 2 additions & 0 deletions qtsingleapplication/qtsingleapplication.pri
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp
HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h
INCLUDEPATH += $$PWD

OTHER_FILES += $$PWD/CMakeLists.txt
4 changes: 2 additions & 2 deletions recentlistitemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ RecentListItemModel::RecentListItemModel() :
#endif
}

Q_CONSTEXPR double BYTES_TO_KB = 1.0 / 1024;
Q_CONSTEXPR double BYTES_TO_MB = 1.0 / 1048576;
const double BYTES_TO_KB = 1.0 / 1024;
const double BYTES_TO_MB = 1.0 / 1048576;

void RecentListItemModel::addRecent(QString name, QString value, QString type, QString sender, qint64 size)
{
Expand Down
Loading

0 comments on commit d8e5e45

Please sign in to comment.