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