improved project files
This commit is contained in:
parent
515cb9fe84
commit
f2f2540bb9
160
CMakeLists.txt
160
CMakeLists.txt
|
@ -5,42 +5,122 @@ set(META_PROJECT_NAME passwordmanager)
|
|||
set(META_APP_NAME "Password Manager")
|
||||
set(META_APP_AUTHOR "Martchus")
|
||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||
set(META APP_DESCRIPTION "A simple password manager.")
|
||||
set(META_APP_DESCRIPTION "A simple password manager.")
|
||||
set(META_VERSION_MAJOR 2)
|
||||
set(META_VERSION_MINOR 0)
|
||||
set(META_VERSION_PATCH 9)
|
||||
|
||||
# define project
|
||||
project(${META_PROJECT_NAME})
|
||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
|
||||
# stringification of meta data
|
||||
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
||||
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
||||
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
||||
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
||||
set(APP_DESCRIPTION_STR "\"${APP_DESCRIPTION}\"")
|
||||
set(META_APP_VERSION_STR "\"${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}\"")
|
||||
set(META_APP_DESCRIPTION_STR "\"${META_APP_DESCRIPTION}\"")
|
||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
set(META_APP_VERSION_STR "\"${META_APP_VERSION}\"")
|
||||
|
||||
# add project files
|
||||
set(HEADER_FILES
|
||||
cli/cli.h
|
||||
model/entryfiltermodel.h
|
||||
model/entrymodel.h
|
||||
model/fieldmodel.h
|
||||
)
|
||||
set(SRC_FILES
|
||||
cli/cli.cpp
|
||||
main.cpp
|
||||
model/entryfiltermodel.cpp
|
||||
model/entrymodel.cpp
|
||||
model/fieldmodel.cpp
|
||||
)
|
||||
set(WIDGETS_HEADER_FILES
|
||||
gui/fielddelegate.h
|
||||
gui/initiategui.h
|
||||
gui/mainwindow.h
|
||||
gui/passwordgeneratordialog.h
|
||||
gui/stacksupport.h
|
||||
gui/undocommands.h
|
||||
)
|
||||
set(WIDGETS_SRC_FILES
|
||||
gui/fielddelegate.cpp
|
||||
gui/initiatequi.cpp
|
||||
gui/mainwindow.cpp
|
||||
gui/passwordgeneratordialog.cpp
|
||||
gui/stacksupport.cpp
|
||||
gui/undocommands.cpp
|
||||
resources/icons.qrc
|
||||
)
|
||||
set(QUICK_HEADER_FILES
|
||||
quickgui/applicationinfo.h
|
||||
quickgui/applicationpaths.h
|
||||
quickgui/initiatequick.h
|
||||
)
|
||||
set(QUICK_SRC_FILES
|
||||
quickgui/applicationinfo.cpp
|
||||
quickgui/initiatequick.cpp
|
||||
resources/icons.qrc
|
||||
resources/qml.qrc
|
||||
)
|
||||
set(TS_FILES
|
||||
translations/${META_PROJECT_NAME}_de_DE.ts
|
||||
translations/${META_PROJECT_NAME}_en_US.ts
|
||||
)
|
||||
|
||||
# define project
|
||||
project(${META_PROJECT_NAME})
|
||||
|
||||
# add configuration header
|
||||
configure_file (
|
||||
"${PROJECT_SOURCE_DIR}/config.h.in"
|
||||
"${PROJECT_BINARY_DIR}/config.h"
|
||||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/resources/config.h.in"
|
||||
"${PROJECT_BINARY_DIR}/resources/config.h"
|
||||
)
|
||||
include_directories("${PROJECT_BINARY_DIR}")
|
||||
|
||||
# add source and header files
|
||||
file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "main.cpp" "cli/*.cpp" "model/*.cpp")
|
||||
file(GLOB_RECURSE WIDGETS_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "gui/*.cpp" "resources/icons.qrc")
|
||||
file(GLOB_RECURSE HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "cli/*.h" "model/*.h")
|
||||
file(GLOB_RECURSE WIDGETS_HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "gui/*.h")
|
||||
# set "GUI-type" to WIN32 to hide console under windows
|
||||
if(WIN32)
|
||||
set(GUI_TYPE WIN32)
|
||||
endif(WIN32)
|
||||
|
||||
# enable only Qt Widgets GUI
|
||||
add_definitions(-DGUI_QTWIDGETS -DMODEL_UNDO_SUPPORT)
|
||||
# add windows resource file
|
||||
if(MINGW)
|
||||
# creation windows icon from png with ffmpeg if available
|
||||
find_program(FFMPEG_BIN ffmpeg avconv)
|
||||
if(FFMPEG_BIN)
|
||||
set(PNG_ICON_PATH "${PROJECT_SOURCE_DIR}/resources/icons/hicolor/128x128/apps/${META_PROJECT_NAME}.png")
|
||||
if(EXISTS ${PNG_ICON_PATH})
|
||||
set(WINDOWS_ICON_PATH "${PROJECT_BINARY_DIR}/${META_PROJECT_NAME}.ico")
|
||||
set(WINDOWS_ICON_RC_ENTRY "IDI_ICON1 ICON DISCARDABLE \"${WINDOWS_ICON_PATH}\"")
|
||||
add_custom_command(
|
||||
OUTPUT "${WINDOWS_ICON_PATH}"
|
||||
COMMAND ${FFMPEG_BIN} -y -i "${PNG_ICON_PATH}" -vf crop=iw-20:ih-20:10:10,scale=64:64 "${WINDOWS_ICON_PATH}"
|
||||
)
|
||||
endif()
|
||||
endif(FFMPEG_BIN)
|
||||
# create windows rc file from template
|
||||
set(WINDOWS_EXT "exe")
|
||||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/resources/windows.rc.in"
|
||||
"${PROJECT_BINARY_DIR}/resources/windows.rc"
|
||||
)
|
||||
# set windres as resource compiler
|
||||
set(RES_FILES "${PROJECT_BINARY_DIR}/resources/windows.rc")
|
||||
set(CMAKE_RC_COMPILER_INIT windres)
|
||||
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
||||
enable_language(RC)
|
||||
endif(MINGW)
|
||||
|
||||
# enable Qt Widgets GUI
|
||||
add_definitions(
|
||||
-DGUI_QTWIDGETS
|
||||
-DMODEL_UNDO_SUPPORT
|
||||
)
|
||||
|
||||
# check required Qt 5 modules
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5Gui REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5LinguistTools REQUIRED)
|
||||
|
||||
# enable moc, uic and rcc
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
@ -48,22 +128,56 @@ set(CMAKE_AUTOUIC ON)
|
|||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# executable and linking
|
||||
add_executable(${META_PROJECT_NAME} ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_HEADER_FILES} ${WIDGETS_SRC_FILES})
|
||||
target_link_libraries(${META_PROJECT_NAME} c++utilities qtutilities passwordfile Qt5::Core Qt5::Widgets)
|
||||
# enable lrelease
|
||||
qt5_add_translation(QM_FILES ${TS_FILES})
|
||||
ADD_CUSTOM_TARGET(translations ALL DEPENDS ${QM_FILES})
|
||||
|
||||
# enable C++11
|
||||
set_property(TARGET ${META_PROJECT_NAME} PROPERTY CXX_STANDARD 11)
|
||||
# executable and linking
|
||||
add_executable(${META_PROJECT_NAME} ${GUI_TYPE} ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_HEADER_FILES} ${WIDGETS_SRC_FILES} ${QM_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
||||
target_link_libraries(${META_PROJECT_NAME} c++utilities qtutilities passwordfile Qt5::Core Qt5::Widgets)
|
||||
set_target_properties(${META_PROJECT_NAME} PROPERTIES
|
||||
CXX_STANDARD 11
|
||||
)
|
||||
|
||||
# add install target
|
||||
install(TARGETS ${META_PROJECT_NAME}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
COMPONENT binary
|
||||
)
|
||||
install(FILES resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg
|
||||
DESTINATION share/icons/hicolor/scalable/apps
|
||||
COMPONENT desktop
|
||||
)
|
||||
install(FILES resources/desktop/applications/${META_PROJECT_NAME}.desktop
|
||||
DESTINATION share/applications
|
||||
COMPONENT desktop
|
||||
)
|
||||
install(FILES ${QM_FILES}
|
||||
DESTINATION share/${META_PROJECT_NAME}/translations
|
||||
COMPONENT localization
|
||||
)
|
||||
add_custom_target(install-binary
|
||||
DEPENDS ${META_PROJECT_NAME}
|
||||
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=binary -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||
)
|
||||
add_custom_target(install-desktop
|
||||
DEPENDS ${META_PROJECT_NAME}
|
||||
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=desktop -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||
)
|
||||
add_custom_target(install-localization
|
||||
DEPENDS ${META_PROJECT_NAME}
|
||||
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=localization -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||
)
|
||||
add_custom_target(strip-mingw-w64
|
||||
DEPENDS install-binary install-localization
|
||||
)
|
||||
add_custom_target(install-binary-strip
|
||||
DEPENDS ${META_PROJECT_NAME}
|
||||
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_COMPONENT=binary -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||
)
|
||||
add_custom_target(install-mingw-w64-strip
|
||||
DEPENDS install-binary-strip install-localization
|
||||
)
|
||||
|
||||
# manual stripping
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#ifndef APP_METADATA_AVAIL
|
||||
#define APP_METADATA_AVAIL
|
||||
#define PROJECT_NAME @META_PROJECT_NAME_STR@
|
||||
#define APP_NAME @META_APP_NAME_STR@
|
||||
#define APP_VERSION @META_APP_VERSION_STR@
|
||||
#define APP_AUTHOR @META_APP_AUTHOR_STR@
|
||||
#define APP_URL @META_APP_URL_STR@
|
||||
#define APP_DESCRIPTION @META_APP_DESCRIPTION_STR@
|
||||
#endif // APP_METADATA_AVAIL
|
56
general.pri
56
general.pri
|
@ -1,28 +1,12 @@
|
|||
#dirs
|
||||
# specify build directories for moc, object and rcc files
|
||||
MOC_DIR = ./moc
|
||||
OBJECTS_DIR = ./obj
|
||||
RCC_DIR = ./res
|
||||
# compiler flags
|
||||
|
||||
# compiler flags: enable C++11
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
QMAKE_LFLAGS += -std=c++11
|
||||
# prefix
|
||||
targetprefix = $$(TARGET_PREFIX)
|
||||
message("Using target prefix \"$${targetprefix}\".")
|
||||
# print install root
|
||||
message("Using install root \"$$(INSTALL_ROOT)\".")
|
||||
# target
|
||||
CONFIG(debug, debug|release) {
|
||||
TARGET = $${targetprefix}$${projectname}d
|
||||
} else {
|
||||
TARGET = $${targetprefix}$${projectname}
|
||||
}
|
||||
# add defines
|
||||
DEFINES += "APP_METADATA_AVAIL"
|
||||
DEFINES += "'PROJECT_NAME=\"$${projectname}\"'"
|
||||
DEFINES += "'APP_NAME=\"$${appname}\"'"
|
||||
DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'"
|
||||
DEFINES += "'APP_URL=\"$${appurl}\"'"
|
||||
DEFINES += "'APP_VERSION=\"$${VERSION}\"'"
|
||||
|
||||
# variables to check target architecture
|
||||
win32-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
||||
win32-g++-32:QMAKE_TARGET.arch = x86
|
||||
|
@ -30,7 +14,30 @@ win32-g++-64:QMAKE_TARGET.arch = x86_64
|
|||
linux-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
||||
linux-g++-32:QMAKE_TARGET.arch = x86
|
||||
linux-g++-64:QMAKE_TARGET.arch = x86_64
|
||||
# configuration
|
||||
|
||||
# determine and print target prefix
|
||||
targetprefix = $$(TARGET_PREFIX)
|
||||
message("Using target prefix \"$${targetprefix}\".")
|
||||
|
||||
# print install root
|
||||
message("Using install root \"$$(INSTALL_ROOT)\".")
|
||||
|
||||
# set target
|
||||
CONFIG(debug, debug|release) {
|
||||
TARGET = $${targetprefix}$${projectname}d
|
||||
} else {
|
||||
TARGET = $${targetprefix}$${projectname}
|
||||
}
|
||||
|
||||
# add defines for meta data
|
||||
DEFINES += "APP_METADATA_AVAIL"
|
||||
DEFINES += "'PROJECT_NAME=\"$${projectname}\"'"
|
||||
DEFINES += "'APP_NAME=\"$${appname}\"'"
|
||||
DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'"
|
||||
DEFINES += "'APP_URL=\"$${appurl}\"'"
|
||||
DEFINES += "'APP_VERSION=\"$${VERSION}\"'"
|
||||
|
||||
# configure Qt modules and defines
|
||||
mobile {
|
||||
DEFINES += CONFIG_MOBILE
|
||||
} else:desktop {
|
||||
|
@ -61,7 +68,7 @@ no-gui {
|
|||
}
|
||||
guiqtquick {
|
||||
message("Configured for Qt Quick GUI support.")
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += quick
|
||||
QT += quick
|
||||
CONFIG(debug, debug|release) {
|
||||
CONFIG += qml_debug
|
||||
}
|
||||
|
@ -69,11 +76,12 @@ guiqtquick {
|
|||
}
|
||||
guiqtwidgets {
|
||||
message("Configured for Qt widgets GUI support.")
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
QT += widgets
|
||||
DEFINES += GUI_QTWIDGETS
|
||||
DEFINES += MODEL_UNDO_SUPPORT
|
||||
}
|
||||
# Windows stuff: configuration for cross compliation with mingw-w64
|
||||
|
||||
# configuration for cross compliation with mingw-w64
|
||||
win32 {
|
||||
QMAKE_TARGET_PRODUCT = "$${appname}"
|
||||
QMAKE_TARGET_COPYRIGHT = "by $${appauthor}"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// include configuration from separate header file when building with CMake
|
||||
#ifndef APP_METADATA_AVAIL
|
||||
#include "config.h"
|
||||
#include "resources/config.h"
|
||||
#endif
|
||||
|
||||
#include <qtutilities/resources/qtconfigarguments.h>
|
||||
|
|
2
main.cpp
2
main.cpp
|
@ -8,7 +8,7 @@
|
|||
|
||||
// include configuration from separate header file when building with CMake
|
||||
#ifndef APP_METADATA_AVAIL
|
||||
#include "config.h"
|
||||
#include "resources/config.h"
|
||||
#endif
|
||||
|
||||
#include <passwordfile/util/openssl.h>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# meta data
|
||||
projectname = passwordmanager
|
||||
appname = "Password Manager"
|
||||
appauthor = Martchus
|
||||
|
@ -12,92 +13,105 @@ VERSION = 2.0.9
|
|||
}
|
||||
}
|
||||
|
||||
# basic configuration: application, might be configured with no Qt
|
||||
TEMPLATE = app
|
||||
|
||||
no-gui {
|
||||
CONFIG -= qt # Qt is only required for GUI
|
||||
# Qt is only required for GUI
|
||||
CONFIG -= qt
|
||||
} else {
|
||||
QT += core gui
|
||||
android {
|
||||
OTHER_FILES += android/AndroidManifest.xml
|
||||
include(../../deployment.pri)
|
||||
}
|
||||
}
|
||||
|
||||
guiqtquick {
|
||||
QML_IMPORT_PATH += ./quick ./qml ./qml/pages ./qml/touch
|
||||
}
|
||||
|
||||
# files
|
||||
SOURCES += main.cpp\
|
||||
# add project files
|
||||
HEADERS += \
|
||||
model/entrymodel.h \
|
||||
model/fieldmodel.h \
|
||||
model/entryfiltermodel.h \
|
||||
cli/cli.h
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
model/entrymodel.cpp \
|
||||
model/fieldmodel.cpp \
|
||||
model/entryfiltermodel.cpp \
|
||||
cli/cli.cpp
|
||||
|
||||
|
||||
testing {
|
||||
SOURCES += util/testroutines.cpp
|
||||
HEADERS += \
|
||||
util/testroutines.h
|
||||
|
||||
SOURCES += \
|
||||
util/testroutines.cpp
|
||||
}
|
||||
|
||||
guiqtwidgets {
|
||||
SOURCES += gui/mainwindow.cpp \
|
||||
HEADERS += \
|
||||
gui/mainwindow.h \
|
||||
gui/passwordgeneratordialog.h \
|
||||
gui/undocommands.h \
|
||||
gui/stacksupport.h \
|
||||
gui/initiategui.h \
|
||||
gui/fielddelegate.h
|
||||
|
||||
SOURCES += \
|
||||
gui/mainwindow.cpp \
|
||||
gui/passwordgeneratordialog.cpp \
|
||||
gui/undocommands.cpp \
|
||||
gui/stacksupport.cpp \
|
||||
gui/initiatequi.cpp \
|
||||
gui/fielddelegate.cpp
|
||||
|
||||
FORMS += gui/mainwindow.ui \
|
||||
FORMS += \
|
||||
gui/mainwindow.ui \
|
||||
gui/passwordgeneratordialog.ui
|
||||
}
|
||||
|
||||
guiqtquick {
|
||||
SOURCES += quickgui/applicationinfo.cpp \
|
||||
quickgui/initiatequick.cpp
|
||||
}
|
||||
|
||||
HEADERS += model/entrymodel.h \
|
||||
model/fieldmodel.h \
|
||||
model/entryfiltermodel.h \
|
||||
cli/cli.h
|
||||
|
||||
testing {
|
||||
HEADERS += util/testroutines.h
|
||||
}
|
||||
|
||||
guiqtwidgets {
|
||||
HEADERS += gui/mainwindow.h \
|
||||
gui/passwordgeneratordialog.h \
|
||||
gui/undocommands.h \
|
||||
gui/stacksupport.h \
|
||||
gui/initiategui.h \
|
||||
gui/fielddelegate.h
|
||||
}
|
||||
|
||||
guiqtquick {
|
||||
HEADERS += quickgui/applicationinfo.h \
|
||||
HEADERS += \
|
||||
quickgui/applicationinfo.h \
|
||||
quickgui/applicationpaths.h \
|
||||
quickgui/initiatequick.h
|
||||
|
||||
SOURCES += \
|
||||
quickgui/applicationinfo.cpp \
|
||||
quickgui/initiatequick.cpp
|
||||
|
||||
RESOURCES += \
|
||||
resources/qml.qrc
|
||||
}
|
||||
|
||||
# resources and translations
|
||||
!no-gui {
|
||||
RESOURCES += resources/icons.qrc
|
||||
contains(DEFINES, GUI_QTQUICK) {
|
||||
RESOURCES += resources/qml.qrc
|
||||
}
|
||||
TRANSLATIONS = translations/passwordmanager_en_US.ts \
|
||||
RESOURCES += \
|
||||
resources/icons.qrc
|
||||
|
||||
TRANSLATIONS += \
|
||||
translations/passwordmanager_en_US.ts \
|
||||
translations/passwordmanager_de_DE.ts
|
||||
}
|
||||
include(translations.pri)
|
||||
|
||||
win32:include(windowsicon.pri)
|
||||
|
||||
OTHER_FILES += \
|
||||
README.md \
|
||||
LICENSE
|
||||
LICENSE \
|
||||
CMakeLists.txt \
|
||||
resources/config.h.in \
|
||||
resources/windows.rc.in \
|
||||
android/AndroidManifest.xml
|
||||
|
||||
# libs and includepath
|
||||
# add deployment for android
|
||||
android:include(../../deployment.pri)
|
||||
|
||||
# release translations
|
||||
include(translations.pri)
|
||||
|
||||
# make windows icon
|
||||
win32:include(windowsicon.pri)
|
||||
|
||||
# add libs
|
||||
CONFIG(debug, debug|release) {
|
||||
LIBS += -lc++utilitiesd -lpasswordfiled
|
||||
!no-gui {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
// include configuration from separate header file when building with CMake
|
||||
#ifndef APP_METADATA_AVAIL
|
||||
#include "config.h"
|
||||
#include "resources/config.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
IDI_ICON1 ICON DISCARDABLE "resources/icons/windowsicon_passwordmanager.ico"
|
Loading…
Reference in New Issue