MSVC: Always define a character set

When targeting the MSVC ABI, define `_MBCS` by default if the project
does not define `_SBCS` or `_UNICODE`.  Visual Studio has long defined
one of the three character set macros automatically.  For consistency,
define it when compiling for the MSVC ABI with other generators.
Add policy CMP0204 for compatibility.

Fixes: #27275
This commit is contained in:
AJIOB
2025-09-24 18:54:02 +03:00
committed by Brad King
parent 2cae68ecbe
commit 6874efb592
86 changed files with 819 additions and 137 deletions

View File

@@ -98,6 +98,7 @@ Policies Introduced by CMake 4.2
.. toctree::
:maxdepth: 1
CMP0204: A character set is always defined when targeting the MSVC ABI. </policy/CMP0204>
CMP0203: _WINDLL is defined for shared libraries targeting the MSVC ABI. </policy/CMP0203>
CMP0202: PDB file names always include their target's per-config POSTFIX. </policy/CMP0202>
CMP0201: Python::NumPy does not depend on Python::Development.Module. </policy/CMP0201>

29
Help/policy/CMP0204.rst Normal file
View File

@@ -0,0 +1,29 @@
CMP0204
-------
.. versionadded:: 4.2
A character set is always defined when targeting the MSVC ABI.
In CMake 4.1 and below, :ref:`Visual Studio Generators` compile sources in with
``_MBCS``, ``_UNICODE`` or ``_SBCS`` defined due to behavior of Visual Studio
itself. The preprocessor definition is not modeled by CMake and is therefore
not added by other generators, such as :generator:`Ninja`.
CMake 4.2 and above, when targeting the MSVC ABI, prefer to compile sources
with ``_MBCS`` defined by all generators unless another charset preprocessor
definition is found (``_UNICODE`` or ``_SBCS``).
This policy provides compatibility with projects that have not been updated
to be aware of the definition. Its setting is recorded by each target as
it is created, and affects compilation of sources in that target.
The ``OLD`` behavior for this policy does not model the ``_MBCS``
preprocessor definition in CMake itself. The ``NEW`` behavior for this
policy adds the ``_MBCS`` preprocessor definition to sources
as a default encoding when targeting the MSVC ABI.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.2
.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
.. include:: include/STANDARD_ADVICE.rst
.. include:: include/DEPRECATED.rst

View File

@@ -0,0 +1,6 @@
define-msvc-char-set
--------------------
* For builds targeting the MSVC ABI, all generators now add the ``_MBCS``
preprocessor definition when compiling sources unless ``_UNICODE`` or ``_SBCS``
is found. See policy :policy:`CMP0204`.

View File

@@ -1538,6 +1538,17 @@ public:
std::string BuildDatabasePath(std::string const& lang,
std::string const& config) const;
enum class MsvcCharSet
{
None,
Unicode,
MultiByte,
SingleByte,
};
// Detect if the current define selects any known charset entry or not
static MsvcCharSet GetMsvcCharSet(std::string const& singleDefine);
private:
void BuildFileSetInfoCache(std::string const& config) const;
struct InfoByConfig

View File

