This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
300 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#create a pretty commit id using git | ||
#uses 'git describe --tags', so tags are required in the repo | ||
#create a tag with 'git tag <name>' and 'git push --tags' | ||
|
||
if(IS_DIRECTORY ${GIT_ROOT_DIR}/.git) | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty | ||
WORKING_DIRECTORY ${GIT_ROOT_DIR} | ||
RESULT_VARIABLE res_var | ||
OUTPUT_VARIABLE GIT_COM_ID | ||
) | ||
if(NOT ${res_var} EQUAL 0) | ||
set(GIT_COMMIT_ID "?.?.?-unknown") | ||
message(WARNING "Git failed (not a repo, or no tags). Build will not contain git revision info.") | ||
endif() | ||
string(REGEX REPLACE "\n$" "" GIT_COMMIT_ID ${GIT_COM_ID}) | ||
string(REGEX REPLACE "^v" "" GIT_COMMIT_ID ${GIT_COMMIT_ID}) | ||
|
||
# check number of digits in version string | ||
string(REPLACE "." ";" GIT_COMMIT_ID_VLIST ${GIT_COMMIT_ID}) | ||
list(LENGTH GIT_COMMIT_ID_VLIST GIT_COMMIT_ID_VLIST_COUNT) | ||
|
||
# no.: major | ||
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_COMMIT_ID}") | ||
# no.: minor | ||
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_COMMIT_ID}") | ||
|
||
if(${GIT_COMMIT_ID_VLIST_COUNT} STREQUAL "2") | ||
# no. patch | ||
set(VERSION_PATCH "0") | ||
# SHA1 string + git 'dirty' flag | ||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+(.*)" "\\1" VERSION_SHA1 "${GIT_COMMIT_ID}") | ||
else() | ||
# no. patch | ||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_COMMIT_ID}") | ||
# SHA1 string + git 'dirty' flag | ||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" VERSION_SHA1 "${GIT_COMMIT_ID}") | ||
endif() | ||
|
||
set(PROJECT_VERSION "${GIT_COMMIT_ID}") | ||
#string(APPEND PROJECT_VERSION " (git)") | ||
message(STATUS "Version: ${PROJECT_VERSION} [git]") | ||
else() | ||
message(STATUS "Version: ${PROJECT_VERSION} [cmake]") | ||
endif() | ||
|
||
if(NOT APPLE) | ||
if(PROJ_UAC_ON) | ||
set(UAC_FLAG "") | ||
else() | ||
set(UAC_FLAG "//") | ||
endif() | ||
|
||
message(STATUS "Processing resource file...") | ||
file(READ ${INPUT_DIR}/${PROJECT_NAME}.rc.in rc_temporary) | ||
string(CONFIGURE ${rc_temporary} rc_updated) | ||
file(WRITE ${OUTPUT_DIR}/${PROJECT_NAME}.rc.tmp ${rc_updated}) | ||
execute_process( | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
${OUTPUT_DIR}/${PROJECT_NAME}.rc.tmp ${OUTPUT_DIR}/${PROJECT_NAME}.rc | ||
) | ||
else() | ||
message(FATAL_ERROR " === ERROR ===") | ||
endif() | ||
|
||
message(STATUS "Processing app info file...") | ||
file(READ ${INPUT_DIR}/${PROJECT_NAME}.cpp.in cpp_temporary) | ||
string(CONFIGURE "${cpp_temporary}" cpp_updated @ONLY) | ||
file(WRITE ${OUTPUT_DIR}/${PROJECT_NAME}.cpp.tmp "${cpp_updated}") | ||
execute_process( | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
${OUTPUT_DIR}/${PROJECT_NAME}.cpp.tmp ${OUTPUT_DIR}/${PROJECT_NAME}.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generate version string via Git description | ||
|
||
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/.git) | ||
find_package(Git 2.7 REQUIRED) | ||
endif() | ||
|
||
add_custom_target(git_revision ALL) | ||
add_custom_command( | ||
TARGET git_revision | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src | ||
|
||
COMMAND ${CMAKE_COMMAND} | ||
-DGIT_ROOT_DIR=${CMAKE_SOURCE_DIR} | ||
-DGIT_EXECUTABLE=${GIT_EXECUTABLE} | ||
|
||
-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR}/src | ||
-DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}/src | ||
|
||
-DPROJECT_NAME=${PROJECT_NAME} | ||
-DPROJECT_VERSION=${PROJECT_VERSION} | ||
-DPROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} | ||
-DPROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR} | ||
-DPROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH} | ||
-DPROJECT_VERSION_TWEAK=${PROJECT_VERSION_TWEAK} | ||
|
||
-DPRODUCT_NAME_COMPANY=${PRODUCT_NAME_COMPANY} | ||
-DPRODUCT_NAME_SHORT=${PRODUCT_NAME_SHORT} | ||
-DPRODUCT_NAME_LONG=${PRODUCT_NAME_LONG} | ||
-DPRODUCT_NAME_COPYRIGHT=${PRODUCT_NAME_COPYRIGHT} | ||
-DPRODUCT_NAME_COMPANY_DOMAIN=${PRODUCT_NAME_COMPANY_DOMAIN} | ||
|
||
-DPROJ_UAC_ON=${PROJ_UAC_ON} | ||
|
||
-DAPPLE=${APPLE} | ||
-P ${CMAKE_SOURCE_DIR}/CMake/Includes/git_revision_generate.cmake | ||
COMMENT "Analyzing Git revision/tag changes..." VERBATIM | ||
) | ||
|
||
add_dependencies(${PROJECT_NAME} git_revision) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.