aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt31
1 files changed, 24 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 551afac..ac0bc1d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,16 +18,28 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Concurrent)
find_package(mastodonpp REQUIRED)
# Get Git commit hash, from http://xit0.org/2013/04/cmake-use-git-branch-and-commit-details-in-project/
-# Get the latest commit hash of the working branch
+# Get a human-readable name of the latest commit on the current branch
execute_process(
- COMMAND git log -1 --format=%H
+ COMMAND git log -1 --format=%(describe)
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_VARIABLE GIT_COMMIT_HASH
+ OUTPUT_VARIABLE GIT_DESCRIBE_TEXT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
-# Put the hash between " so it is a string litteral
-string(PREPEND GIT_COMMIT_HASH "\"")
-string(APPEND GIT_COMMIT_HASH "\"")
+if (GIT_DESCRIBE_TEXT)
+ # Put the hash between " so it is a string litteral
+ string(PREPEND GIT_DESCRIBE_TEXT "\"")
+ string(APPEND GIT_DESCRIBE_TEXT "\"")
+else()
+ # Get the latest commit hash of the working branch
+ execute_process(
+ COMMAND git log -1 --format=%H
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE GIT_COMMIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ string(PREPEND GIT_COMMIT_HASH "\"")
+ string(APPEND GIT_COMMIT_HASH "\"")
+endif()
# add_subdirectory will happen later…
set(PROJECT_SOURCES
@@ -107,7 +119,12 @@ else()
endif()
endif()
-target_compile_definitions(ActorViewer PRIVATE GIT_COMMIT_HASH=${GIT_COMMIT_HASH})
+if (GIT_DESCRIBE_TEXT)
+ target_compile_definitions(ActorViewer PRIVATE GIT_DESCRIBE_TEXT=${GIT_DESCRIBE_TEXT})
+else()
+ target_compile_definitions(ActorViewer PRIVATE GIT_COMMIT_HASH=${GIT_COMMIT_HASH})
+endif()
+
target_link_libraries(ActorViewer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets mastodonpp)
set_target_properties(ActorViewer PROPERTIES