@@ -38,6 +38,12 @@ enum class OptionsParse
Shell
};
struct MsvcCharSetInfo
{
cmGeneratorTarget::MsvcCharSet CharSet;
bool IsNeedToAddDefine;
};
namespace {
auto const DL_BEGIN = "<DEVICE_LINK>"_s;
auto const DL_END = "</DEVICE_LINK>"_s;
@@ -205,6 +211,45 @@ std::vector<BT<std::string>> wrapOptions(
}
return result;
}
cm::string_view const UNICODE_DEFINITION = "_UNICODE"_s;
cm::string_view const MBCS_DEFINITION = "_MBCS"_s;
cm::string_view const SBCS_DEFINITION = "_SBCS"_s;
constexpr char UNICODE_DEFINITION_PREFIX[] = "_UNICODE=";
constexpr char MBCS_DEFINITION_PREFIX[] = "_MBCS=";
constexpr char SBCS_DEFINITION_PREFIX[] = "_SBCS=";
MsvcCharSetInfo GetMsvcCharSetInfo(
cmGeneratorTarget const& tgt, std::string const& lang,
EvaluatedTargetPropertyEntries const& entries)
{
using MsvcCharSet = cmGeneratorTarget::MsvcCharSet;
if (tgt.Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_ID")) != "MSVC"_s &&
tgt.Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_SIMULATE_ID")) != "MSVC"_s) {
// Only MSVC ABI uses this feature
return { MsvcCharSet::None, false };
}
for (EvaluatedTargetPropertyEntry const& entry : entries.Entries) {
for (std::string const& value : entry.Values) {
MsvcCharSet charSet = cmGeneratorTarget::GetMsvcCharSet(value);
if (charSet != MsvcCharSet::None) {
return { charSet, false };
}
}
}
// Default to multi-byte, similar to the Visual Studio generator
// Define the default charset for Visual Studio too:
// it should filter it out if need
return { MsvcCharSet::MultiByte, true };
}
}
void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
@@ -343,6 +388,34 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
AddInterfaceEntries(this, "INTERFACE_COMPILE_DEFINITIONS", context,
&dagChecker, entries, IncludeRuntimeInterface::Yes);
// Add the character set definition
MsvcCharSetInfo charSetInfo = GetMsvcCharSetInfo(*this, language, entries);
if (charSetInfo.IsNeedToAddDefine &&
this->GetPolicyStatusCMP0204() == cmPolicies::NEW) {
cm::string_view define;
switch (charSetInfo.CharSet) {
case MsvcCharSet::None:
// Nothing to set
break;
case MsvcCharSet::Unicode:
define = UNICODE_DEFINITION;
break;
case MsvcCharSet::MultiByte:
define = MBCS_DEFINITION;
break;
case MsvcCharSet::SingleByte:
define = SBCS_DEFINITION;
break;
}
if (!define.empty()) {
std::unique_ptr<TargetPropertyEntry> property =
TargetPropertyEntry::Create(*this->LocalGenerator->GetCMakeInstance(),
std::string{ define });
entries.Entries.emplace_back(
EvaluateTargetPropertyEntry(this, context, &dagChecker, *property));
}
}
processOptions(this, entries, list, uniqueOptions, debugDefines,
"compile definitions", OptionsParse::None);
@@ -677,3 +750,24 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDepends(
return result;
}
cmGeneratorTarget::MsvcCharSet cmGeneratorTarget::GetMsvcCharSet(
std::string const& singleDefine)
{
if (singleDefine == UNICODE_DEFINITION ||
cmHasLiteralPrefix(singleDefine, UNICODE_DEFINITION_PREFIX)) {
return MsvcCharSet::Unicode;
}
if (singleDefine == MBCS_DEFINITION ||
cmHasLiteralPrefix(singleDefine, MBCS_DEFINITION_PREFIX)) {
return MsvcCharSet::MultiByte;
}
if (singleDefine == SBCS_DEFINITION ||
cmHasLiteralPrefix(singleDefine, SBCS_DEFINITION_PREFIX)) {
return MsvcCharSet::SingleByte;
}
return MsvcCharSet::None;
}

View File

