From 9d0e92a10d7a8b300971ec3baa604f1c21806382 Mon Sep 17 00:00:00 2001 From: orbea Date: Sun, 28 Nov 2021 12:18:44 -0800 Subject: [PATCH] cmake: Generate Revision.h in the build directory --- src/CMakeLists.txt | 9 ++++++--- src/Debugger.cpp | 2 +- src/GLideN64.cpp | 2 +- src/getRevision.sh | 3 ++- src/windows/ZilmarAPIImpl_windows.cpp | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 38c43242..b582cce3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,22 +11,25 @@ option(ANDROID "Set to ON if targeting an Android device" ${ANDROID}) option(GL_PROFILE "Set to ON to turn on GL profiling" ${GL_PROFILE}) # run script to generate Revision.h -set(PATH_REVISION "Revision.h") +set(PATH_REVISION "${CMAKE_CURRENT_BINARY_DIR}/inc/Revision.h") find_package(Git) if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/../.git") add_custom_command( OUTPUT ${PATH_REVISION} - COMMAND ${CMAKE_SOURCE_DIR}/getRevision.sh + COMMAND + OUTPUT=${PATH_REVISION} ${CMAKE_SOURCE_DIR}/getRevision.sh COMMENT "Generate Git version" ) else(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/../.git") add_custom_command( OUTPUT ${PATH_REVISION} - COMMAND ${CMAKE_SOURCE_DIR}/getRevision.sh --nogit + COMMAND + OUTPUT=${PATH_REVISION} ${CMAKE_SOURCE_DIR}/getRevision.sh --nogit COMMENT "Generate version" ) endif(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/../.git") set_property(SOURCE ${PATH_REVISION} PROPERTY SKIP_AUTOGEN ON) +include_directories("${CMAKE_CURRENT_BINARY_DIR}/inc") project( GLideN64 ) diff --git a/src/Debugger.cpp b/src/Debugger.cpp index f8cb09ad..ab4b6f36 100644 --- a/src/Debugger.cpp +++ b/src/Debugger.cpp @@ -1,9 +1,9 @@ #include +#include #include "assert.h" #include "math.h" #include "Platform.h" #include "GLideN64.h" -#include "Revision.h" #include "RSP.h" #include "Config.h" #include "Combiner.h" diff --git a/src/GLideN64.cpp b/src/GLideN64.cpp index d1b2645f..f5950189 100644 --- a/src/GLideN64.cpp +++ b/src/GLideN64.cpp @@ -1,4 +1,4 @@ -#include "Revision.h" +#include char pluginName[] = "GLideN64"; char pluginNameWithRevision[] = "GLideN64 rev." PLUGIN_REVISION; wchar_t pluginNameW[] = L"GLideN64"; diff --git a/src/getRevision.sh b/src/getRevision.sh index 3d2a389c..df1b5237 100755 --- a/src/getRevision.sh +++ b/src/getRevision.sh @@ -4,7 +4,7 @@ set -eu cd -- "$(cd -- "${0%/*}/" && pwd -P)" -header='./Revision.h' +header="${OUTPUT:-./Revision.h}" if [ "${1:-}" != --nogit ] then @@ -23,6 +23,7 @@ printf '%s\n' "current revision $rev" "last build revision $lastrev" if [ "$lastrev" != "$rev" ] then + [ "$header" = "${header##*/}" ] || mkdir -p -- "${header%/*}" printf '%s\n' "#define PLUGIN_REVISION $rev" \ "#define PLUGIN_REVISION_W L$rev" > "$header" fi diff --git a/src/windows/ZilmarAPIImpl_windows.cpp b/src/windows/ZilmarAPIImpl_windows.cpp index b82c0bfd..85b720ad 100644 --- a/src/windows/ZilmarAPIImpl_windows.cpp +++ b/src/windows/ZilmarAPIImpl_windows.cpp @@ -3,8 +3,8 @@ #include "../GLideN64.h" #include "../GLideNUI/GLideNUI.h" #include "../Config.h" -#include "../Revision.h" #include +#include void PluginAPI::DllAbout(/*HWND _hParent*/) {