[CMake] Building on Windows, with NMake, without Unicode Support

Stewart, Robert Robert.Stewart at sig.com
Fri Aug 30 14:57:40 EDT 2013


I can't figure out how to get CMake to build my code with setting -D_UNICODE and -DUNICODE.  I don't want those manifest constants set, but they appear in the generated DependInfo.cmake files when generating code for NMake Makefiles:

SET(CMAKE_CXX_COMPILER_ID "MSVC")

# Preprocessor definitions for this target.
SET(CMAKE_TARGET_DEFINITIONS
  "NT"
  "_UNICODE"
  "UNICODE"
  "_CRT_SECURE_NO_WARNINGS"
  "_SCL_SECURE_NO_WARNINGS"
  "NOMINMAX"
  "NT"
  "WIN32_LEAN_AND_MEAN"
  )

The definitions following those for Unicode are from this command in my CMakeLists.txt:

add_definitions(
   /D_CRT_SECURE_NO_WARNINGS
   /D_SCL_SECURE_NO_WARNINGS
   /DNOMINMAX
   /DNT
   /DWIN32_LEAN_AND_MEAN)

I've tried every which way I can think of to remove those definitions, but nothing has worked:

 - get_target_property() finds nothing for COMPILE_DEFINITIONS or DEFINITIONS.

 - add_definitions(/U_UNICODE /UUNICODE) doesn't work because those precede the -D_UNICODE -DUNICODE arguments generated by the above. (CMake "helpfully" sorts the flags, it seems.  That's a bug, if you ask me.  Order dependent flags, at least, should appear in the order the user gives them.)

 - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /U_UNICODE /UUNICODE") doesn't work.  (I could probably force an update to the cache, but then that would apply globally and not to the current project.

How can I convince CMake to remove those definitions from my builds?


_____
Rob Stewart
Software Engineer
Dev Tools & Components
Susquehanna International Group, LLP



________________________________

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


More information about the CMake mailing list