@@ -4193,6 +4193,11 @@ bool cmLocalGenerator::IsNinjaMulti() const
return this->GetState()->UseNinjaMulti();
}
bool cmLocalGenerator::IsWindowsVSIDE() const
{
return this->GetState()->UseWindowsVSIDE();
}
namespace {
std::string relativeIfUnder(std::string const& top, std::string const& cur,
std::string const& path)

View File

@@ -544,6 +544,7 @@ public:
bool IsMinGWMake() const;
bool IsNMake() const;
bool IsNinjaMulti() const;
bool IsWindowsVSIDE() const;
void IssueMessage(MessageType t, std::string const& text) const;

View File

@@ -609,7 +609,10 @@ class cmMakefile;
4, 2, 0, WARN) \
SELECT(POLICY, CMP0203, \
"_WINDLL is defined for shared libraries targeting the MSVC ABI.", \
4, 2, 0, WARN)
4, 2, 0, WARN) \
SELECT(POLICY, CMP0204, \
"A character set is always defined when targeting the MSVC ABI.", 4, \
2, 0, WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
@@ -661,7 +664,8 @@ class cmMakefile;
F(CMP0199) \
F(CMP0200) \
F(CMP0202) \
F(CMP0203)
F(CMP0203) \
F(CMP0204)
#define CM_FOR_EACH_CUSTOM_COMMAND_POLICY(F) \
F(CMP0116) \

View File

@@ -134,21 +134,44 @@ bool cmVisualStudioGeneratorOptions::IsManaged() const
return this->FlagMap.find("CompileAsManaged") != this->FlagMap.end();
}
void cmVisualStudioGeneratorOptions::CacheCharsetValue() const
{
using MsvcCharSet = cmGeneratorTarget::MsvcCharSet;
if (this->CachedCharset.has_value()) {
return;
}
MsvcCharSet newValue = MsvcCharSet::None;
// Look for a any charset definition.
// Real charset will be updated if something is found.
auto it = std::find_if(this->Defines.begin(), this->Defines.end(),
[&newValue](std::string const& define) {
newValue =
cmGeneratorTarget::GetMsvcCharSet(define);
return newValue != MsvcCharSet::None;
});
if (it == this->Defines.end()) {
// Default to multi-byte, as Visual Studio does
newValue = MsvcCharSet::MultiByte;
}
this->CachedCharset = newValue;
}
bool cmVisualStudioGeneratorOptions::UsingUnicode() const
{
// Look for a _UNICODE definition.
return std::any_of(
this->Defines.begin(), this->Defines.end(), [](std::string const& di) {
return di == "_UNICODE"_s || cmHasLiteralPrefix(di, "_UNICODE=");
});
this->CacheCharsetValue();
return this->CachedCharset.value() ==
cmGeneratorTarget::MsvcCharSet::Unicode;
}
bool cmVisualStudioGeneratorOptions::UsingSBCS() const
{
// Look for a _SBCS definition.
return std::any_of(
this->Defines.begin(), this->Defines.end(), [](std::string const& di) {
return di == "_SBCS"_s || cmHasLiteralPrefix(di, "_SBCS=");
});
this->CacheCharsetValue();
return this->CachedCharset.value() ==
cmGeneratorTarget::MsvcCharSet::SingleByte;
}
void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()

View File

@@ -9,6 +9,7 @@
#include <cm/optional>
#include "cmGeneratorTarget.h"
#include "cmGlobalVisualStudioGenerator.h"
#include "cmIDEFlagTable.h"
#include "cmIDEOptions.h"
@@ -97,7 +98,11 @@ private:
std::string UnknownFlagField;
mutable cm::optional<cmGeneratorTarget::MsvcCharSet> CachedCharset;
void StoreUnknownFlag(std::string const& flag) override;
FlagValue TakeFlag(std::string const& key);
void CacheCharsetValue() const;
};

View File

