You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
set(MSG_PREFIX "etl |")
determine_version_with_git(${GIT_DIR_LOOKUP_POLICY})
if(NOT ETL_VERSION)
determine_version_with_file("version.txt")
endif()
project(etl VERSION ${ETL_VERSION} LANGUAGES CXX)
And in determine_version_with_git():
if(PROJECT_IS_TOP_LEVEL)
There is unfortunately a bit of a chicken-and-egg problem here. determine_version_with_git() is called before project(), and so PROJECT_IS_TOP_LEVEL is TRUE even when it should be FALSE. For example, when included from another project which is the real top-level. This leads to a warning
message(WARNING "Version string ${VERSION} retrieved with git describe is invalid")
when it should have fallen back on using the version file silently.
PROJECT_IS_TOP_LEVEL should only be used after your project() call, otherwise it is inheriting the state from the project which is including your CMakeLists.txt as a subdirectory, and that may be TRUE or FALSE depending upon whether the project adding you is the top-level or not. It's not useful in determining whether you are the top-level or not.
Suggestion:
Compare CMAKE_CURRENT_LIST_DIR with PROJECT_SOURCE_DIR before the project() call. It will never be true unless you are the real top-level, for example:
In the top-level CMakeLists.txt:
And in
determine_version_with_git()
:There is unfortunately a bit of a chicken-and-egg problem here.
determine_version_with_git()
is called beforeproject()
, and soPROJECT_IS_TOP_LEVEL
is TRUE even when it should be FALSE. For example, when included from another project which is the real top-level. This leads to a warningwhen it should have fallen back on using the version file silently.
PROJECT_IS_TOP_LEVEL
should only be used after yourproject()
call, otherwise it is inheriting the state from the project which is including your CMakeLists.txt as a subdirectory, and that may be TRUE or FALSE depending upon whether the project adding you is the top-level or not. It's not useful in determining whether you are the top-level or not.Suggestion:
Compare
CMAKE_CURRENT_LIST_DIR
withPROJECT_SOURCE_DIR
before theproject()
call. It will never be true unless you are the real top-level, for example:and then use
ETL_IS_TOP_LEVEL
in place ofPROJECT_IS_TOP_LEVEL
indetermine_version_with_git()
.Kind regards,
Roger
The text was updated successfully, but these errors were encountered: