1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

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>
This commit is contained in:
Panagiotis Vasilopoulos
2021-09-19 19:16:54 +02:00
parent dbe4b564d4
commit 04b436dfa6

View File

@@ -46,10 +46,90 @@ 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()
# 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()
# ~~~~~~~
# Vcpkg
# ~~~~~~~
if( VCPKG )
set( ENV{VCPKG_DISABLE_METRICS} true )
if( NOT DEFINED ENV{VCPKG_BINARY_SOURCES} )
set( ENV{VCPKG_BINARY_SOURCES} "clear;nuget,tenacityteam_github_auto,read;" )
endif()
set( ENV{VCPKG_FEATURE_FLAGS} "-compilertracking,manifests,registries,versions" )
if( VCPKG_ROOT )
message( STATUS "Using dependencies from vcpkg repository at ${VCPKG_ROOT}" )
if( NOT EXISTS "${VCPKG_ROOT}/bootstrap-vcpkg.sh" )
message( FATAL_ERROR "${VCPKG_ROOT} is not a vcpkg Git repository." )
endif()
else()
message( STATUS "Using dependencies from vcpkg Git submodule" )
set( VCPKG_ROOT "${CMAKE_SOURCE_DIR}/vcpkg" )
if( NOT EXISTS "${VCPKG_ROOT}/bootstrap-vcpkg.sh" )
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()
if( NOT DEFINED VCPKG_OVERLAY_PORTS )
set( VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/ports" )
endif()
if( NOT DEFINED VCPKG_OVERLAY_TRIPLETS )
set( VCPKG_OVERLAY_TRIPLETS "${VCPKG_ROOT}/overlay/triplets" )
endif()
if( NOT DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET )
if( APPLE )
set( VCPKG_TARGET_TRIPLET "x64-osx-10.12min" )
endif()
elseif( DEFINED ENV{VCPKG_DEFAULT_TRIPLET} )
set( VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" )
endif()
set( CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" )
else()
message( STATUS "Searching for dependencies from system, not using vcpkg." )
endif()
# ~~~~~~~~~
# Version
# ~~~~~~~~~
@@ -91,80 +171,6 @@ if( GIT_FOUND )
endif()
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 )
if( NOT DEFINED ENV{VCPKG_BINARY_SOURCES} )
set( ENV{VCPKG_BINARY_SOURCES} "clear;nuget,tenacityteam_github_auto,read;" )
endif()
set( ENV{VCPKG_FEATURE_FLAGS} "-compilertracking,manifests,registries,versions" )
if( VCPKG_ROOT )
message( STATUS "Using dependencies from vcpkg repository at ${VCPKG_ROOT}" )
if( NOT EXISTS "${VCPKG_ROOT}/bootstrap-vcpkg.sh" )
message( FATAL_ERROR "${VCPKG_ROOT} is not a vcpkg Git repository." )
endif()
else()
message( STATUS "Using dependencies from vcpkg Git submodule" )
set( VCPKG_ROOT "${CMAKE_SOURCE_DIR}/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()
endif()
endif()
if( NOT DEFINED VCPKG_OVERLAY_PORTS )
set( VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/ports" )
endif()
if( NOT DEFINED VCPKG_OVERLAY_TRIPLETS )
set( VCPKG_OVERLAY_TRIPLETS "${VCPKG_ROOT}/overlay/triplets" )
endif()
if( NOT DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET )
if( APPLE )
set( VCPKG_TARGET_TRIPLET "x64-osx-10.12min" )
endif()
elseif( DEFINED ENV{VCPKG_DEFAULT_TRIPLET} )
set( VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" )
endif()
set( CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" )
else()
message( STATUS "Searching for dependencies from system, not using vcpkg." )
endif()
# ~~~~~~~~~~~~~~~~~~~~~~
# CMake input validation
# ~~~~~~~~~~~~~~~~~~~~~~