@@ -1446,3 +1446,12 @@ if (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
)
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
-DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
-DCMAKE_C_SIMULATE_ID=${CMAKE_C_SIMULATE_ID}
-DCMake_TEST_CUDA=${CMake_TEST_CUDA}
)
set_property(TEST RunCMake.MsvcCharsetDefines APPEND PROPERTY LABELS "CUDA")
endif()

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -31,6 +32,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/lib.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -49,6 +51,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -76,6 +79,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -100,6 +104,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -118,6 +123,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -156,6 +162,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -178,6 +185,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/lib.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -196,6 +204,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -223,6 +232,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -247,6 +257,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -265,6 +276,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -31,6 +32,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/lib.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -49,6 +51,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -76,6 +79,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -100,6 +104,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -118,6 +123,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -31,6 +32,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/lib.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -49,6 +51,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -76,6 +79,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -100,6 +104,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -118,6 +123,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -31,6 +32,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/lib.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -49,6 +51,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -76,6 +79,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -100,6 +104,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -118,6 +123,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -31,6 +32,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/lib.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -49,6 +51,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -76,6 +79,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -100,6 +104,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -118,6 +123,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -156,6 +162,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -178,6 +185,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/lib.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -196,6 +204,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -223,6 +232,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -247,6 +257,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -265,6 +276,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -31,6 +32,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/lib.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -49,6 +51,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -76,6 +79,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -100,6 +104,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -118,6 +123,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -24,6 +25,7 @@
"PATH:<SOURCE_DIR>/examples/import-modules/use.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -35,6 +37,7 @@
"-Dtarget_public_option"
],
"local-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -62,6 +65,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -77,6 +81,7 @@
"PATH:<SOURCE_DIR>/examples/import-modules/use.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -88,6 +93,7 @@
"-Dtarget_public_option"
],
"local-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -115,6 +121,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -140,6 +147,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -160,6 +168,7 @@
"-Dtarget_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -198,6 +207,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -223,6 +233,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -243,6 +254,7 @@
"-Dtarget_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -24,6 +25,7 @@
"PATH:<SOURCE_DIR>/examples/import-modules/use.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -35,6 +37,7 @@
"-Dtarget_public_option"
],
"local-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -62,6 +65,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -87,6 +91,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -107,6 +112,7 @@
"-Dtarget_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -24,6 +25,7 @@
"PATH:<SOURCE_DIR>/examples/import-modules/use.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -35,6 +37,7 @@
"-Dtarget_public_option"
],
"local-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -62,6 +65,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -87,6 +91,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -107,6 +112,7 @@
"-Dtarget_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -24,6 +25,7 @@
"PATH:<SOURCE_DIR>/examples/import-modules/use.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -35,6 +37,7 @@
"-Dtarget_public_option"
],
"local-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -62,6 +65,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -87,6 +91,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -107,6 +112,7 @@
"-Dtarget_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -24,6 +25,7 @@
"PATH:<SOURCE_DIR>/examples/import-modules/use.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -35,6 +37,7 @@
"-Dtarget_public_option"
],
"local-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -62,6 +65,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -77,6 +81,7 @@
"PATH:<SOURCE_DIR>/examples/import-modules/use.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -88,6 +93,7 @@
"-Dtarget_public_option"
],
"local-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -115,6 +121,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -140,6 +147,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -160,6 +168,7 @@
"-Dtarget_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -198,6 +207,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -223,6 +233,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -243,6 +254,7 @@
"-Dtarget_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -24,6 +25,7 @@
"PATH:<SOURCE_DIR>/examples/import-modules/use.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -35,6 +37,7 @@
"-Dtarget_public_option"
],
"local-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -62,6 +65,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -87,6 +91,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",
@@ -107,6 +112,7 @@
"-Dtarget_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_interface_define",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -24,6 +25,7 @@
"PATH:<SOURCE_DIR>/examples/import-modules/use.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",
@@ -35,6 +37,7 @@
"-Dtarget_public_option"
],
"local-arguments": [
"-D_MBCS",
"-Dtarget_interface_define",
"-Dtarget_public_define",
"PATH:-I<SOURCE_DIR>/examples/export-build-database/target_interface_include",

View File

@@ -9,6 +9,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -31,6 +32,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/lib.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -49,6 +51,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -76,6 +79,7 @@
{
"arguments": [
"<IGNORE>",
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -100,6 +104,7 @@
"PATH:<SOURCE_DIR>/examples/export-build-database/importable.cxx"
],
"baseline-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",
@@ -118,6 +123,7 @@
"-Ddep_interface_option"
],
"local-arguments": [
"-D_MBCS",
"-Ddep_interface_define",
"-Dfrom_compile_definitions",
"-Dtarget_private_define",

View File

@@ -1,5 +1,10 @@
set(CMAKE_EXPERIMENTAL_EXPORT_BUILD_DATABASE "73194a1d-c0b5-41b9-9190-a4512925e192")
# _MBCS default append for MSVC ABI workaround: see CMP0204
# So, force add the default value for all platforms to be consistent.
cmake_policy(SET CMP0204 NEW)
add_compile_definitions(_MBCS)
get_property(is_multiconfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (is_multiconfig)
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release")

View File

@@ -5,6 +5,11 @@ include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
include("${CMAKE_SOURCE_DIR}/../export-build-database-setup.cmake")
# _MBCS default append for MSVC ABI workaround: see CMP0204
# So, force add the default value for all platforms to be consistent.
cmake_policy(SET CMP0204 NEW)
add_compile_definitions(_MBCS)
add_compile_options(-Dfrom_compile_options)
add_compile_definitions(-Dfrom_compile_definitions)
include_directories(from_include_directories)

View File

@@ -956,7 +956,10 @@ def gen_check_build_system_targets(c, g, inSource):
continue
# _WINDLL is expected for compilers targeting the MSVC ABI, but not for others.
group["defines"] = [d for d in group["defines"] if d and d["define"] != "_WINDLL"]
# And _MBCS too
group["defines"] = [d for d in group["defines"] if d and d["define"] != "_WINDLL" and d["define"] != "_MBCS"]
if len(group["defines"]) == 0:
group["defines"] = None
if os.path.exists(os.path.join(reply_dir, "..", "..", "..", "..", "cxx", "cxx_std_11.txt")):
for e in expected:

View File

@@ -36,7 +36,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 13,
"line": 16,
"command": "install",
"hasParent": true
},
@@ -70,7 +70,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 13,
"line": 16,
"command": "install",
"hasParent": true
},
@@ -102,7 +102,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 13,
"line": 16,
"command": "install",
"hasParent": true
},
@@ -136,7 +136,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 13,
"line": 16,
"command": "install",
"hasParent": true
},

