diff options
author | click <none@none> | 2010-09-30 01:44:09 +0200 |
---|---|---|
committer | click <none@none> | 2010-09-30 01:44:09 +0200 |
commit | 91502154f11fb6beb5d6cccbd594ef24397bfbd3 (patch) | |
tree | 3c93fb862119e6f838bf61c000be8f91941be4cc /CMakeLists.txt | |
parent | b87d8f470042628ac54386853cf877cec107c141 (diff) |
BuildSystem: Add another revision.h setup "test-clause" (in case someone doesn't have a .hg dir or .hg_archival.txt)
- Set revision-ID to 0, and revision-hash to "Unknown archive", if an id/hash can not be properly detected.
This should never happen unless the user has -deliberately deleted- the .hg directory and/or the .hg_archival.txt,
or does not have the hg command in their command-path
--HG--
branch : trunk
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1311ca557ec..56c313c95e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,6 @@ if( UNIX ) endif() if(EXISTS ${CMAKE_SOURCE_DIR}/.hg_archival.txt) - set(hg_rev_id_str "Archive") file(READ ${CMAKE_SOURCE_DIR}/.hg_archival.txt hg_rev_hash_str LIMIT 10 @@ -67,9 +66,9 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/.hg_archival.txt) ) string(STRIP ${hg_rev_id_str} hg_rev_id_str) string(STRIP ${hg_rev_hash_str} hg_rev_hash_str) + set(hg_rev_id_str "Archive") set(hg_rev_id "0") set(hg_rev_hash ${hg_rev_hash_str}) - else() # Find revision ID and hash of the sourcetree execute_process( @@ -77,20 +76,32 @@ else() WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE hg_rev_id_str OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET ) execute_process( COMMAND hg id -i WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE hg_rev_hash_str OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET ) - # Strip off excess strings (shows when the source is actually modified) - string(REPLACE "+" "" hg_rev_id ${hg_rev_id_str}) - string(REPLACE "+" "" hg_rev_hash ${hg_rev_hash_str}) endif() +# Last minute check - ensure that we have a proper revision +# If everything above fails (means the user has erased the mercurial revisional control directory, or runs archive and erased their .hg_archival.txt) +if(NOT hg_rev_id_str) + message("") + message(STATUS "WARNING - No revision-information found - have you been tampering with the sources?") + + # Ok, since we have no valid ways of finding/setting the revision, let's force some defaults + set(hg_rev_id_str "0") + set(hg_rev_id "0") + set(hg_rev_hash_str "Unknown archive") + set(hg_rev_hash "0") +endif() + +# Strip off excess strings (shows when the source is actually modified) +string(REPLACE "+" "" hg_rev_id ${hg_rev_id_str}) +string(REPLACE "+" "" hg_rev_hash ${hg_rev_hash_str}) + # Create the actual revision.h file from the above params configure_file( "${CMAKE_SOURCE_DIR}/revision.h.in.cmake" |