1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 14:08:35 +08:00

Tests: Cover CMP0203 and CMP0204 on all platforms

This commit is contained in:
Alex Overchenko
2025-10-03 15:25:58 +03:00
committed by Brad King
parent 6874efb592
commit b554dead95
5 changed files with 27 additions and 26 deletions

View File

@@ -1438,20 +1438,12 @@ if(CMake_TEST_Emscripten_TOOLCHAINS)
set_property(TEST RunCMake.Emscripten APPEND PROPERTY LABELS "Emscripten") set_property(TEST RunCMake.Emscripten APPEND PROPERTY LABELS "Emscripten")
endif() endif()
if (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") add_RunCMake_test(SharedLibraryDefines
add_RunCMake_test(SharedLibraryDefines -DCMake_TEST_CUDA=${CMake_TEST_CUDA}
-DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} )
-DCMAKE_C_SIMULATE_ID=${CMAKE_C_SIMULATE_ID} set_property(TEST RunCMake.SharedLibraryDefines APPEND PROPERTY LABELS "CUDA")
-DCMake_TEST_CUDA=${CMake_TEST_CUDA}
)
set_property(TEST RunCMake.SharedLibraryDefines APPEND PROPERTY LABELS "CUDA")
endif()
if (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") add_RunCMake_test(MsvcCharsetDefines
add_RunCMake_test(MsvcCharsetDefines -DCMake_TEST_CUDA=${CMake_TEST_CUDA}
-DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} )
-DCMAKE_C_SIMULATE_ID=${CMAKE_C_SIMULATE_ID} set_property(TEST RunCMake.MsvcCharsetDefines APPEND PROPERTY LABELS "CUDA")
-DCMake_TEST_CUDA=${CMake_TEST_CUDA}
)
set_property(TEST RunCMake.MsvcCharsetDefines APPEND PROPERTY LABELS "CUDA")
endif()

View File

@@ -4,8 +4,10 @@
# ifndef _MBCS # ifndef _MBCS
# error "_MBCS is not defined, but it should be" # error "_MBCS is not defined, but it should be"
# endif # endif
# if _MBCS != 1 # if !defined(__BORLANDC__)
# error "_MBCS is not defined as 1, but it should be" # if _MBCS != 1
# error "_MBCS is not defined as 1, but it should be"
# endif
# endif # endif
#else #else
# ifdef _MBCS # ifdef _MBCS
@@ -17,8 +19,10 @@
# ifndef _SBCS # ifndef _SBCS
# error "_SBCS is not defined, but it should be" # error "_SBCS is not defined, but it should be"
# endif # endif
# if _SBCS != 1 # if !defined(__BORLANDC__)
# error "_SBCS is not defined as 1, but it should be" # if _SBCS != 1
# error "_SBCS is not defined as 1, but it should be"
# endif
# endif # endif
#else #else
# ifdef _SBCS # ifdef _SBCS
@@ -30,8 +34,10 @@
# ifndef _UNICODE # ifndef _UNICODE
# error "_UNICODE is not defined, but it should be" # error "_UNICODE is not defined, but it should be"
# endif # endif
# if _UNICODE != 1 # if !defined(__BORLANDC__)
# error "_UNICODE is not defined as 1, but it should be" # if _UNICODE != 1
# error "_UNICODE is not defined as 1, but it should be"
# endif
# endif # endif
#else #else
# ifdef _UNICODE # ifdef _UNICODE
@@ -39,7 +45,7 @@
# endif # endif
#endif #endif
int FUNCTION() int FUNCTION(void)
{ {
return 0; return 0;
} }

View File

@@ -48,7 +48,8 @@ foreach(policy_value IN ITEMS OLD WARN NEW)
if (CMAKE_GENERATOR MATCHES "Visual Studio") if (CMAKE_GENERATOR MATCHES "Visual Studio")
# Visual Studio always defines `_MBCS` by default # Visual Studio always defines `_MBCS` by default
set(expected_define "MBCS") set(expected_define "MBCS")
elseif (policy_value STREQUAL "NEW") elseif (policy_value STREQUAL "NEW" AND
("${CMAKE_${language}_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_${language}_SIMULATE_ID}" STREQUAL "MSVC"))
set(expected_define "MBCS") set(expected_define "MBCS")
endif() endif()
msvcCharsetDefs_addTests(${policy_value} Default "${expected_define}" "") msvcCharsetDefs_addTests(${policy_value} Default "${expected_define}" "")

View File

@@ -13,7 +13,7 @@
# endif # endif
#endif #endif
int FUNCTION() int FUNCTION(void)
{ {
return 0; return 0;
} }

View File

@@ -29,4 +29,6 @@ endif()
sharedLibraryDefs_addTests(NEW) sharedLibraryDefs_addTests(NEW)
target_compile_definitions(${language}-CMP0203_NEW_shared PRIVATE "MUST_HAVE_DEFINE") if ("${CMAKE_${language}_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_${language}_SIMULATE_ID}" STREQUAL "MSVC")
target_compile_definitions(${language}-CMP0203_NEW_shared PRIVATE "MUST_HAVE_DEFINE")
endif()