Skip to content

Fix linking libuuid on Windows #6460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(UUID_INCLUDE "")
set(UUID_LIBRARIES "")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(UUID_INCLUDE "")
set(UUID_LIBRARIES "ole32.lib")
else()
find_package(UUID REQUIRED)
set(UUID_INCLUDE "-I${UUID_INCLUDE_DIRS}")
Expand Down
7 changes: 4 additions & 3 deletions lib/Basic/UUID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
// WIN32 doesn't natively support <uuid/uuid.h>. Instead, we use Win32 APIs.
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <rpc.h>
#define NOMINMAX
#include <objbase.h>
#include <string>
#else
#include <uuid/uuid.h>
Expand All @@ -31,7 +32,7 @@ using namespace swift;
swift::UUID::UUID(FromRandom_t) {
#if defined(_WIN32)
::UUID uuid;
UuidCreate(&uuid);
::CoCreateGuid(&uuid);

memcpy(Value, &uuid, Size);
#else
Expand All @@ -42,7 +43,7 @@ swift::UUID::UUID(FromRandom_t) {
swift::UUID::UUID(FromTime_t) {
#if defined(_WIN32)
::UUID uuid;
UuidCreate(&uuid);
::CoCreateGuid(&uuid);

memcpy(Value, &uuid, Size);
#else
Expand Down