Browse Source

Git is now a mandatory build dependency

We are planning to use Git to detect the current version of Tenacity, instead
of depending on a hardcoded variable, as that is an approach that is far from
foolproof. We already depended on it for Windows and macOS builds, as vcpkg
uses Git to fetch a couple of dependencies. The vcpkg has also been
appropriately adjusted and cleaned up.

It may seem a bit excessive, but the operating systems we support all have
a version of Git that is available and it is not a runtime dependency. We
assume that people who can gain access to the source code can also install
a copy of Git. If we actually come across some sort of an extreme edge case
where this is not true, we can set the versions to `9999` just like in
`win/tenacity.rc`, in order to ensure portability, at a later point in time.

This change is a measure that will ensure that we are going to avoid mistakes
that we will not be able to undo later.

Signed-off-by: Panagiotis Vasilopoulos <hello@alwayslivid.com>
panos/git-build-dependency
Panagiotis Vasilopoulos 4 months ago
parent
commit
04b436dfa6
No known key found for this signature in database GPG Key ID: 9E541BDE43B99F44
  1. 130
      CMakeLists.txt

130
CMakeLists.txt

@ -46,48 +46,28 @@ else()
set( AUDACITY_NAME "tenacity")
endif()
if( WIN32 OR APPLE )
option( VCPKG "Use vcpkg for dependencies" ON )
else()
option( VCPKG "Use vcpkg for dependencies" OFF )
endif()
# Make sure that we have actually attempted to find Git
if(NOT GIT_FOUND)
find_package( Git )
endif()
# ~~~~~~~~~
# Version
# ~~~~~~~~~
# Audacity version that Tenacity is based on
set( AUDACITY_VERSION 3 ) # Major version
set( AUDACITY_RELEASE 0 ) # Minor version
set( AUDACITY_REVISION 4 ) # Revision version
set( AUDACITY_MODLEVEL 0 ) # Additional version detail
# Tenacity's version
set( TENACITY_VERSION 0 ) # Major version
set( TENACITY_RELEASE 1 ) # Minor version
set( TENACITY_REVISION 0 ) # Revision version
set( TENACITY_MODLEVEL 0 ) # Additional version detail
set( GIT_DESCRIBE "unknown" )
if( GIT_FOUND )
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=7
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)
if( GIT_DESCRIBE )
# Copy to new variable for string manipulation
set( git_output ${GIT_DESCRIBE} )
# TODO: Remove this after first Tenacity release
string( REPLACE "Audacity-" "" git_output "${git_output}" )
string( REGEX REPLACE "-.*" "" git_output "${git_output}" )
string( REPLACE "." ";" git_output "${git_output}" )
list( GET git_output 0 AUDACITY_VERSION )
list( GET git_output 1 AUDACITY_RELEASE )
list( GET git_output 2 AUDACITY_REVISION )
# Oops, our attempt failed
if(NOT GIT_FOUND)
if( VCPKG )
message( FATAL_ERROR "Git NOT found."
"Please install Git from https://git-scm.com/ or your package manager."
"We use Git to detect the current version of Tenacity, as well as for"
"downloading a couple of dependencies that Tenacity depends on.")
else()
message( FATAL_ERROR "Git NOT found."
"Please install Git from https://git-scm.com/ or your package manager."
"We use Git to detect the current version of Tenacity.")
endif()
endif()
@ -95,12 +75,6 @@ endif()
# Vcpkg
# ~~~~~~~
if( WIN32 OR APPLE )
option( VCPKG "Use vcpkg for dependencies" ON )
else()
option( VCPKG "Use vcpkg for dependencies" OFF )
endif()
if( VCPKG )
set( ENV{VCPKG_DISABLE_METRICS} true )
@ -123,24 +97,15 @@ if( VCPKG )
if( NOT EXISTS "${VCPKG_ROOT}/bootstrap-vcpkg.sh" )
# Make sure we have actually attempted to find Git
if( NOT GIT_FOUND )
find_package( Git )
endif()
if( GIT_FOUND )
message( STATUS "Initializing vcpkg Git submodule" )
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule init
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
else()
message( FATAL_ERROR "Unable to initialize vcpkg Git submodule because CMake was unable to find a git installation" )
endif()
message( STATUS "Initializing vcpkg Git submodule" )
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule init
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
endif()
endif()
@ -165,6 +130,47 @@ else()
message( STATUS "Searching for dependencies from system, not using vcpkg." )
endif()
# ~~~~~~~~~
# Version
# ~~~~~~~~~
# Audacity version that Tenacity is based on
set( AUDACITY_VERSION 3 ) # Major version
set( AUDACITY_RELEASE 0 ) # Minor version
set( AUDACITY_REVISION 4 ) # Revision version
set( AUDACITY_MODLEVEL 0 ) # Additional version detail
# Tenacity's version
set( TENACITY_VERSION 0 ) # Major version
set( TENACITY_RELEASE 1 ) # Minor version
set( TENACITY_REVISION 0 ) # Revision version
set( TENACITY_MODLEVEL 0 ) # Additional version detail
set( GIT_DESCRIBE "unknown" )
if( GIT_FOUND )
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=7
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)
if( GIT_DESCRIBE )
# Copy to new variable for string manipulation
set( git_output ${GIT_DESCRIBE} )
# TODO: Remove this after first Tenacity release
string( REPLACE "Audacity-" "" git_output "${git_output}" )
string( REGEX REPLACE "-.*" "" git_output "${git_output}" )
string( REPLACE "." ";" git_output "${git_output}" )
list( GET git_output 0 AUDACITY_VERSION )
list( GET git_output 1 AUDACITY_RELEASE )
list( GET git_output 2 AUDACITY_REVISION )
endif()
endif()
# ~~~~~~~~~~~~~~~~~~~~~~
# CMake input validation
# ~~~~~~~~~~~~~~~~~~~~~~

Loading…
Cancel
Save