View File

@@ -54,7 +54,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 50,
"line": 51,
"command": "install",
"hasParent": true
},
@@ -99,7 +99,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 53,
"line": 54,
"command": "install",
"hasParent": true
},
@@ -147,7 +147,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 53,
"line": 54,
"command": "install",
"hasParent": true
},
@@ -192,7 +192,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 53,
"line": 54,
"command": "install",
"hasParent": true
},
@@ -236,7 +236,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 53,
"line": 54,
"command": "install",
"hasParent": true
},
@@ -280,7 +280,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 58,
"line": 59,
"command": "install",
"hasParent": true
},
@@ -327,7 +327,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 60,
"line": 61,
"command": "install",
"hasParent": true
},
@@ -372,7 +372,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 61,
"line": 62,
"command": "install",
"hasParent": true
},
@@ -421,7 +421,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 62,
"line": 63,
"command": "install",
"hasParent": true
},
@@ -473,7 +473,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 63,
"line": 64,
"command": "install",
"hasParent": true
},
@@ -522,7 +522,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 64,
"line": 65,
"command": "install",
"hasParent": true
},
@@ -564,7 +564,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 65,
"line": 66,
"command": "install",
"hasParent": true
},
@@ -606,7 +606,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 66,
"line": 67,
"command": "install",
"hasParent": true
},

View File

@@ -48,7 +48,12 @@
"^empty\\.c$"
],
"includes": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"frameworks": null,
"compileCommandFragments": null
}

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 12,
"line": 13,
"command": "add_executable",
"hasParent": true
},
@@ -60,7 +60,12 @@
"^empty\\.c$"
],
"includes": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"frameworks": null,
"compileCommandFragments": null
}
@@ -68,7 +73,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 12,
"line": 13,
"command": "add_executable",
"hasParent": true
},
@@ -118,7 +123,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 13,
"line": 14,
"command": "target_link_libraries",
"hasParent": true
},

View File

