1
0

Windows-GNU.cmake 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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(__WINDOWS_GNU)
  15. return()
  16. endif()
  17. set(__WINDOWS_GNU 1)
  18. set(CMAKE_IMPORT_LIBRARY_PREFIX "lib")
  19. set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
  20. set(CMAKE_SHARED_MODULE_PREFIX "lib")
  21. set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
  22. set(CMAKE_EXECUTABLE_SUFFIX ".exe")
  23. set(CMAKE_IMPORT_LIBRARY_SUFFIX ".dll.a")
  24. set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
  25. set(CMAKE_SHARED_MODULE_SUFFIX ".dll")
  26. set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
  27. if(MSYS OR MINGW)
  28. set(CMAKE_EXTRA_LINK_EXTENSIONS ".lib") # MinGW can also link to a MS .lib
  29. endif()
  30. if(MINGW)
  31. set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
  32. set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib")
  33. set(CMAKE_C_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32")
  34. set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
  35. endif()
  36. set(CMAKE_DL_LIBS "")
  37. set(CMAKE_LIBRARY_PATH_FLAG "-L")
  38. set(CMAKE_LINK_LIBRARY_FLAG "-l")
  39. set(CMAKE_LINK_LIBRARY_SUFFIX "")
  40. set(CMAKE_CREATE_WIN32_EXE "-mwindows")
  41. set(CMAKE_GNULD_IMAGE_VERSION
  42. "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
  43. macro(__windows_compiler_gnu lang)
  44. if(MSYS OR MINGW)
  45. # Create archiving rules to support large object file lists for static libraries.
  46. set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
  47. set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
  48. set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
  49. # Initialize C link type selection flags. These flags are used when
  50. # building a shared library, shared module, or executable that links
  51. # to other libraries to select whether to use the static or shared
  52. # versions of the libraries.
  53. foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
  54. set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic")
  55. set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic")
  56. endforeach(type)
  57. endif()
  58. set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on Windows
  59. set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
  60. set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-Wl,@")
  61. # Binary link rules.
  62. set(CMAKE_${lang}_CREATE_SHARED_MODULE
  63. "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_MODULE_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
  64. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  65. "<CMAKE_${lang}_COMPILER> <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>")
  66. set(CMAKE_${lang}_LINK_EXECUTABLE
  67. "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
  68. endmacro()