diff options
Diffstat (limited to '')
-rw-r--r-- | CMakeLists.txt | 58 | ||||
-rw-r--r-- | gpgfrontend.ico (renamed from gpg4usb.ico) | bin | 9662 -> 9662 bytes | |||
-rw-r--r-- | gpgfrontend.qrc (renamed from gpg4usb.qrc) | 0 | ||||
-rw-r--r-- | include/GpgFrontend.h | 43 | ||||
-rw-r--r-- | include/GpgFrontend.h.in | 31 | ||||
-rw-r--r-- | src/CMakeLists.txt | 27 | ||||
-rw-r--r-- | src/gpg/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/main.cpp | 8 |
8 files changed, 123 insertions, 46 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e12853e..fc711633 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.19) project(GPGFrontend VERSION 1.0.0 LANGUAGES CXX) -message("GPGFrontend Build Confifgure Started.") +message(STATUS "GPGFrontend Build Configuration Started CMAKE Version ${CMAKE_VERSION}") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -15,17 +15,54 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Wall") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O2") + +if(${CMAKE_BUILD_TYPE} STREQUAL "Release") + message(STATUS "Build Type RELEASE") + set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O2") +else() + message(STATUS "Build Type DEBUG") + set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Wall") +endif() + +# Get Git Information + +set(GIT_COMMIT_HASH "") +set(GIT_BRANCH_NAME "") +find_package(Git QUIET) +if(GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%H + OUTPUT_VARIABLE COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + execute_process( + COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD + OUTPUT_VARIABLE BRANCH_NAME + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) +endif() + + +set(BUILD_VERSION ${PROJECT_VERSION}_${CMAKE_SYSTEM}_${CMAKE_SYSTEM_PROCESSOR}_${CMAKE_BUILD_TYPE}) +set(GIT_VERSION ${PROJECT_NAME}_${GIT_COMMIT_HASH}_${GIT_COMMIT_HASH}) +string(TIMESTAMP BUILD_TIMESTAMP "%Y-%m-%d %H:%M:%S") + +message("Build Timestamp ${BUILD_TIMESTAMP}") +message(STATUS "Build Version ${BUILD_VERSION}") +message(STATUS "Git Version ${GIT_VERSION}") IF (MINGW) - message("OS Platform Microsoft Windows") - message("Envrinoment MINGW") + message(STATUS "Configuration For OS Platform Microsoft Windows") + message(STATUS "Build Environment MINGW") - set(CMAKE_EXE_LINKER_FLAGS "-static") - - include_directories( + set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") + + include_directories( include /mingw64/include ) @@ -37,7 +74,7 @@ endif() if(APPLE) - message("OS Platform MacOS") + message(STATUS, "Configuration For OS Platform MacOS") set(ENV{Qt5_DIR} /usr/local/opt/qt5/lib/cmake) @@ -56,7 +93,8 @@ endif() if(LINUX) - message("OS Platform LINUX") + message(STATUS "Configuration For OS Platform LINUX") + set(Platform LINUX) include_directories( include diff --git a/gpg4usb.ico b/gpgfrontend.ico Binary files differindex 51c9b00c..51c9b00c 100644 --- a/gpg4usb.ico +++ b/gpgfrontend.ico diff --git a/gpg4usb.qrc b/gpgfrontend.qrc index 3eda5d57..3eda5d57 100644 --- a/gpg4usb.qrc +++ b/gpgfrontend.qrc diff --git a/include/GpgFrontend.h b/include/GpgFrontend.h index 0568668b..3907449c 100644 --- a/include/GpgFrontend.h +++ b/include/GpgFrontend.h @@ -1,29 +1,5 @@ -/** - * This file is part of GPGFrontend. - * - * GPGFrontend is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Foobar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <https://www.gnu.org/licenses/>. - * - * The initial version of the source code is inherited from gpg4usb-team. - * Their source code version also complies with GNU General Public License. - * - * The source code version of this software was modified and released - * by Saturneric<[email protected]> starting on May 12, 2021. - * - */ - -#ifndef GPG4USB_GPG4USB_H -#define GPG4USB_GPG4USB_H +#ifndef GPGFRONTEND_H_IN +#define GPGFRONTEND_H_IN #include <iostream> #include <string> @@ -39,4 +15,17 @@ #include <gpgme.h> -#endif //GPG4USB_GPG4USB_H +#define PROJECT_NAME "GPGFrontend" +#define BUILD_VERSION "1.0.0_Windows-10.0.19042_AMD64_Debug" +#define GIT_VERSION "GPGFrontend__" + +#define VERSION_MAJOR 1 +#define VERSION_MINOR 0 +#define VERSION_PATCH 0 + +#define BUILD_TIMESTAMP "2021-06-18 01:49:12" + +#define GIT_BRANCH_NAME "" +#define GIT_COMMIT_HASH "" + +#endif //GPGFRONTEND_H_IN diff --git a/include/GpgFrontend.h.in b/include/GpgFrontend.h.in new file mode 100644 index 00000000..6cf6c7af --- /dev/null +++ b/include/GpgFrontend.h.in @@ -0,0 +1,31 @@ +#ifndef GPGFRONTEND_H_IN +#define GPGFRONTEND_H_IN + +#include <iostream> +#include <string> +#include <cmath> +#include <clocale> +#include <cerrno> +#include <utility> + +#include <QtCore> +#include <QtWidgets> +#include <QtNetwork/QtNetwork> +#include <QtPrintSupport/QtPrintSupport> + +#include <gpgme.h> + +#define PROJECT_NAME "@PROJECT_NAME@" +#define BUILD_VERSION "@BUILD_VERSION@" +#define GIT_VERSION "@GIT_VERSION@" + +#define VERSION_MAJOR @CMAKE_PROJECT_VERSION_MAJOR@ +#define VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@ +#define VERSION_PATCH @CMAKE_PROJECT_VERSION_PATCH@ + +#define BUILD_TIMESTAMP "@BUILD_TIMESTAMP@" + +#define GIT_BRANCH_NAME "@GIT_BRANCH_NAME@" +#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" + +#endif //GPGFRONTEND_H_IN
\ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0158ef6c..b4280fcc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,10 +4,27 @@ add_subdirectory(ui) aux_source_directory(. BASE_SOURCE) file(GLOB_RECURSE GPG4USB_HEADER_FILES RELACTIVE ../include/* *.h) -qt5_wrap_cpp(QT5_MOCS ${GPG4USB_HEADER_FILES} TARGET gpg4usb) +qt5_wrap_cpp(QT5_MOCS ${GPG4USB_HEADER_FILES} TARGET gpgfrontend) -add_executable(gpg4usb ${BASE_SOURCE} ../gpg4usb.qrc ${QT5_MOCS}) +# Set Build Information +configure_file(${CMAKE_SOURCE_DIR}/include/GpgFrontend.h.in ${CMAKE_SOURCE_DIR}/include/GpgFrontend.h @ONLY) + +# Copy Resource File +file(COPY ${CMAKE_SOURCE_DIR}/resource/ DESTINATION ${EXECUTABLE_OUTPUT_PATH}/ FOLLOW_SYMLINK_CHAIN) + +add_executable(gpgfrontend ${BASE_SOURCE} ${CMAKE_SOURCE_DIR}/gpgfrontend.qrc ${QT5_MOCS}) + +IF (MINGW) + message(STATUS "Link Application Static Library For MINGW")完善工程设置 + target_link_libraries(gpgfrontend + qtui gpg + Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) + + +else() + message(STATUS "Link Application Static Library For UNIX") + target_link_libraries(gpgfrontend + qtui gpg + Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) +endif() -target_link_libraries(gpg4usb - qtui gpg - Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) diff --git a/src/gpg/CMakeLists.txt b/src/gpg/CMakeLists.txt index 3213c457..a12f371f 100644 --- a/src/gpg/CMakeLists.txt +++ b/src/gpg/CMakeLists.txt @@ -8,11 +8,13 @@ set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils) set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib) IF (MINGW) + message(STATUS "Link GPG Static Library For MINGW") target_link_libraries(gpg gpgme gpg-error assuan Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core wsock32) else() + message(STATUS "Link GPG Static Library For Unix") target_link_libraries(gpg gpgme gpg-error assuan Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) diff --git a/src/main.cpp b/src/main.cpp index 6cb84d25..7ce4a946 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,14 +26,14 @@ int main(int argc, char *argv[]) { - Q_INIT_RESOURCE(gpg4usb); + Q_INIT_RESOURCE(gpgfrontend); QApplication app(argc, argv); // get application path QString appPath = qApp->applicationDirPath(); - QApplication::setApplicationVersion("1.0.0"); + QApplication::setApplicationVersion(BUILD_VERSION); QApplication::setApplicationName("GPGFrontend"); // dont show icons in menus @@ -67,11 +67,11 @@ int main(int argc, char *argv[]) { lang = QLocale::system().name(); } - translator.load("ts/gpg4usb_" + lang, appPath); + translator.load("./ts/gpg4usb_" + lang, appPath); QApplication::installTranslator(&translator); // set qt translations - translator2.load("ts/qt_" + lang, appPath); + translator2.load("./ts/qt_" + lang, appPath); QApplication::installTranslator(&translator2); MainWindow window; |