Skip to content
  • Brad King's avatar
    Cygwin: Do not define 'WIN32' (#10122) · 85c0a69a
    Brad King authored
    One of Cygwin's goals is to build projects using the POSIX API with no
    Windows awareness.  Many CMake-built projects have been written to test
    for UNIX and WIN32 but not CYGWIN.  The preferred behavior under Cygwin
    in such projects is to take the UNIX path but not the WIN32 path.
    
    Unfortunately this change is BACKWARDS INCOMPATIBLE for Cygwin-aware
    CMake projects!  Some projects that previously built under Cygwin and
    are Cygwin-aware when they test for WIN32 may now behave differently.
    Eventually these projects will need to be updated, but to help users
    build them in the meantime we print a warning about the change in
    behavior.  Furthermore, one may set CMAKE_LEGACY_CYGWIN_WIN32 to request
    old behavior during the transition.
    
    Normally we avoid backwards incompatible changes, but we make an
    exception in this case for a few reasons:
    
    (1) This behavior is preferred by Cygwin's design goals.
    
    (2) A warning provides a clear path forward for everyone who may see
    incompatible behavior, and CMAKE_LEGACY_CYGWIN_WIN32 provides a
    compatibility option.  The warning and compatibility option both
    disappear when the minimum required version of CMake in a project is
    sufficiently new, so this issue will simply go away over time as
    projects are updated to account for the change.
    
    (3) The fixes required to update projects are fairly insignificant.
    Furthermore, the Cygwin distribution has no releases itself so project
    versions that predate said fixes tend to be difficult to build anyway.
    
    (4) This change enables many CMake-built projects that did not
    previously build under Cygwin to work out-of-the-box.  From bug #10122:
    
      "I have built over 120 different source packages with (my patched)
       CMake, including most of KDE4, and have found that NOT defining
       WIN32 on Cygwin is much more accurate." -- Yaakov Selkowitz
    
    A fully compatible change would require patches on top of these project
    releases for Cygwin even though they otherwise need not be aware of it.
    
    (5) Yaakov has been maintaining a fork of CMake with this change for the
    Cygwin Ports distribution.  It works well in practice.  By accepting the
    change in upstream CMake we avoid confusion between the versions.
    
    CMake itself builds without WIN32 defined on Cygwin.  Simply disable
    CMAKE_LEGACY_CYGWIN_WIN32 explicitly in our own CMakeLists.txt file.
    85c0a69a