@@ -14,25 +14,33 @@
"name": "HEADERS",
"type": "HEADERS",
"visibility": "PUBLIC",
"baseDirectories": ["^fileset$"]
"baseDirectories": [
"^fileset$"
]
},
{
"name": "a",
"type": "HEADERS",
"visibility": "PRIVATE",
"baseDirectories": ["^fileset$"]
"baseDirectories": [
"^fileset$"
]
},
{
"name": "b",
"type": "HEADERS",
"visibility": "PUBLIC",
"baseDirectories": ["^fileset/dir$"]
"baseDirectories": [
"^fileset/dir$"
]
},
{
"name": "c",
"type": "HEADERS",
"visibility": "INTERFACE",
"baseDirectories": ["^fileset$"]
"baseDirectories": [
"^fileset$"
]
}
],
"sources": [
@@ -204,7 +212,12 @@
}
],
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -14,7 +14,9 @@
"name": "HEADERS",
"type": "HEADERS",
"visibility": "INTERFACE",
"baseDirectories": ["^fileset$"]
"baseDirectories": [
"^fileset$"
]
}
],
"sources": [
@@ -56,7 +58,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 11,
"line": 12,
"command": "add_library",
"hasParent": true
},
@@ -61,14 +61,19 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 11,
"line": 12,
"command": "add_library",
"hasParent": true
},

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 6,
"line": 9,
"command": "add_executable",
"hasParent": true
},
@@ -41,7 +41,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 7,
"line": 10,
"command": "target_link_libraries",
"hasParent": true
},
@@ -76,14 +76,19 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 6,
"line": 9,
"command": "add_executable",
"hasParent": true
},
@@ -116,7 +121,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 13,
"line": 16,
"command": "install",
"hasParent": true
},
@@ -142,7 +147,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 7,
"line": 10,
"command": "target_link_libraries",
"hasParent": true
},

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 5,
"line": 8,
"command": "add_library",
"hasParent": true
},
@@ -49,14 +49,19 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 5,
"line": 8,
"command": "add_library",
"hasParent": true
},

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 17,
"line": 18,
"command": "add_executable",
"hasParent": true
},
@@ -61,14 +61,19 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"compileCommandFragments": null
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 17,
"line": 18,
"command": "add_executable",
"hasParent": true
},
@@ -118,7 +123,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 18,
"line": 19,
"command": "target_link_libraries",
"hasParent": true
},

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 16,
"line": 17,
"command": "add_library",
"hasParent": true
},
@@ -62,6 +62,10 @@
"includes": null,
"frameworks": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
},
{
"define": "_WINDLL",
"backtrace": null
@@ -77,7 +81,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 16,
"line": 17,
"command": "add_library",
"hasParent": true
},
@@ -126,7 +130,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 53,
"line": 54,
"command": "install",
"hasParent": true
},
@@ -156,7 +160,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 53,
"line": 54,
"command": "install",
"hasParent": true
},
@@ -186,7 +190,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 58,
"line": 59,
"command": "install",
"hasParent": true
},

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 21,
"line": 22,
"command": "add_executable",
"hasParent": true
},
@@ -61,14 +61,19 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 21,
"line": 22,
"command": "add_executable",
"hasParent": true
},
@@ -118,7 +123,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 22,
"line": 23,
"command": "target_link_libraries",
"hasParent": true
},

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 20,
"line": 21,
"command": "add_library",
"hasParent": true
},
@@ -61,14 +61,19 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 20,
"line": 21,
"command": "add_library",
"hasParent": true
},

View File

