Skip to content

Commit

Permalink
Don't warn on tag missing when subproject (ETLCPP#653) (ETLCPP#655)
Browse files Browse the repository at this point in the history
Different solution than proposed in the issue, since that proposed
solution would given unexpected results when an intermediate
(untagged) commit is checked out.

This change simply skips warning about a missing git version when this
is a subproject, and uses the original version calculation logic.

I've also renamed `determine_version` to `determine_version_with_file`.
I'd originally done this in an intermediate version of this PR, but I
think that keeping the renaming is clearer code.
  • Loading branch information
flaviut authored Jan 4, 2023
1 parent e74f8b4 commit e66750d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/helpers.cmake)
set(MSG_PREFIX "etl |")
determine_version_with_git(${GIT_DIR_LOOKUP_POLICY})
if(NOT ETL_VERSION)
determine_version("version.txt")
determine_version_with_file("version.txt")
endif()

project(etl VERSION ${ETL_VERSION} LANGUAGES CXX)
Expand Down
8 changes: 6 additions & 2 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function(determine_version VER_FILE_NAME)
function(determine_version_with_file VER_FILE_NAME)
file(READ ${VER_FILE_NAME} ETL_VERSION_RAW)
# Remove trailing whitespaces and/or newline
string(STRIP ${ETL_VERSION_RAW} ETL_VERSION)
Expand All @@ -13,7 +13,11 @@ function(determine_version_with_git)
git_describe(VERSION ${ARGN})
string(FIND ${VERSION} "." VALID_VERSION)
if(VALID_VERSION EQUAL -1)
message(WARNING "Version string ${VERSION} retrieved with git describe is invalid")
if(PROJECT_IS_TOP_LEVEL)
# only warn if this is the top-level project, since we may be
# building from a tarball as a subproject
message(WARNING "Version string ${VERSION} retrieved with git describe is invalid")
endif()
return()
endif()
message(STATUS "${MSG_PREFIX} Version string determined with git describe: ${VERSION}")
Expand Down

0 comments on commit e66750d

Please sign in to comment.