浏览代码

Tests: handle string escaping differences with NMake+clang

Zsolt Parragi 6 年之前
父节点
当前提交
19669abe1d
共有 3 个文件被更改,包括 13 次插入6 次删除
  1. 1 1
      Tests/CompileOptions/CMakeLists.txt
  2. 10 4
      Tests/Preprocess/CMakeLists.txt
  3. 2 1
      Tests/Preprocess/preprocess.c

+ 1 - 1
Tests/CompileOptions/CMakeLists.txt

@@ -42,7 +42,7 @@ else()
     )
     )
 endif()
 endif()
 
 
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero")
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero" AND NOT "${CMAKE_GENERATOR}" MATCHES "NMake Makefiles")
   set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS
   set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS
     "-DTEST_OCTOTHORPE=\"#\""
     "-DTEST_OCTOTHORPE=\"#\""
     )
     )

+ 10 - 4
Tests/Preprocess/CMakeLists.txt

@@ -28,6 +28,11 @@ endif()
 if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
 if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
   set(PP_VS 1)
   set(PP_VS 1)
 endif()
 endif()
+if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND
+   "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND
+   "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
+   set(CLANG_GNULIKE_WINDOWS 1)
+endif()
 
 
 # Some tests below check the PP_* variables set above.  They are meant
 # Some tests below check the PP_* variables set above.  They are meant
 # to test the case that the build tool is at fault.  Other tests below
 # to test the case that the build tool is at fault.  Other tests below
@@ -53,7 +58,7 @@ endif()
 
 
 string(APPEND STRING_EXTRA " ")
 string(APPEND STRING_EXTRA " ")
 
 
-if(NOT PP_BORLAND AND NOT PP_WATCOM)
+if(NOT PP_BORLAND AND NOT PP_WATCOM AND NOT CLANG_GNULIKE_WINDOWS)
   # Borland, WMake: multiple spaces
   # Borland, WMake: multiple spaces
   # The make tool seems to remove extra whitespace from inside
   # The make tool seems to remove extra whitespace from inside
   # quoted strings when passing to the compiler.  It does not have
   # quoted strings when passing to the compiler.  It does not have
@@ -70,14 +75,14 @@ if(NOT PP_VS)
   string(APPEND STRING_EXTRA ",")
   string(APPEND STRING_EXTRA ",")
 endif()
 endif()
 
 
-if(NOT PP_MINGW)
+if(NOT PP_MINGW AND NOT CLANG_GNULIKE_WINDOWS)
   # MinGW: &
   # MinGW: &
   # When inside -D"FOO=\"a & b\"" MinGW make wants -D"FOO=\"a "&" b\""
   # When inside -D"FOO=\"a & b\"" MinGW make wants -D"FOO=\"a "&" b\""
   # but it does not like quoted ampersand elsewhere.
   # but it does not like quoted ampersand elsewhere.
   string(APPEND STRING_EXTRA "&")
   string(APPEND STRING_EXTRA "&")
 endif()
 endif()
 
 
-if(NOT PP_MINGW)
+if(NOT PP_MINGW AND NOT CLANG_GNULIKE_WINDOWS)
   # MinGW: |
   # MinGW: |
   # When inside -D"FOO=\"a | b\"" MinGW make wants -D"FOO=\"a "|" b\""
   # When inside -D"FOO=\"a | b\"" MinGW make wants -D"FOO=\"a "|" b\""
   # but it does not like quoted pipe elsewhere.
   # but it does not like quoted pipe elsewhere.
@@ -100,7 +105,8 @@ endif()
 
 
 set(EXPR_OP1 "/")
 set(EXPR_OP1 "/")
 if((NOT MSVC OR PP_NMAKE) AND
 if((NOT MSVC OR PP_NMAKE) AND
-   NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
+   NOT CMAKE_C_COMPILER_ID STREQUAL "Intel" AND
+   NOT CLANG_GNULIKE_WINDOWS)
   # MSVC cl, Intel icl: %
   # MSVC cl, Intel icl: %
   # When the cl compiler is invoked from the command line then % must
   # When the cl compiler is invoked from the command line then % must
   # be written %% (to distinguish from %ENV% syntax).  However cl does
   # be written %% (to distinguish from %ENV% syntax).  However cl does

+ 2 - 1
Tests/Preprocess/preprocess.c

@@ -10,7 +10,8 @@ int check_defines_C(void)
 {
 {
   int result = 1;
   int result = 1;
   if (strcmp(FILE_STRING, STRING_VALUE) != 0) {
   if (strcmp(FILE_STRING, STRING_VALUE) != 0) {
-    fprintf(stderr, "FILE_STRING has wrong value in C [%s]\n", FILE_STRING);
+    fprintf(stderr, "FILE_STRING has wrong value in C [%s] vs [%s]\n",
+            FILE_STRING, STRING_VALUE);
     result = 0;
     result = 0;
   }
   }
   if (strcmp(TARGET_STRING, STRING_VALUE) != 0) {
   if (strcmp(TARGET_STRING, STRING_VALUE) != 0) {