Skip to content

Commit a61b098

Browse files
authored
Merge pull request #309 from jolavillette/FixCMakeLibVersionHash
build(cmake): define RS_LIB_VERSION_HASH so libRetroShareVersion() works
2 parents 51c969f + 2ed43ac commit a61b098

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,29 @@ endif(V_VERSION_SET)
851851

852852
################################################################################
853853

854+
# Engine build hash exposed through RsInit::libRetroShareVersion().
855+
# Ported from the qmake build (libretroshare.pro RS_LIB_VERSION_HASH block):
856+
# describe the libretroshare submodule itself and drop the leading 'v' to
857+
# match the GUI version style. Used only inside libretroshare, hence PRIVATE.
858+
execute_process(
859+
COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty
860+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
861+
OUTPUT_VARIABLE RS_LIB_VERSION_HASH
862+
OUTPUT_STRIP_TRAILING_WHITESPACE
863+
RESULT_VARIABLE V_GIT_HASH_RESULT ) # Avoid CMake failure if git fails
864+
865+
if(V_GIT_HASH_RESULT EQUAL 0 AND NOT RS_LIB_VERSION_HASH STREQUAL "")
866+
string(REGEX REPLACE "^v" "" RS_LIB_VERSION_HASH "${RS_LIB_VERSION_HASH}")
867+
message(STATUS "libRetroShare engine hash ${RS_LIB_VERSION_HASH}")
868+
target_compile_definitions(
869+
${PROJECT_NAME}
870+
PRIVATE RS_LIB_VERSION_HASH="${RS_LIB_VERSION_HASH}" )
871+
else()
872+
message(WARNING "Determining libRetroShare engine hash via git failed")
873+
endif()
874+
875+
################################################################################
876+
854877
# TODO: Use generator expressions instead of CMAKE_BUILD_TYPE see
855878
# https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#build-configurations
856879
# https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#manual:cmake-generator-expressions(7)

0 commit comments

Comments
 (0)