Fix building without Qt/GUI

This commit is contained in:
Martchus 2016-07-27 18:29:00 +02:00
parent e890b37459
commit 4caabbb148
2 changed files with 21 additions and 7 deletions

View File

@ -2,11 +2,12 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
# meta data # meta data
set(META_PROJECT_NAME passwordmanager) set(META_PROJECT_NAME passwordmanager)
set(META_PROJECT_TYPE application)
set(META_APP_NAME "Password Manager") set(META_APP_NAME "Password Manager")
set(META_APP_CATEGORIES "Utility") set(META_APP_CATEGORIES "Utility")
set(META_APP_AUTHOR "Martchus") set(META_APP_AUTHOR "Martchus")
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_APP_DESCRIPTION "A simple password store using AES-256-CBC encryption via OpenSSL.") set(META_APP_DESCRIPTION "A simple password store using AES-256-CBC encryption via OpenSSL")
set(META_VERSION_MAJOR 2) set(META_VERSION_MAJOR 2)
set(META_VERSION_MINOR 1) set(META_VERSION_MINOR 1)
set(META_VERSION_PATCH 1) set(META_VERSION_PATCH 1)
@ -22,6 +23,14 @@ set(HEADER_FILES
set(SRC_FILES set(SRC_FILES
cli/cli.cpp cli/cli.cpp
main.cpp main.cpp
)
set(GUI_HEADER_FILES
model/entryfiltermodel.cpp
model/entrymodel.cpp
model/fieldmodel.cpp
)
set(GUI_SRC_FILES
model/entryfiltermodel.cpp model/entryfiltermodel.cpp
model/entrymodel.cpp model/entrymodel.cpp
model/fieldmodel.cpp model/fieldmodel.cpp
@ -111,8 +120,10 @@ find_package(c++utilities 4.0.0 REQUIRED)
use_cpp_utilities() use_cpp_utilities()
# find qtutilities # find qtutilities
find_package(qtutilities 4.0.0 REQUIRED) if(WIDGETS_GUI OR QUICK_GUI)
use_qt_utilities() find_package(qtutilities 5.0.0 REQUIRED)
use_qt_utilities()
endif()
# find passwordfile # find passwordfile
find_package(passwordfile 3.1.0 REQUIRED) find_package(passwordfile 3.1.0 REQUIRED)
@ -120,8 +131,10 @@ use_password_file()
# include modules to apply configuration # include modules to apply configuration
include(BasicConfig) include(BasicConfig)
include(QtGuiConfig) if(WIDGETS_GUI OR QUICK_GUI)
include(QtConfig) include(QtGuiConfig)
include(QtConfig)
endif()
include(WindowsResources) include(WindowsResources)
include(AppTarget) include(AppTarget)
include(ShellCompletion) include(ShellCompletion)

View File

@ -16,12 +16,11 @@
#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK) #if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK)
# include <qtutilities/resources/qtconfigarguments.h> # include <qtutilities/resources/qtconfigarguments.h>
# include <QString>
#else #else
# include <c++utilities/application/fakeqtconfigarguments.h> # include <c++utilities/application/fakeqtconfigarguments.h>
#endif #endif
#include <QString>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
@ -65,10 +64,12 @@ int main(int argc, char *argv[])
} }
} else if(qtConfigArgs.areQtGuiArgsPresent()) { } else if(qtConfigArgs.areQtGuiArgsPresent()) {
// run Qt gui if no arguments, --qt-gui or --qt-quick-gui specified, a file might be specified // run Qt gui if no arguments, --qt-gui or --qt-quick-gui specified, a file might be specified
#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK)
QString file; QString file;
if(fileArg.isPresent()) { if(fileArg.isPresent()) {
file = QString::fromLocal8Bit(fileArg.values().front()); file = QString::fromLocal8Bit(fileArg.values().front());
} }
#endif
if(qtConfigArgs.qtWidgetsGuiArg().isPresent()) { if(qtConfigArgs.qtWidgetsGuiArg().isPresent()) {
#ifdef GUI_QTWIDGETS #ifdef GUI_QTWIDGETS
res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file); res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file);