From 019735dd84eeb35e5415ac67e1f9b08cfba3a61b Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Mon, 7 Apr 2014 10:35:38 +0800 Subject: Update CMake files for git. A transfer from SVN to git. --- CMakeLists.txt | 5 +- CMakeLists.txt.freebsd | 2 +- CMakeLists.txt.linux | 1 - CMakeLists.txt.macos | 2 +- CMakeLists.txt.win32 | 2 +- cmake/GetGitRevisionDescription.cmake | 124 ++++++++++++++++++++++++++++ cmake/GetGitRevisionDescription.cmake.in | 38 +++++++++ cmake/VersionControl.cmake | 82 ------------------- src/ui/CMakeLists.txt | 2 + src/ui/aboutdialog.cpp | 5 +- src/ui/aboutdialog.ui | 134 +++++++++++++------------------ 11 files changed, 225 insertions(+), 172 deletions(-) create mode 100644 cmake/GetGitRevisionDescription.cmake create mode 100644 cmake/GetGitRevisionDescription.cmake.in delete mode 100644 cmake/VersionControl.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 6098e8e..dd3213f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,9 @@ ENDIF(NOT CMAKE_BUILD_TYPE) set(CMAKE_COLOR_MAKEFILE ON) -include(${CMAKE_MODULE_PATH}/VersionControl.cmake) -vcs_get_revision(MCGSVN_WC_REVISION) +include(GetGitRevisionDescription) +git_describe(MCGGIT_WC_REVISION) +message("Git revision: " ${MCGGIT_WC_REVISION}) find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork QtScript QtXml REQUIRED) IF(APPLE) diff --git a/CMakeLists.txt.freebsd b/CMakeLists.txt.freebsd index 08ca9ac..fc34e1b 100644 --- a/CMakeLists.txt.freebsd +++ b/CMakeLists.txt.freebsd @@ -7,7 +7,7 @@ ADD_DEFINITIONS(-Wall) ADD_DEFINITIONS(-DQT_SHARED) ADD_DEFINITIONS(-D_OS_FREEBSD_) ADD_DEFINITIONS(-DFQTERM_VERSION_STRING="\\"${FQTERM_VERSION}\\"") -ADD_DEFINITIONS(-DFQTERM_SVN_REVISION="\\"${MCGSVN_WC_REVISION}\\"") + IF(OSS_FOUND) ADD_DEFINITIONS(-DAUDIO_OSS) SET(AUDIO_INCLUDE_DIR "${OSS_INCLUDE_DIR}") diff --git a/CMakeLists.txt.linux b/CMakeLists.txt.linux index 60a53a7..28e7546 100644 --- a/CMakeLists.txt.linux +++ b/CMakeLists.txt.linux @@ -23,7 +23,6 @@ endif(ALSA_FOUND) ADD_DEFINITIONS(-Wall) ADD_DEFINITIONS(-D_OS_LINUX_) ADD_DEFINITIONS(-D "FQTERM_VERSION_STRING=\\\"${FQTERM_VERSION}\\\"") -ADD_DEFINITIONS(-D "FQTERM_SVN_REVISION=\\\"${MCGSVN_WC_REVISION}\\\"") add_subdirectory(src) diff --git a/CMakeLists.txt.macos b/CMakeLists.txt.macos index 459c0ad..9016271 100644 --- a/CMakeLists.txt.macos +++ b/CMakeLists.txt.macos @@ -4,7 +4,7 @@ set(CMAKE_VERBOSE_MAKEFILE ON) ADD_DEFINITIONS(-Wall) ADD_DEFINITIONS(-DFQTERM_VERSION_STRING="\\"${FQTERM_VERSION}\\"") -ADD_DEFINITIONS(-DFQTERM_SVN_REVISION="\\"${MCGSVN_WC_REVISION}\\"") + if(FQTERM_USE_STATIC_QT) ADD_DEFINITIONS(-DFQTERM_USE_STATIC_QT) diff --git a/CMakeLists.txt.win32 b/CMakeLists.txt.win32 index f9ff97e..2b09250 100644 --- a/CMakeLists.txt.win32 +++ b/CMakeLists.txt.win32 @@ -16,7 +16,7 @@ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Zi /Od /MD") ADD_DEFINITIONS(/D USE_DOTNET_STYLE) ADD_DEFINITIONS(/D _CRT_SECURE_NO_DEPRECATE) ADD_DEFINITIONS(/D FQTERM_VERSION_STRING="\\"${FQTERM_VERSION}\\"") -ADD_DEFINITIONS(/D FQTERM_SVN_REVISION="\\"${MCGSVN_WC_REVISION}\\"") + if(FQTERM_USE_STATIC_QT) ADD_DEFINITIONS(/D FQTERM_USE_STATIC_QT) diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 0000000..178514f --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,124 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe --always + ${hash} + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 0000000..888ce13 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,38 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") + configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + set(HEAD_HASH "${HEAD_REF}") + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/cmake/VersionControl.cmake b/cmake/VersionControl.cmake deleted file mode 100644 index aa7f4ff..0000000 --- a/cmake/VersionControl.cmake +++ /dev/null @@ -1,82 +0,0 @@ -# -*- cmake -*- -# -# Utility macros for getting info from the version control system. -# Originally taken from http://emeraldviewer.googlecode.com (GPLv2) - -set (PROJECT_SOURCE_DIR .) - -FIND_PACKAGE(Subversion) - -if (WIN32 AND NOT Subversion_FOUND) - # The official subversion client is not available, so fall back to - # tortoise if it is installed. - find_program(TORTOISE_WCREV_EXECUTABLE - NAMES SubWCRev.exe - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\TortoiseSVN;Directory]/bin" - ) - - if (NOT TORTOISE_WCREV_EXECUTABLE) - message(INFO "TortoiseSVN was not found.") - endif (NOT TORTOISE_WCREV_EXECUTABLE) -endif (WIN32 AND NOT Subversion_FOUND) - -# Use this macro on all platforms to set _output_variable to the current SVN -# revision. -macro(vcs_get_revision _output_variable) - if (Subversion_FOUND) - # The included Subversion macros performs operations that require auth, - # which breaks when building under fakeroot. Replacing with a custom - # command. --Ambroff - # Subversion_WC_INFO(${PROJECT_SOURCE_DIR} _Indra) - # set(${_output_variable} ${_Indra_WC_LAST_CHANGED_REV}) - - execute_process( - COMMAND ${Subversion_SVN_EXECUTABLE} info ../ - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE _svn_info_output - ERROR_VARIABLE _svn_info_error - RESULT_VARIABLE _svn_info_result - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ) - - if (NOT ${_svn_info_result} EQUAL 0) - message(STATUS "svn info failed: ${_svn_info_error}") - set(${_output_variable} 0) - else (NOT ${_svn_info_result} EQUAL 0) - string(REGEX REPLACE - "(.*)?Last Changed Rev: ([0-9]+).*$" - "\\2" - ${_output_variable} - ${_svn_info_output}) - endif (NOT ${_svn_info_result} EQUAL 0) - else (Subversion_FOUND) - if (WIN32 AND TORTOISE_WCREV_EXECUTABLE) - # try to find TortoisSVN if we are on windows. - execute_process( - COMMAND ${TORTOISE_WCREV_EXECUTABLE} ../ - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE _tortoise_rev_info - ERROR_VARIABLE _tortoise_rev_info_error - RESULT_VARIABLE _tortoise_rev_info_result - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ) - - if (NOT ${_tortoise_rev_info_result} EQUAL 0) - message(STATUS "Command '${_tortoise_rev_info_error} ${PROJECT_SOURCE_DIR}' failed: ${_tortoise_rev_info_error}") - set(${_output_variable} 0) - else (NOT ${_tortoise_rev_info_result} EQUAL 0) - string(REGEX REPLACE - "(.*\n)?Last committed at revision ([0-9]+).*$" - "\\2" - ${_output_variable} "${_tortoise_rev_info}") - endif (NOT ${_tortoise_rev_info_result} EQUAL 0) - else (WIN32 AND TORTOISE_WCREV_EXECUTABLE) - # Ruh-roh... we can't get the revision, so set it to '0' - message(STATUS - "No subversion client is installed. Setting build number to 0.") - set(${_output_variable} 0) - endif (WIN32 AND TORTOISE_WCREV_EXECUTABLE) - endif (Subversion_FOUND) -endmacro(vcs_get_revision) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 09af483..dc5a873 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -120,3 +120,5 @@ add_dependencies(fqterm_ui fqterm_common fqterm_utilities ) + +ADD_DEFINITIONS(-D "FQTERM_GIT_REVISION=\\\"${MCGGIT_WC_REVISION}\\\"") diff --git a/src/ui/aboutdialog.cpp b/src/ui/aboutdialog.cpp index 5c56dcc..130810b 100644 --- a/src/ui/aboutdialog.cpp +++ b/src/ui/aboutdialog.cpp @@ -52,10 +52,7 @@ aboutDialog::aboutDialog(QWidget *parent, Qt::WFlags fl) ui_.TextBrowser->setPlainText(line); file.close(); } - QString aboutText = "FQTerm " + QString(FQTERM_VERSION_STRING) + QString("\nSVN revision ") + QString(FQTERM_SVN_REVISION) + QString("\n Built with Qt") + QT_VERSION_STR + QString("\n Running with Qt ") + qVersion(); - if (QString(FQTERM_VERSION_STRING).startsWith("0.9.8")) { - aboutText += "\n>>2012 - End of the world edition<<"; - } + QString aboutText = "FQTerm " + QString(FQTERM_VERSION_STRING) + QString("\ngit revision ") + QString(FQTERM_GIT_REVISION) + QString("\n Built with Qt") + QT_VERSION_STR + QString("\n Running with Qt ") + qVersion(); ui_.TextLabel->setText(aboutText); } diff --git a/src/ui/aboutdialog.ui b/src/ui/aboutdialog.ui index 5770cd8..5f2938a 100644 --- a/src/ui/aboutdialog.ui +++ b/src/ui/aboutdialog.ui @@ -1,7 +1,8 @@ - + + aboutDialog - - + + 0 0 @@ -9,129 +10,102 @@ 290 - + false - + About FQTerm - - - - + + + + - + true - - - + + + QFrame::NoFrame - + QFrame::Plain - + FQTerm - + Qt::AlignCenter - - - + + + 0 - - - - 0 - 0 - 376 - 194 - - - + + About - - - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br />FQTerm<br /><br /><br /><a href="http://code.google.com/p/fqterm"><span style=" text-decoration: underline; color:#0000ff;">http://code.google.com/p/fqterm</span></a></p></body></html> + + + + + <html><head/><body><p><br/>FQTerm<br/><br/><a href="http://code.google.com/p/fqterm"><span style=" text-decoration: underline; color:#0000ff;">http://code.google.com/p/fqterm</span></a></p><p><a href="https://github.com/Iroul/fqterm"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/Iroul/fqterm</span></a></p><p><a href="http://code.google.com/p/fqterm"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/mytbk/fqterm</span></a></p><p><br/></p></body></html> - + Qt::RichText - + Qt::AlignCenter - + true - + Qt::TextBrowserInteraction - - - - 77 - 97 - 944 - 522 - - - + + Authors - - - - + + + + fqterm@gmail.com devilphoenix@newsmth - + Qt::AlignCenter - - - - 100 - 120 - 944 - 522 - - - + + Credits - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun';"><br /></p></body></html> @@ -139,16 +113,16 @@ p, li { white-space: pre-wrap; } - - - + + + Close - + closeButton mainTabWidget @@ -161,11 +135,11 @@ p, li { white-space: pre-wrap; } aboutDialog accept() - + 339 261 - + 211 249 -- cgit v1.2.3