toolchain-winegcc.cmake 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Toolchain file for cross-building a Winelib version of Windows PuTTY
  2. # on Linux, using winegcc (tested on Ubuntu).
  3. # Winelib is weird because it's basically compiling ordinary Linux
  4. # objects and executables, but we want to pretend to be Windows for
  5. # purposes of (a) having resource files, and (b) selecting the Windows
  6. # platform subdirectory.
  7. #
  8. # So, do we tag this as a weird kind of Windows build, or a weird kind
  9. # of Linux build? Either way we have to do _something_ out of the
  10. # ordinary.
  11. #
  12. # After some experimentation, it seems to make more sense to treat
  13. # Winelib builds as basically Linux, and set a flag WINELIB that
  14. # PuTTY's main build scripts will detect and handle specially.
  15. # Specifically, that flag will cause cmake/setup.cmake to select the
  16. # Windows platform (overriding the usual check of CMAKE_SYSTEM_NAME),
  17. # and also trigger a call to enable_language(RC), which for some kind
  18. # of cmake re-entrancy reason we can't do in this toolchain file
  19. # itself.
  20. set(CMAKE_SYSTEM_NAME Linux)
  21. set(WINELIB ON)
  22. # We need a wrapper script around winegcc proper, because cmake's link
  23. # command lines will refer to system libraries as "-lkernel32.lib"
  24. # rather than the required "-lkernel32". The winegcc script alongside
  25. # this toolchain file bodges that command-line translation.
  26. set(CMAKE_C_COMPILER ${CMAKE_SOURCE_DIR}/cmake/winegcc)
  27. set(CMAKE_RC_COMPILER wrc)
  28. set(CMAKE_RC_OUTPUT_EXTENSION .res.o)
  29. set(CMAKE_RC_COMPILE_OBJECT
  30. "<CMAKE_RC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")