@@ -69,6 +69,10 @@
],
"frameworks": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
},
{
"define": "SUBDIR",
"backtrace": [
@@ -93,7 +97,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 24,
"line": 25,
"command": "add_library",
"hasParent": true
},

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"precompileHeaders": [
{
"header": ".*empty\\.h$",
@@ -143,7 +148,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 50,
"line": 51,
"command": "install",
"hasParent": true
},

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
@@ -82,10 +87,10 @@
"build": "^cxx/cross$",
"source": "^cxx/cross$",
"install": null,
"launchers" : [
"launchers": [
{
"command": "^no-such-emulator(\\.exe)?$",
"type" : "emulator"
"type": "emulator"
}
],
"link": {

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
@@ -82,14 +87,14 @@
"build": "^cxx/cross$",
"source": "^cxx/cross$",
"install": null,
"launchers" : [
"launchers": [
{
"arguments" : [
"arg1",
"arg2 with space"
"arguments": [
"arg1",
"arg2 with space"
],
"command": "^no-such-emulator(\\.exe)?$",
"type" : "emulator"
"type": "emulator"
}
],
"link": {

View File

@@ -7,7 +7,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"precompileHeaders": [
{
"header": ".*empty\\.h$",
@@ -54,7 +59,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"precompileHeaders": [
{
"header": ".*empty\\.h$",

View File

@@ -7,7 +7,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"precompileHeaders": [
{
"header": ".*empty\\.h$",
@@ -54,7 +59,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"precompileHeaders": [
{
"header": ".*empty\\.h$",
@@ -101,7 +111,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"precompileHeaders": [
{
"header": ".*empty\\.h$",

View File

@@ -7,7 +7,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"precompileHeaders": [
{
"header": ".*empty\\.h$",
@@ -54,7 +59,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"precompileHeaders": [
{
"header": ".*empty\\.h$",

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
@@ -82,10 +87,10 @@
"build": "^cxx$",
"source": "^cxx$",
"install": null,
"launchers" : [
"launchers": [
{
"command": "^no-such-launcher(\\.exe)?$",
"type" : "test"
"type": "test"
}
],
"link": {

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
@@ -82,14 +87,14 @@
"build": "^cxx/cross$",
"source": "^cxx/cross$",
"install": null,
"launchers" : [
"launchers": [
{
"command": "^no-such-launcher(\\.exe)?$",
"type" : "test"
"type": "test"
},
{
"command": "^no-such-emulator(\\.exe)?$",
"type" : "emulator"
"type": "emulator"
}
],
"link": {

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 10,
"line": 13,
"command": "add_executable",
"hasParent": true
},
@@ -41,7 +41,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 11,
"line": 14,
"command": "target_link_libraries",
"hasParent": true
},
@@ -76,14 +76,19 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 10,
"line": 13,
"command": "add_executable",
"hasParent": true
},
@@ -116,7 +121,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 13,
"line": 16,
"command": "install",
"hasParent": true
},
@@ -142,7 +147,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 11,
"line": 14,
"command": "target_link_libraries",
"hasParent": true
},

View File

@@ -20,7 +20,7 @@
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 9,
"line": 12,
"command": "add_library",
"hasParent": true
},
@@ -49,14 +49,19 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 9,
"line": 12,
"command": "add_library",
"hasParent": true
},

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -50,6 +50,10 @@
"includes": null,
"frameworks": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
},
{
"define": "_WINDLL",
"backtrace": null
@@ -102,7 +106,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 53,
"line": 54,
"command": "install",
"hasParent": true
},
@@ -132,7 +136,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 53,
"line": 54,
"command": "install",
"hasParent": true
},
@@ -162,7 +166,7 @@
"backtrace": [
{
"file": "^codemodel-v2\\.cmake$",
"line": 58,
"line": 59,
"command": "install",
"hasParent": true
},

View File

@@ -44,8 +44,7 @@
"compileGroups": [
{
"language": "CXX",
"languageStandard" :
{
"languageStandard": {
"backtraces": [
[
{
@@ -62,14 +61,19 @@
}
]
],
"standard" : "98"
"standard": "98"
},
"sourcePaths": [
"^empty\\.cxx$"
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -44,8 +44,7 @@
"compileGroups": [
{
"language": "CXX",
"languageStandard" :
{
"languageStandard": {
"backtraces": [
[
{
@@ -62,14 +61,19 @@
}
]
],
"standard" : "17"
"standard": "17"
},
"sourcePaths": [
"^empty\\.cxx$"
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -114,6 +114,10 @@
],
"frameworks": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
},
{
"define": "EMPTY_C=1",
"backtrace": [
@@ -185,7 +189,7 @@
],
"compileCommandFragments": [
{
"fragment" : "SRC_COMPILE_OPTIONS_DUMMY",
"fragment": "SRC_COMPILE_OPTIONS_DUMMY",
"backtrace": [
{
"file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
@@ -194,7 +198,7 @@
"hasParent": true
},
{
"file" : "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
"file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
"line": null,
"command": null,
"hasParent": false
@@ -230,6 +234,10 @@
],
"frameworks": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
},
{
"define": "GENERATED_EXE=1",
"backtrace": [

View File

@@ -32,7 +32,7 @@
},
{
"file": "^codemodel-v2\\.cmake$",
"line": 9,
"line": 10,
"command": "include",
"hasParent": true
},
@@ -74,6 +74,10 @@
"includes": null,
"frameworks": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
},
{
"define": "interface_exe_EXPORTS",
"backtrace": null
@@ -95,7 +99,7 @@
},
{
"file": "^codemodel-v2\\.cmake$",
"line": 9,
"line": 10,
"command": "include",
"hasParent": true
},
@@ -138,7 +142,7 @@
},
{
"file": "^codemodel-v2\\.cmake$",
"line": 9,
"line": 10,
"command": "include",
"hasParent": true
},

View File

@@ -28,7 +28,7 @@
},
{
"file": "^codemodel-v2\\.cmake$",
"line": 9,
"line": 10,
"command": "include",
"hasParent": true
},

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -50,6 +50,10 @@
"includes": null,
"frameworks": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
},
{
"define": "_WINDLL",
"backtrace": null

View File

@@ -49,7 +49,12 @@
],
"includes": null,
"frameworks": null,
"defines": null,
"defines": [
{
"define": "_MBCS",
"backtrace": null
}
],
"compileCommandFragments": null
}
],

View File

@@ -3,6 +3,7 @@ set(CMAKE_INTERMEDIATE_DIR_STRATEGY FULL CACHE STRING "" FORCE)
enable_language(C)
cmake_policy(SET CMP0203 NEW)
cmake_policy(SET CMP0204 NEW)
set(CMAKE_AIX_SHARED_LIBRARY_ARCHIVE 0)

View File

@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.13)
project(Object)
enable_language(CXX)
cmake_policy(SET CMP0203 NEW)
cmake_policy(SET CMP0204 NEW)
add_library(c_object_lib OBJECT ../empty.c)
add_executable(c_object_exe ../empty.c)
target_link_libraries(c_object_exe PRIVATE c_object_lib)

View File

@@ -0,0 +1,3 @@
set(language C)
set(extension "c")
include(common.cmake)

View File

@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 4.0)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@@ -0,0 +1,3 @@
set(language CUDA)
set(extension "cu")
include(common.cmake)

View File

@@ -0,0 +1,3 @@
set(language CXX)
set(extension "cxx")
include(common.cmake)

View File

@@ -0,0 +1,20 @@
include(RunCMake)
function(configure_and_build case)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
run_cmake(${case})
set(RunCMake_TEST_NO_CLEAN 1)
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
run_cmake_command(${case}-build-Debug ${CMAKE_COMMAND} --build . --config Debug)
run_cmake_command(${case}-build-Release ${CMAKE_COMMAND} --build . --config Release)
else()
run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .)
endif()
endfunction()
configure_and_build(C)
configure_and_build(CXX)
if(CMake_TEST_CUDA)
configure_and_build(CUDA)
endif()

View File

@@ -0,0 +1 @@
#include "checker.h"

View File

@@ -0,0 +1 @@
#include "checker.h"

View File

@@ -0,0 +1 @@
#include "checker.h"

View File

@@ -0,0 +1,45 @@
#pragma once
#ifdef MUST_HAVE_DEFINE_MBCS
# ifndef _MBCS
# error "_MBCS is not defined, but it should be"
# endif
# if _MBCS != 1
# error "_MBCS is not defined as 1, but it should be"
# 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 _SBCS != 1
# error "_SBCS is not defined as 1, but it should be"
# 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 _UNICODE != 1
# error "_UNICODE is not defined as 1, but it should be"
# endif
#else
# ifdef _UNICODE
# error "_UNICODE is defined, but it should not be"
# endif
#endif
int FUNCTION()
{
return 0;
}

View File

@@ -0,0 +1,55 @@
enable_language(${language})
function(msvcCharsetDefs_addTests policy_value suffix expected_define passed_define)
block(SCOPE_FOR POLICIES)
if (NOT "${policy_value}" STREQUAL "WARN")
# WARN is the default value - no need to set it
cmake_policy(SET CMP0204 "${policy_value}")
endif()
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()
endblock()
endfunction()
foreach(policy_value IN ITEMS OLD 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")
# Visual Studio always defines `_MBCS` by default
set(expected_define "MBCS")
elseif (policy_value STREQUAL "NEW")
set(expected_define "MBCS")
endif()
msvcCharsetDefs_addTests(${policy_value} Default "${expected_define}" "")
endforeach()

View File

@@ -51,6 +51,7 @@
\* CMP0200
\* CMP0202
\* CMP0203
\* CMP0204
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)