# Generate for VS2022 sets Character Set to "Use Multi-Byte Character Set"

**URL:** <https://discourse.cmake.org/t/generate-for-vs2022-sets-character-set-to-use-multi-byte-character-set/12870>\
**Category:** Code\
**Created:** [October 31, 2024, 1:52am UTC](https://discourse.cmake.org/t/generate-for-vs2022-sets-character-set-to-use-multi-byte-character-set/12870 "2024-10-31T01:52:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![perdrix](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/a8b319/32.png) [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Post date:** [October 31, 2024, 1:52am UTC](https://discourse.cmake.org/t/generate-for-vs2022-sets-character-set-to-use-multi-byte-character-set/12870/1 "2024-10-31T01:52:55Z")

</div>

Which I don’t want - I want it to be set to “Not Set” as I don’t want the \_MBCS define to be generated by Visual Studio.

How can I stop this please?

---

<div class="post-metadata">

**Author:** ![retif](https://discourse.cmake.org/user_avatar/discourse.cmake.org/retif/32/1776_2.png) [@retif](https://discourse.cmake.org/u/retif)\
**Post date:** [October 31, 2024, 9:11am UTC](https://discourse.cmake.org/t/generate-for-vs2022-sets-character-set-to-use-multi-byte-character-set/12870/2 "2024-10-31T09:11:40Z")

</div>

The very first result from Google says to do so:

```cmake
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # or just if(MSVC)
    target_compile_definitions(${PROJECT_NAME} # or your particular target name, if it's different
        PRIVATE
            "_UNICODE"
            "UNICODE"
    )
endif()

```

Have you tried that? Although if you want it to be set exactly to `Not Set`, that is probably not much better then.

---

<div class="post-metadata">

**Author:** ![perdrix](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/a8b319/32.png) [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Post date:** [October 31, 2024, 10:50am UTC](https://discourse.cmake.org/t/generate-for-vs2022-sets-character-set-to-use-multi-byte-character-set/12870/3 "2024-10-31T10:50:06Z")

</div>

No, I don’t want it set to a Unicode build.

PS What was your exact Google search please?

Thanks  
David

---

<div class="post-metadata">

**Author:** ![perdrix](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/a8b319/32.png) [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Post date:** [October 31, 2024, 1:33pm UTC](https://discourse.cmake.org/t/generate-for-vs2022-sets-character-set-to-use-multi-byte-character-set/12870/4 "2024-10-31T13:33:57Z")

</div>

I’ve been informed that:

CharacterSet is set as follows:

If the project adds a \_UNICODE preprocessor definition, the CharacterSet is Unicode. If the project adds a \_SBCS preprocessor definition, the CharacterSet is NotSet. Otherwise, the CharacterSet is MultiByte.

so

target\_compile\_definitions(example PRIVATE \_SBCS)

should do the job.

D.

---

<div class="post-metadata">

**Author:** ![retif](https://discourse.cmake.org/user_avatar/discourse.cmake.org/retif/32/1776_2.png) [@retif](https://discourse.cmake.org/u/retif)\
**Post date:** [October 31, 2024, 1:39pm UTC](https://discourse.cmake.org/t/generate-for-vs2022-sets-character-set-to-use-multi-byte-character-set/12870/5 "2024-10-31T13:39:27Z")

</div>

> What was your exact Google search please?

It was `cmake "Use Multi-Byte Character Set"`, and that landed me [here](https://github.com/Jebbs/DSFML-C/issues/8#issuecomment-1582737999).

> If the project adds a \_SBCS preprocessor definition, the CharacterSet is NotSet

Thanks for coming back and posting it here, I’m sure that will be useful for others. I, for one, did not know about `_SBCS` definition.

You can probably even mark that comment as a solution for your topic.
