CYGWIN-GNU.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # This module is shared by multiple languages; use include blocker.
  4. if(__CYGWIN_COMPILER_GNU)
  5. return()
  6. endif()
  7. set(__CYGWIN_COMPILER_GNU 1)
  8. # TODO: Is -Wl,--enable-auto-import now always default?
  9. string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,--enable-auto-import")
  10. set(CMAKE_CREATE_WIN32_EXE "-mwindows")
  11. set(CMAKE_GNULD_IMAGE_VERSION
  12. "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
  13. set(CMAKE_GENERATOR_RC windres)
  14. macro(__cygwin_compiler_gnu lang)
  15. # Binary link rules.
  16. set(CMAKE_${lang}_CREATE_SHARED_MODULE
  17. "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
  18. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  19. "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
  20. set(CMAKE_${lang}_LINK_EXECUTABLE
  21. "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
  22. # No -fPIC on cygwin
  23. set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
  24. set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
  25. set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
  26. set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
  27. set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
  28. set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
  29. # Initialize C link type selection flags. These flags are used when
  30. # building a shared library, shared module, or executable that links
  31. # to other libraries to select whether to use the static or shared
  32. # versions of the libraries.
  33. foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
  34. set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic")
  35. set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic")
  36. endforeach()
  37. set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-all-symbols")
  38. # TODO: Is -Wl,--enable-auto-import now always default?
  39. string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,--enable-auto-import")
  40. set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS}")
  41. if(NOT CMAKE_RC_COMPILER_INIT)
  42. set(CMAKE_RC_COMPILER_INIT windres)
  43. endif()
  44. enable_language(RC)
  45. endmacro()