Closed neagix closed 9 years ago
Well, I don't know a whole lot about CMake to be honest. This offers a speed improvement for compiling?
no, it makes compiled binaries represent in memory their strings as unicode instead of multi-byte. see also http://stackoverflow.com/questions/3064052/c-project-type-unicode-vs-multi-byte-pros-and-cons
Interesting stuff. Sounds like it definitely makes sense to do this. I'll see if I can get this added to SFML's CMake file too.
@Jebbs precisely! thanks. I also compiled SFML with that
Finally remembered to mention this to the SFML guys. Apparently they already do this, just in a different part of their CMake files.
@Jebbs so it was not needed? or was it added recently?
edit: is it only in Window class but not in all the others?
Looks like it was added about 8 months ago, so it isn't even a part of the 2.1 source. I'll open this back up and will make sure it get's added to DSFML at least until I get everything updated to SFML's HEAD.
And it only add's the definition to the Window submodule because that is where all the WIN32 api calls that deal with strings take place I'm guessing. The graphics module is just built on top of it.
@Jebbs do not agree, it should be defined at topmost level (for all submodules) because it affects all API calls
This is the issue I opened: https://github.com/LaurentGomila/SFML/issues/657
They would be able to answer your questions about this better than I could, so I would ask the SFML team directly.
Sorry for digging up this old thread but it appears to be well-indexed by Google when you search "CMake unicode character set". I just want CMake to generate Visual Studio Solution with this value set to "Use Unicode Character Set
":
It is a shame that in 2023 CMake still generates Visual Studio Solutions with Character Set set to "Use Multi-Byte Character Set
" and the only option to override this is adding preprocessor definitions in CMake.
Anyway, in "mordern" CMake the use of add_definitions
is discouraged. So now it would be:
if (MSVC)
target_compile_definitions(my_target PUBLIC UNICODE _UNICODE)
endif()
A small improvement: by default CMake will build VC++ projects that build with the default multi-byte characterset instead of Unicode. Since Windows XP all multi-byte strings are converted internally to Unicode before usage in Windows APIs, thus going native is good both for compatiblity (long live UTF-8!) and performance reasons.
NOTE: I tested this only with Visual Studio 2010, targeting 64bit: