Browse Source

CMP0204: Remove redundant cases from RunCMake.MsvcCharsetDefines

A single executable for each policy/charset combination is sufficient.
The behavior is the same across target types.

The "OLD" cases are not needed because "WARN" has the same behavior.

The `-D` cases are not needed because `target_compile_definitions`
strips the `-D` prefix before populating `COMPILE_DEFINITIONS`.
Brad King 3 weeks ago
parent
commit
948b2fe31a

+ 51 - 1
Tests/RunCMake/MsvcCharsetDefines/checker.c

@@ -1 +1,51 @@
-#include "checker.h"
+#pragma once
+
+#ifdef MUST_HAVE_DEFINE_MBCS
+#  ifndef _MBCS
+#    error "_MBCS is not defined, but it should be"
+#  endif
+#  if !defined(__BORLANDC__)
+#    if _MBCS != 1
+#      error "_MBCS is not defined as 1, but it should be"
+#    endif
+#  endif
+#else
+#  ifdef _MBCS
+#    error "_MBCS is defined, but it should not be"
+#  endif
+#endif
+
+#ifdef MUST_HAVE_DEFINE_SBCS
+#  ifndef _SBCS
+#    error "_SBCS is not defined, but it should be"
+#  endif
+#  if !defined(__BORLANDC__)
+#    if _SBCS != 1
+#      error "_SBCS is not defined as 1, but it should be"
+#    endif
+#  endif
+#else
+#  ifdef _SBCS
+#    error "_SBCS is defined, but it should not be"
+#  endif
+#endif
+
+#ifdef MUST_HAVE_DEFINE_UNICODE
+#  ifndef _UNICODE
+#    error "_UNICODE is not defined, but it should be"
+#  endif
+#  if !defined(__BORLANDC__)
+#    if _UNICODE != 1
+#      error "_UNICODE is not defined as 1, but it should be"
+#    endif
+#  endif
+#else
+#  ifdef _UNICODE
+#    error "_UNICODE is defined, but it should not be"
+#  endif
+#endif
+
+int main(void)
+{
+  return 0;
+}

+ 1 - 1
Tests/RunCMake/MsvcCharsetDefines/checker.cu

@@ -1 +1 @@
-#include "checker.h"
+#include "checker.c"

+ 1 - 1
Tests/RunCMake/MsvcCharsetDefines/checker.cxx

@@ -1 +1 @@
-#include "checker.h"
+#include "checker.c"

+ 0 - 51
Tests/RunCMake/MsvcCharsetDefines/checker.h

@@ -1,51 +0,0 @@
-#pragma once
-
-#ifdef MUST_HAVE_DEFINE_MBCS
-#  ifndef _MBCS
-#    error "_MBCS is not defined, but it should be"
-#  endif
-#  if !defined(__BORLANDC__)
-#    if _MBCS != 1
-#      error "_MBCS is not defined as 1, but it should be"
-#    endif
-#  endif
-#else
-#  ifdef _MBCS
-#    error "_MBCS is defined, but it should not be"
-#  endif
-#endif
-
-#ifdef MUST_HAVE_DEFINE_SBCS
-#  ifndef _SBCS
-#    error "_SBCS is not defined, but it should be"
-#  endif
-#  if !defined(__BORLANDC__)
-#    if _SBCS != 1
-#      error "_SBCS is not defined as 1, but it should be"
-#    endif
-#  endif
-#else
-#  ifdef _SBCS
-#    error "_SBCS is defined, but it should not be"
-#  endif
-#endif
-
-#ifdef MUST_HAVE_DEFINE_UNICODE
-#  ifndef _UNICODE
-#    error "_UNICODE is not defined, but it should be"
-#  endif
-#  if !defined(__BORLANDC__)
-#    if _UNICODE != 1
-#      error "_UNICODE is not defined as 1, but it should be"
-#    endif
-#  endif
-#else
-#  ifdef _UNICODE
-#    error "_UNICODE is defined, but it should not be"
-#  endif
-#endif
-
-int FUNCTION(void)
-{
-  return 0;
-}

+ 6 - 25
Tests/RunCMake/MsvcCharsetDefines/common.cmake

@@ -9,40 +9,21 @@ function(msvcCharsetDefs_addTests policy_value suffix expected_define passed_def
 
     set(suffix "CMP0204-${policy_value}_${suffix}")
 
-    add_executable(${language}-${suffix}_executable checker.${extension})
-    target_compile_definitions(${language}-${suffix}_executable PRIVATE "FUNCTION=main")
-
-    add_library(${language}-${suffix}_shared SHARED checker.${extension})
-    target_compile_definitions(${language}-${suffix}_shared PRIVATE "FUNCTION=test")
-
-    add_library(${language}-${suffix}_static STATIC checker.${extension})
-    target_compile_definitions(${language}-${suffix}_static PRIVATE "FUNCTION=test")
-
-    add_library(${language}-${suffix}_object OBJECT checker.${extension})
-    target_compile_definitions(${language}-${suffix}_object PRIVATE "FUNCTION=test")
-
-    foreach(target IN ITEMS ${language}-${suffix}_executable ${language}-${suffix}_shared ${language}-${suffix}_static ${language}-${suffix}_object)
-      target_compile_definitions(${target} PRIVATE
-        "MUST_HAVE_DEFINE_${expected_define}"
-        "${passed_define}"
-      )
-    endforeach()
+    add_executable(${language}-${suffix} checker.${extension})
+    target_compile_definitions(${language}-${suffix} PRIVATE
+      "MUST_HAVE_DEFINE_${expected_define}"
+      "${passed_define}"
+    )
   endblock()
 endfunction()
 
-foreach(policy_value IN ITEMS OLD WARN NEW)
+foreach(policy_value IN ITEMS WARN NEW)
   msvcCharsetDefs_addTests(${policy_value} MBCS_NO_VALUE MBCS _MBCS)
   msvcCharsetDefs_addTests(${policy_value} SBCS_NO_VALUE SBCS _SBCS)
   msvcCharsetDefs_addTests(${policy_value} UNICODE_NO_VALUE UNICODE _UNICODE)
   msvcCharsetDefs_addTests(${policy_value} MBCS_WITH_VALUE MBCS _MBCS=1)
   msvcCharsetDefs_addTests(${policy_value} SBCS_WITH_VALUE SBCS _SBCS=1)
   msvcCharsetDefs_addTests(${policy_value} UNICODE_WITH_VALUE UNICODE _UNICODE=1)
-  msvcCharsetDefs_addTests(${policy_value} D_MBCS_NO_VALUE MBCS -D_MBCS)
-  msvcCharsetDefs_addTests(${policy_value} D_SBCS_NO_VALUE SBCS -D_SBCS)
-  msvcCharsetDefs_addTests(${policy_value} D_UNICODE_NO_VALUE UNICODE -D_UNICODE)
-  msvcCharsetDefs_addTests(${policy_value} D_MBCS_WITH_VALUE MBCS -D_MBCS=1)
-  msvcCharsetDefs_addTests(${policy_value} D_SBCS_WITH_VALUE SBCS -D_SBCS=1)
-  msvcCharsetDefs_addTests(${policy_value} D_UNICODE_WITH_VALUE UNICODE -D_UNICODE=1)
 
   set(expected_define "")
   if (CMAKE_GENERATOR MATCHES "Visual Studio")