Skip to content

Commit bbcdade

Browse files
committed
Improve MS compatibility for Clang/C2
This forces the MS Compatibility flag which enables Windows headers to work CMake is now able to generate a full CMake Clang project. Crashes are occuring in Clang though, should help a lot though to make progress.
1 parent 7095be1 commit bbcdade

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

Source/cmGlobalGenerator.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,11 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
441441

442442
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
443443
# pragma warning (push)
444-
# pragma warning (disable:4996)
444+
# if defined(__clang__)
445+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
446+
# else // MSVC
447+
# pragma warning (disable:4996)
448+
# endif
445449
#endif
446450
GetVersionExW((OSVERSIONINFOW*)&osviex);
447451
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx

Source/cmVisualStudio10TargetGenerator.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,10 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
19501950
{
19511951
clOptions.AddFlag("CompileAs", "CompileAsCpp");
19521952
}
1953+
if(IsClang())
1954+
{
1955+
clOptions.AddFlag("MSCompatibility", "true");
1956+
}
19531957
this->LocalGenerator->AddCompileOptions(flags, this->Target,
19541958
linkLanguage, configName.c_str());
19551959

Source/kwsys/ProcessWin32.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ kwsysProcess* kwsysProcess_New(void)
365365
# pragma warning (push)
366366
# ifdef __INTEL_COMPILER
367367
# pragma warning (disable:1478)
368-
# else
368+
# elif defined(__clang__)
369+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
370+
# else // MSVC
369371
# pragma warning (disable:4996)
370372
# endif
371373
#endif
@@ -2897,8 +2899,8 @@ static int kwsysProcessesAdd(HANDLE hProcess, DWORD dwProcessid,
28972899
newSize = kwsysProcesses.Size? kwsysProcesses.Size*2 : 4;
28982900

28992901
/* Try allocating the new block of memory. */
2900-
if(newArray = (kwsysProcessInstance*)malloc(
2901-
newSize*sizeof(kwsysProcessInstance)))
2902+
if((newArray = (kwsysProcessInstance*)malloc(
2903+
newSize*sizeof(kwsysProcessInstance))))
29022904
{
29032905
/* Copy the old process handles to the new memory. */
29042906
if(kwsysProcesses.Count > 0)

Source/kwsys/SystemInformation.cxx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ typedef struct rlimit ResourceLimitType;
201201
# endif
202202
#endif
203203

204-
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64)
204+
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64) && !defined(__clang__)
205205
#define USE_ASM_INSTRUCTIONS 1
206206
#else
207207
#define USE_ASM_INSTRUCTIONS 0
208208
#endif
209209

210-
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
210+
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__clang__)
211211
#include <intrin.h>
212212
#define USE_CPUID_INTRINSICS 1
213213
#else
@@ -5171,7 +5171,9 @@ bool SystemInformationImplementation::QueryOSInformation()
51715171
# pragma warning (push)
51725172
# ifdef __INTEL_COMPILER
51735173
# pragma warning (disable:1478)
5174-
# else
5174+
# elif defined(__clang__)
5175+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
5176+
# else // MSVC
51755177
# pragma warning (disable:4996)
51765178
# endif
51775179
#endif

Source/kwsys/SystemTools.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4894,7 +4894,9 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
48944894
# pragma warning (push)
48954895
# ifdef __INTEL_COMPILER
48964896
# pragma warning (disable:1478)
4897-
# else
4897+
# elif defined(__clang__)
4898+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
4899+
# else // MSVC
48984900
# pragma warning (disable:4996)
48994901
# endif
49004902
#endif

0 commit comments

Comments
 (0)