From d449887ea3b090997ad744f8535b0856e182a813 Mon Sep 17 00:00:00 2001 From: Eduard Kalinowski Date: Tue, 16 May 2017 17:09:48 +0200 Subject: [PATCH] version.h will be generated from qmake or cmake --- CMakeLists.txt | 42 ++++++++++++++++----------------- SrcPony/version-cmake.h.in | 26 +++++++++++++++++++++ SrcPony/version-qmake.h.in | 26 +++++++++++++++++++++ SrcPony/version.h | 8 +++---- ponyprog.pro | 48 ++++++++++++++++++++++++-------------- 5 files changed, 108 insertions(+), 42 deletions(-) create mode 100644 SrcPony/version-cmake.h.in create mode 100644 SrcPony/version-qmake.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index acb0b13..2d39181 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,7 @@ EXECUTE_PROCESS ( COMMAND grep -E "^[0-9]+\\.[0-9]+\\.[0-9]+" COMMAND head -n 1 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE PONYPROG_VERSION + RESULT_VARIABLE APP_VERSION OUTPUT_VARIABLE DESCRIBE_STRING OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -94,28 +94,28 @@ EXECUTE_PROCESS ( IF(NOT DESCRIBE_STRING) SET(DESCRIBE_STRING "no valid git tag for ${PROJECT_NAME} found") ELSE() - STRING(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" PONYPROG_VERSION "${DESCRIBE_STRING}" ) - IF (NOT PONYPROG_VERSION) + STRING(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" APP_VERSION "${DESCRIBE_STRING}" ) + IF (NOT APP_VERSION) SET(DESCRIBE_STRING "no valid git tag ${PROJECT_NAME}-x.x.x found") ENDIF() ENDIF() -MESSAGE(STATUS "Version info: ${PONYPROG_VERSION}") -SET(VERSION ${PONYPROG_VERSION}) +MESSAGE(STATUS "Version info: ${APP_VERSION}") +SET(VERSION ${APP_VERSION}) # -SET(PONYPROG_VERSION "3.0.0") -SET(PANYPROG_AUTHOR "Claudio Lanconelli") -SET(PROJECT_EMAIL "PonyProg2000@gmail.com") +SET(APP_VERSION "3.0.0") +SET(APP_AUTHOR "Claudio Lanconelli") +SET(APP_EMAIL "PonyProg2000@gmail.com") SET(APP_NAME "PonyProg") EXECUTE_PROCESS ( - COMMAND date +"%d %b %Y" + COMMAND date +"%d.%m.%Y" COMMAND sed -e "s/\"//g" - OUTPUT_VARIABLE BUILD_DATE + OUTPUT_VARIABLE APP_BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) -MESSAGE(STATUS "Version build date: ${BUILD_DATE}") +MESSAGE(STATUS "Version build date: ${APP_BUILD_DATE}") # SET(PONYPROG_PACKAGE ponyprog) @@ -131,7 +131,7 @@ SET(PONYPROG_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) # ENDIF(MSVC) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-exceptions -fno-rtti") # options for gprof IF(${USE_PROFILER}) @@ -157,7 +157,7 @@ IF(${USE_QT_VERSION} MATCHES "4") "You can do it in interactive mode (ccmake instead of cmake) or using -DVAR=VAL syntax.") ENDIF() ELSE() - FIND_PACKAGE(Qt5 COMPONENTS Core PrintSupport Gui Widgets REQUIRED QUIET) + FIND_PACKAGE(Qt5 COMPONENTS Core PrintSupport Gui Widgets Multimedia REQUIRED QUIET) # FIND_PACKAGE(Qt5 COMPONENTS LinguistTools REQUIRED QUIET) @@ -174,17 +174,17 @@ IF(${USE_QT_VERSION} MATCHES "4") MESSAGE(STATUS "QT_INCLUDES ${QT_INCLUDES}") # LINK_DIRECTORIES(${QT_LIBRARY_DIR}) ELSE() - INCLUDE_DIRECTORIES(${QT_INCLUDES} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES(${QT_INCLUDES} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS}) - MESSAGE(STATUS "QT_INCLUDES ${QT_INCLUDES} ${Qt5Widgets_INCLUDE_DIRS} ") + MESSAGE(STATUS "QT_INCLUDES ${QT_INCLUDES} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS}") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${Qt5PrintSupport_EXECUTABLE_COMPILE_FLAGS}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${Qt5Multimedia_EXECUTABLE_COMPILE_FLAGS} ${Qt5PrintSupport_EXECUTABLE_COMPILE_FLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lQt5PrintSupport") ENDIF() configure_file ( - "${PROJECT_SOURCE_DIR}/SrcPony/version.h.in" + "${PROJECT_SOURCE_DIR}/SrcPony/version-cmake.h.in" "${PROJECT_SOURCE_DIR}/SrcPony/version.h" ) @@ -224,14 +224,14 @@ SOURCE_GROUP( "Generated Files" FILES IF(NOT ${USE_DEBUGGER}) - ADD_DEFINITIONS(${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT) + ADD_DEFINITIONS(${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) ENDIF() IF(${USE_QT_VERSION} MATCHES "4") INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS} -DNO_QT3SUPPORT -DDISABLE_QT3SUPPORT -DQT_PROJECT) ELSE() - ADD_DEFINITIONS( ${Qt5Widgets_DEFINITIONS} ${Qt5PrintSupport_DEFINITIONS} -DQT_PROJECT ) + ADD_DEFINITIONS( ${Qt5Widgets_DEFINITIONS} ${Qt5PrintSupport_DEFINITIONS} ${Qt5Multimedia_DEFINITIONS} -DQT_PROJECT ) ENDIF() ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} @@ -248,8 +248,8 @@ ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} IF(${USE_QT_VERSION} MATCHES "4") TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${QT_LIBRARIES} ) ELSE() - TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${QT_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ) - MESSAGE(STATUS "QT LIBRARIES: ${QT_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ${Qt5Core_LIBRARIES}") + TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${QT_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ) + MESSAGE(STATUS "QT LIBRARIES: ${QT_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ${Qt5Core_LIBRARIES}") ENDIF() ADD_CUSTOM_TARGET (tags diff --git a/SrcPony/version-cmake.h.in b/SrcPony/version-cmake.h.in new file mode 100644 index 0000000..65c8aaa --- /dev/null +++ b/SrcPony/version-cmake.h.in @@ -0,0 +1,26 @@ +#ifndef PONYPROGVERSION_H +#define PONYPROGVERSION_H + +#ifndef APP_VERSION +#define APP_VERSION "${APP_VERSION}" +#endif + +#ifndef APP_AUTHOR +#define APP_AUTHOR "${APP_AUTHOR}" +#endif + +#ifndef PROGRAM_DATE +#define PROGRAM_DATE "${APP_BUILD_DATE}" +#endif + +#ifndef APP_NAME +#define APP_NAME "${APP_NAME}" +#endif + +#ifndef APP_EMAIL +#define APP_EMAIL "${APP_EMAIL}" +#endif + +#define USE_QT_VERSION ${USE_QT_VERSION} + +#endif diff --git a/SrcPony/version-qmake.h.in b/SrcPony/version-qmake.h.in new file mode 100644 index 0000000..5e431fe --- /dev/null +++ b/SrcPony/version-qmake.h.in @@ -0,0 +1,26 @@ +#ifndef PONYPROGVERSION_H +#define PONYPROGVERSION_H + +#ifndef APP_VERSION +#define APP_VERSION \"$$APP_VERSION\" +#endif + +#ifndef APP_AUTHOR +#define APP_AUTHOR \"$$APP_AUTHOR\" +#endif + +#ifndef PROGRAM_DATE +#define PROGRAM_DATE \"$$APP_BUILD_DATE\" +#endif + +#ifndef APP_NAME +#define APP_NAME \"$$APP_NAME\" +#endif + +#ifndef APP_EMAIL +#define APP_EMAIL \"$$APP_EMAIL\" +#endif + +#define USE_QT_VERSION $$USE_QT_VERSION + +#endif diff --git a/SrcPony/version.h b/SrcPony/version.h index c7370cc..df28800 100644 --- a/SrcPony/version.h +++ b/SrcPony/version.h @@ -6,21 +6,21 @@ #endif #ifndef APP_AUTHOR -#define APP_AUTHOR "" +#define APP_AUTHOR "Claudio Lanconelli" #endif #ifndef PROGRAM_DATE -#define PROGRAM_DATE "15 Mai 2017" +#define PROGRAM_DATE "16-05-2017" #endif #ifndef APP_NAME -#define APP_NAME "ponyprog" +#define APP_NAME "PonyProg" #endif #ifndef APP_EMAIL #define APP_EMAIL "PonyProg2000@gmail.com" #endif -#define USE_QT_VERSION 4 +#define USE_QT_VERSION #endif diff --git a/ponyprog.pro b/ponyprog.pro index 980ca08..021544f 100644 --- a/ponyprog.pro +++ b/ponyprog.pro @@ -26,6 +26,7 @@ APP_LOW_H_NAME = ".ponyprog" APP_AUTHOR = "Claudio Lanconelli" APP_COPYRIGHT = "(C) 1997-2017 $$APP_AUTHOR" APP_VERSION = "3.0.0" +# APP_BUILD_DATE = $$_DATE_ APP_LONG_NAME = "$$APP_NAME $$APP_VERSION" APP_EMAIL = "PonyProg2000@gmail.com" APP_URL = "https://github.com/lancos/ponyprog/" @@ -35,6 +36,14 @@ APP_USERAGENT = "PonyProg/$$APP_VERSION (github.com/lancos/ponyp # replace it with yours info for donates # APP_DONATE_URL = "https://goo.gl/YFVJ0j" +win32 { + APP_BUILD_DATE = $$system(date /t) +} +else +{ + APP_BUILD_DATE = $$system(date +%d-%m-%Y) +} + # TODO: please check this win32:INCLUDEPATH += $$PWD/windows @@ -51,21 +60,21 @@ unix:INCLUDEPATH +=/usr/local/include/ # Custom definitions. -DEFINES += APP_VERSION='"\\\"$$APP_VERSION\\\""' -DEFINES += APP_NAME='"\\\"$$APP_NAME\\\""' -DEFINES += APP_LOW_NAME='"\\\"$$APP_LOW_NAME\\\""' -DEFINES += APP_LOW_H_NAME='"\\\"$$APP_LOW_H_NAME\\\""' -DEFINES += APP_LONG_NAME='"\\\"$$APP_LONG_NAME\\\""' -DEFINES += APP_AUTHOR='"\\\"$$APP_AUTHOR\\\""' -DEFINES += APP_EMAIL='"\\\"$$APP_EMAIL\\\""' -DEFINES += APP_URL='"\\\"$$APP_URL\\\""' -DEFINES += APP_URL_ISSUES='"\\\"$$APP_URL_ISSUES\\\""' -DEFINES += APP_URL_ISSUES_NEW='"\\\"$$APP_URL_ISSUES_NEW\\\""' -DEFINES += APP_URL_WIKI='"\\\"$$APP_URL_WIKI\\\""' -DEFINES += APP_USERAGENT='"\\\"$$APP_USERAGENT\\\""' -# DEFINES += APP_DONATE_URL='"\\\"$$APP_DONATE_URL\\\""' -DEFINES += APP_SYSTEM_NAME='"\\\"$$QMAKE_HOST.os\\\""' -DEFINES += APP_SYSTEM_VERSION='"\\\"$$QMAKE_HOST.arch\\\""' +# DEFINES += APP_VERSION='"\\\"$$APP_VERSION\\\""' +# DEFINES += APP_NAME='"\\\"$$APP_NAME\\\""' +# DEFINES += APP_LOW_NAME='"\\\"$$APP_LOW_NAME\\\""' +# DEFINES += APP_LOW_H_NAME='"\\\"$$APP_LOW_H_NAME\\\""' +# DEFINES += APP_LONG_NAME='"\\\"$$APP_LONG_NAME\\\""' +# DEFINES += APP_AUTHOR='"\\\"$$APP_AUTHOR\\\""' +# DEFINES += APP_EMAIL='"\\\"$$APP_EMAIL\\\""' +# DEFINES += APP_URL='"\\\"$$APP_URL\\\""' +# DEFINES += APP_URL_ISSUES='"\\\"$$APP_URL_ISSUES\\\""' +# DEFINES += APP_URL_ISSUES_NEW='"\\\"$$APP_URL_ISSUES_NEW\\\""' +# DEFINES += APP_URL_WIKI='"\\\"$$APP_URL_WIKI\\\""' +# DEFINES += APP_USERAGENT='"\\\"$$APP_USERAGENT\\\""' +# # DEFINES += APP_DONATE_URL='"\\\"$$APP_DONATE_URL\\\""' +# DEFINES += APP_SYSTEM_NAME='"\\\"$$QMAKE_HOST.os\\\""' +# DEFINES += APP_SYSTEM_VERSION='"\\\"$$QMAKE_HOST.arch\\\""' CODECFORTR = UTF-8 @@ -80,7 +89,7 @@ isEmpty(APP_REVISION) { APP_REVISION = "" } -DEFINES += APP_REVISION='"\\\"$$APP_REVISION\\\""' +# DEFINES += APP_REVISION='"\\\"$$APP_REVISION\\\""' message(ponyprog: PonyProg version is: \"$$APP_VERSION\") @@ -94,7 +103,12 @@ message(ponyprog: lrelease executable name: \"$$LRELEASE_EXECUTABLE\") VERSION = $$APP_VERSION -VERSION_FILE = $$OUT_PWD/SrcPony/version.h +versionconfig.input = $$OUT_PWD/SrcPony/version-qmake.h.in +versionconfig.output = $$OUT_PWD/SrcPony/version.h +QMAKE_SUBSTITUTES += versionconfig + + +# VERSION_FILE = $$OUT_PWD/SrcPony/version.h # write_file...