Fix mingw builds

This commit is contained in:
Michał Janiszewski 2017-11-14 16:03:07 +01:00 committed by Chris Marsh
parent 767b15184f
commit f22f299330
3 changed files with 16 additions and 8 deletions

View file

@ -32,7 +32,7 @@ execute_process(
ERROR_QUIET
)
find_file(RAPIDJSONTEST NAMES rapidjson rapidjson-1.1.0 PATHS ${CMAKE_SOURCE_DIR}/thirdparty)
find_file(RAPIDJSONTEST NAMES rapidjson rapidjson-1.1.0 PATHS ${CMAKE_SOURCE_DIR}/thirdparty CMAKE_FIND_ROOT_PATH_BOTH)
if (NOT RAPIDJSONTEST)
message("no rapidjson, download")
set(RJ_TAR_FILE ${CMAKE_SOURCE_DIR}/thirdparty/v1.1.0.tar.gz)
@ -44,7 +44,7 @@ if (NOT RAPIDJSONTEST)
file(REMOVE ${RJ_TAR_FILE})
endif(NOT RAPIDJSONTEST)
find_file(RAPIDJSON NAMES rapidjson rapidjson-1.1.0 PATHS ${CMAKE_SOURCE_DIR}/thirdparty)
find_file(RAPIDJSON NAMES rapidjson rapidjson-1.1.0 PATHS ${CMAKE_SOURCE_DIR}/thirdparty CMAKE_FIND_ROOT_PATH_BOTH)
add_library(rapidjson STATIC IMPORTED ${RAPIDJSON})

View file

@ -29,6 +29,7 @@ if(WIN32)
add_definitions(-DDISCORD_WINDOWS)
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
add_library(discord-rpc ${RPC_LIBRARY_TYPE} ${BASE_RPC_SRC})
if (MSVC)
target_compile_options(discord-rpc PRIVATE /EHsc
/MT
/Wall
@ -44,6 +45,8 @@ if(WIN32)
/wd4946 # reinterpret_cast used between related classes
/wd5027 # move assignment operator was implicitly defined as deleted
)
endif(MSVC)
target_link_libraries(discord-rpc PRIVATE psapi)
endif(WIN32)
if(UNIX)

View file

@ -1,3 +1,9 @@
#ifdef __MINGW32__
// 0x0600 == vista
#define WINVER 0x0600
#define _WIN32_WINNT 0x0600
#endif // __MINGW32__
#include "discord-rpc.h"
#include <stdio.h>
@ -6,9 +12,8 @@
#define NOSERVICE
#define NOIME
#include <windows.h>
#include <Psapi.h>
#include <Strsafe.h>
#pragma comment(lib, "Psapi.lib")
#include <psapi.h>
#include <strsafe.h>
void Discord_RegisterW(const wchar_t* applicationId, const wchar_t* command)
{
@ -24,7 +29,7 @@ void Discord_RegisterW(const wchar_t* applicationId, const wchar_t* command)
StringCbPrintfW(openCommand, sizeof(openCommand), L"%s", command);
}
else {
lstrcpyW(openCommand, exeFilePath);
StringCbCopyW(openCommand, sizeof(openCommand), exeFilePath);
}
wchar_t protocolName[64];