CYGWIN-GNU.cmake 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #=============================================================================
  2. # Copyright 2002-2009 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distributed this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. # This module is shared by multiple languages; use include blocker.
  14. if(__CYGWIN_COMPILER_GNU)
  15. return()
  16. endif()
  17. set(__CYGWIN_COMPILER_GNU 1)
  18. # TODO: Is -Wl,--enable-auto-import now always default?
  19. set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--enable-auto-import")
  20. set(CMAKE_CREATE_WIN32_EXE "-mwindows")
  21. set(CMAKE_GNULD_IMAGE_VERSION
  22. "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
  23. macro(__cygwin_compiler_gnu lang)
  24. # Binary link rules.
  25. set(CMAKE_${lang}_CREATE_SHARED_MODULE
  26. "<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>")
  27. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  28. "<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>")
  29. set(CMAKE_${lang}_LINK_EXECUTABLE
  30. "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
  31. set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on cygwin
  32. # Initialize C link type selection flags. These flags are used when
  33. # building a shared library, shared module, or executable that links
  34. # to other libraries to select whether to use the static or shared
  35. # versions of the libraries.
  36. FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE)
  37. SET(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic")
  38. SET(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic")
  39. ENDFOREACH(type)
  40. set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-all-symbols")
  41. # TODO: Is -Wl,--enable-auto-import now always default?
  42. set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS} -Wl,--enable-auto-import")
  43. set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS}")
  44. endmacro()