Browse Source

Set version and project name via CMake

pull/289/head^2
Anders Jenbo 7 years ago
parent
commit
606d5536f2
  1. 11
      CMakeLists.txt
  2. 26
      Source/init.cpp
  3. 4
      SourceS/config.h.in
  4. 19
      SourceS/miniwin/misc.h
  5. 3
      SourceS/miniwin/misc_macro.h
  6. 33
      SourceX/miniwin/misc.cpp

11
CMakeLists.txt

@ -2,13 +2,11 @@ cmake_minimum_required(VERSION 3.7)
include(CMake/out_of_tree.cmake)
set(PROJECT_VERSION 0.5.0)
project(devilutionX
VERSION ${PROJECT_VERSION}
project(DevilutionX
VERSION 0.5.0
LANGUAGES C CXX)
list(APPEND CMAKE_MODULE_PATH "${devilutionX_SOURCE_DIR}/CMake")
list(APPEND CMAKE_MODULE_PATH "${DevilutionX_SOURCE_DIR}/CMake")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
@ -212,7 +210,8 @@ add_executable(devilutionx MACOSX_BUNDLE
./Packaging/macOS/AppIcon.icns
./Packaging/resources/CharisSILB.ttf)
target_include_directories(devilution PUBLIC Source SourceS)
configure_file(SourceS/config.h.in config.h @ONLY)
target_include_directories(devilution PUBLIC Source SourceS ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(devilutionx PRIVATE
SourceX
3rdParty/asio/include

26
Source/init.cpp

@ -3,6 +3,7 @@
#include "../3rdParty/Storm/Source/storm.h"
#include "../DiabloUI/diabloui.h"
#include <SDL.h>
#include <config.h>
DEVILUTION_BEGIN_NAMESPACE
@ -130,29 +131,8 @@ HANDLE init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags
void init_get_file_info()
{
DWORD dwLen;
void *pBlock;
unsigned int uBytes;
DWORD dwHandle;
VS_FIXEDFILEINFO *lpBuffer;
if (GetModuleFileName(ghInst, diablo_exe_path, sizeof(diablo_exe_path))) {
dwLen = GetFileVersionInfoSize(diablo_exe_path, &dwHandle);
if (dwLen) {
pBlock = DiabloAllocPtr(dwLen);
if (GetFileVersionInfo(diablo_exe_path, 0, dwLen, pBlock)) {
if (VerQueryValue(pBlock, "\\", (LPVOID *)&lpBuffer, &uBytes))
sprintf(
gszVersionNumber,
"version %d.%d.%d.%d",
lpBuffer->dwProductVersionMS >> 16,
lpBuffer->dwProductVersionMS & 0xFFFF,
lpBuffer->dwProductVersionLS >> 16,
lpBuffer->dwProductVersionLS & 0xFFFF);
}
mem_free_dbg(pBlock);
}
}
snprintf(gszProductName, MAX_PATH, "%s v%s", PROJECT_NAME, PROJECT_VERSION);
snprintf(gszVersionNumber, MAX_PATH, "version %s", PROJECT_VERSION);
}
LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)

4
SourceS/config.h.in

@ -0,0 +1,4 @@
#pragma once
#define PROJECT_NAME "@PROJECT_NAME@"
#define PROJECT_VERSION "@PROJECT_VERSION@"

19
SourceS/miniwin/misc.h

@ -114,22 +114,6 @@ typedef struct tagSIZE {
LONG cy;
} SIZE;
typedef struct tagVS_FIXEDFILEINFO {
DWORD dwSignature;
DWORD dwStrucVersion;
DWORD dwFileVersionMS;
DWORD dwFileVersionLS;
DWORD dwProductVersionMS;
DWORD dwProductVersionLS;
DWORD dwFileFlagsMask;
DWORD dwFileFlags;
DWORD dwFileOS;
DWORD dwFileType;
DWORD dwFileSubtype;
DWORD dwFileDateMS;
DWORD dwFileDateLS;
} VS_FIXEDFILEINFO;
typedef struct tagMSG {
HWND hwnd;
UINT message;
@ -435,9 +419,6 @@ WINBOOL WINAPI GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerClus
LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters);
DWORD WINAPI GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
WINBOOL WINAPI GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize);
DWORD GetFileVersionInfoSizeA(LPCSTR lptstrFilename, LPDWORD lpdwHandle);
BOOL GetFileVersionInfoA(LPCSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData);
BOOL VerQueryValueA(LPCVOID pBlock, LPCSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen);
WINBOOL WINAPI DeleteFileA(LPCSTR lpFileName);
WINBOOL WINAPI CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, WINBOOL bFailIfExists);
HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle);

3
SourceS/miniwin/misc_macro.h

@ -118,9 +118,6 @@
#define GetDiskFreeSpace GetDiskFreeSpaceA
#define GetModuleFileName GetModuleFileNameA
#define GetComputerName GetComputerNameA
#define GetFileVersionInfoSize GetFileVersionInfoSizeA
#define GetFileVersionInfo GetFileVersionInfoA
#define VerQueryValue VerQueryValueA
#define DeleteFile DeleteFileA
#define CopyFile CopyFileA

33
SourceX/miniwin/misc.cpp

@ -147,39 +147,6 @@ WINBOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize)
return true;
}
DWORD GetFileVersionInfoSizeA(LPCSTR lptstrFilename, LPDWORD lpdwHandle)
{
DUMMY();
*lpdwHandle = 0;
return 1532;
}
BOOL GetFileVersionInfoA(LPCSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData)
{
DUMMY();
*(int *)lpData = 16711836; // TODO use actual version from .rc
return true;
}
BOOL VerQueryValueA(LPCVOID pBlock, LPCSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
{
DUMMY();
static VS_FIXEDFILEINFO lpBuffer;
// Set internal version, TODO use actual version from .rc
lpBuffer.dwProductVersionMS = 1;
lpBuffer.dwProductVersionMS <<= 16;
lpBuffer.dwProductVersionMS |= 0 & 0xFFFF;
lpBuffer.dwProductVersionLS = 9;
lpBuffer.dwProductVersionLS <<= 16;
lpBuffer.dwProductVersionLS |= 2 & 0xFFFF;
*lplpBuffer = (LPVOID *)&lpBuffer;
return true;
}
DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer)
{
char *base_path = SDL_GetBasePath();

Loading…
Cancel
Save