Skip to content

Commit eff73e2

Browse files
authored
Merge pull request #310 from jolavillette/FixCMakeGuiVersionFromSuperproject
build(cmake): describe the super-project for the displayed version
2 parents a61b098 + 98e9ee0 commit eff73e2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,19 @@ else()
816816
set(V_GIT_DESCRIBE_OUTPUT "")
817817
set(V_GIT_DESCRIBE_REGEXP "^v([0-9]+).([0-9]+).([0-9]+)(.*)\n$")
818818

819+
# When libretroshare is built inside the RetroShare super-project (as a
820+
# submodule), the displayed "RetroShare Version" must reflect the root
821+
# repository, not this submodule. Describe the parent repo when present;
822+
# fall back to this directory for standalone / FetchContent / Android
823+
# builds where ../.git does not exist.
824+
set(V_GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
825+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../.git")
826+
set(V_GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
827+
endif()
828+
819829
execute_process(
820830
COMMAND ${GIT_EXECUTABLE} describe --tags --long --match v*.*.*
821-
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
831+
WORKING_DIRECTORY "${V_GIT_DIR}"
822832
OUTPUT_VARIABLE V_GIT_DESCRIBE_OUTPUT
823833
RESULT_VARIABLE V_GIT_RESULT ) # Avoid CMake failure if git fails
824834

0 commit comments

Comments
 (0)