1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Ease CMake and legacy build coexistence

Cliff noticed that the CMake git ident was not being updated when
pulling new changes.  This was because it was getting captured at
configuration time and, even if you pull more changes, the CMake
configuration may not be redone automatically if the build files
weren't also changed.

So, this adds a new target to get the information at build time
instead.
This commit is contained in:
Leland Lucius 2020-03-11 22:31:19 -05:00
parent 9d4082d7f1
commit 66aae0900b
3 changed files with 38 additions and 7 deletions

View File

@ -0,0 +1,16 @@
# Executed during build (NOT configuration) to create/update the
# RevisionIdent.h header. It will only update it if there was
# a change in git.
execute_process(
COMMAND
${GIT} show -s "--format=#define REV_LONG \"%H\"%n#define REV_TIME \"%cd\"%n%n"
OUTPUT_FILE
RevisionIdent.h.in
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
COMMAND_ECHO STDOUT
)
configure_file( RevisionIdent.h.in RevisionIdent.h COPYONLY )

View File

@ -53,12 +53,16 @@ hold information about one contributor to Audacity.
#else #else
#include "../images/AudacityLogoWithName.xpm" #include "../images/AudacityLogoWithName.xpm"
#endif #endif
#include "RevisionIdent.h"
// Notice this is a "system include". This is on purpose and only until
// we convert over to CMake. Once converted, the "RevisionIndent.h" file
// should be deleted and this can be changed back to a user include if
// desired.
//
// RevisionIdent.h may contain #defines like these ones: // RevisionIdent.h may contain #defines like these ones:
//#define REV_LONG "28864acb238cb3ca71dda190a2d93242591dd80e" //#define REV_LONG "28864acb238cb3ca71dda190a2d93242591dd80e"
//#define REV_TIME "Sun Apr 12 12:40:22 2015 +0100" //#define REV_TIME "Sun Apr 12 12:40:22 2015 +0100"
#include <RevisionIdent.h>
#ifndef REV_TIME #ifndef REV_TIME
#define REV_TIME "unknown date and time" #define REV_TIME "unknown date and time"

View File

@ -14,6 +14,21 @@ add_dependencies( ${TARGET} plug-ins )
def_vars() def_vars()
# Add a target that will provide the git revision info
# whenever it changes. (Must be done at build time, not
# configuration time.)
if( GIT_FOUND )
add_custom_target(
version
COMMAND
${CMAKE_COMMAND} -D GIT=${GIT_EXECUTABLE}
-P ${CMAKE_MODULE_PATH}/Version.cmake
WORKING_DIRECTORY
${_PRVDIR}
)
add_dependencies( ${TARGET} version )
endif()
# Handle Audio Units option # Handle Audio Units option
if( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) if( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
cmd_option( cmd_option(
@ -1002,10 +1017,6 @@ list( APPEND DEFINES
WXINTL_NO_GETTEXT_MACRO WXINTL_NO_GETTEXT_MACRO
WXUSINGDLL WXUSINGDLL
CMAKE CMAKE
$<$<BOOL:${GIT_FOUND}>:
REV_LONG="${GIT_COMMIT_LONG}"
REV_TIME="${GIT_COMMIT_TIME}"
>
$<$<BOOL:${HAVE_LRINT}>: $<$<BOOL:${HAVE_LRINT}>:
HAVE_LRINT HAVE_LRINT
> >
@ -1347,7 +1358,7 @@ source_group(
${_INTDIR}/CMakeFiles/Audacity.dir/cmake_pch.hxx ${_INTDIR}/CMakeFiles/Audacity.dir/cmake_pch.hxx
) )
target_sources( ${TARGET} PRIVATE ${HEADERS} ${SOURCES} ${RESOURCES} ${MAC_RESOURCES} ${WIN_RESOURCES} ) target_sources( ${TARGET} PRIVATE ${HEADERS} ${SOURCES} ${RESOURCES} ${MAC_RESOURCES} ${WIN_RESOURCES} ${_PRVDIR}/RevisionIdent.h)
target_compile_definitions( ${TARGET} PRIVATE ${DEFINES} ) target_compile_definitions( ${TARGET} PRIVATE ${DEFINES} )
target_compile_options( ${TARGET} PRIVATE ${OPTIONS} ) target_compile_options( ${TARGET} PRIVATE ${OPTIONS} )
target_include_directories( ${TARGET} PRIVATE ${INCLUDES} ) target_include_directories( ${TARGET} PRIVATE ${INCLUDES} )