1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4include(CMakeInitializeConfigs)
5
6set(CMAKE_SHARED_LIBRARY_C_FLAGS "")            # -pic
7set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")       # -shared
8set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")         # +s, flag for exe link to use shared lib
9set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "")       # -rpath
10set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "")   # : or empty
11set(CMAKE_INCLUDE_FLAG_C "-I")       # -I
12set(CMAKE_LIBRARY_PATH_FLAG "-L")
13set(CMAKE_LIBRARY_PATH_TERMINATOR "")  # for the Digital Mars D compiler the link paths have to be terminated with a "/"
14set(CMAKE_LINK_LIBRARY_FLAG "-l")
15
16set(CMAKE_LINK_LIBRARY_SUFFIX "")
17set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
18set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
19set(CMAKE_SHARED_LIBRARY_PREFIX "lib")          # lib
20set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")          # .so
21set(CMAKE_EXECUTABLE_SUFFIX "")          # .exe
22set(CMAKE_DL_LIBS "dl")
23
24set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
25set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
26
27set(CMAKE_AUTOGEN_ORIGIN_DEPENDS ON)
28set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON)
29if(NOT DEFINED CMAKE_AUTOMOC_PATH_PREFIX)
30  set(CMAKE_AUTOMOC_PATH_PREFIX OFF)
31endif()
32set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE" "Q_NAMESPACE_EXPORT")
33
34# basically all general purpose OSs support shared libs
35set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
36
37set (CMAKE_SKIP_RPATH "NO" CACHE BOOL
38     "If set, runtime paths are not added when using shared libraries.")
39set (CMAKE_SKIP_INSTALL_RPATH "NO" CACHE BOOL
40     "If set, runtime paths are not added when installing shared libraries, but are added when building.")
41
42set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make.  This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.")
43
44if(CMAKE_GENERATOR MATCHES "Make")
45  set(CMAKE_COLOR_MAKEFILE ON CACHE BOOL
46    "Enable/Disable color output during build."
47    )
48  mark_as_advanced(CMAKE_COLOR_MAKEFILE)
49  if(DEFINED CMAKE_RULE_MESSAGES)
50    set_property(GLOBAL PROPERTY RULE_MESSAGES ${CMAKE_RULE_MESSAGES})
51  endif()
52  if(DEFINED CMAKE_TARGET_MESSAGES)
53    set_property(GLOBAL PROPERTY TARGET_MESSAGES ${CMAKE_TARGET_MESSAGES})
54  endif()
55endif()
56
57if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS AND CMAKE_GENERATOR MATCHES "Ninja|Unix Makefiles")
58  set(CMAKE_EXPORT_COMPILE_COMMANDS "$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}"
59    CACHE BOOL "Enable/Disable output of compile commands during generation."
60    )
61  mark_as_advanced(CMAKE_EXPORT_COMPILE_COMMANDS)
62endif()
63
64# GetDefaultWindowsPrefixBase
65#
66# Compute the base directory for CMAKE_INSTALL_PREFIX based on:
67#  - is this 32-bit or 64-bit Windows
68#  - is this 32-bit or 64-bit CMake running
69#  - what architecture targets will be built
70#
71function(GetDefaultWindowsPrefixBase var)
72
73  # Try to guess what architecture targets will end up being built as,
74  # even if CMAKE_SIZEOF_VOID_P is not computed yet... We need to know
75  # the architecture of the targets being built to choose the right
76  # default value for CMAKE_INSTALL_PREFIX.
77  #
78  if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
79    set(arch_hint "x64")
80  elseif("${CMAKE_GENERATOR_PLATFORM}" MATCHES "x64")
81    set(arch_hint "x64")
82  elseif("${CMAKE_GENERATOR_PLATFORM}" MATCHES "ARM64")
83    set(arch_hint "ARM64")
84  elseif("${CMAKE_GENERATOR}" MATCHES "ARM")
85    set(arch_hint "ARM")
86  elseif("${CMAKE_GENERATOR_PLATFORM}" MATCHES "ARM")
87    set(arch_hint "ARM")
88  elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
89    set(arch_hint "x64")
90  elseif("$ENV{LIB}" MATCHES "(amd64|ia64)")
91    set(arch_hint "x64")
92  endif()
93
94  if(NOT arch_hint)
95    set(arch_hint "x86")
96  endif()
97
98  # default env in a 64-bit app on Win64:
99  # ProgramFiles=C:\Program Files
100  # ProgramFiles(x86)=C:\Program Files (x86)
101  # ProgramW6432=C:\Program Files
102  #
103  # default env in a 32-bit app on Win64:
104  # ProgramFiles=C:\Program Files (x86)
105  # ProgramFiles(x86)=C:\Program Files (x86)
106  # ProgramW6432=C:\Program Files
107  #
108  # default env in a 32-bit app on Win32:
109  # ProgramFiles=C:\Program Files
110  # ProgramFiles(x86) NOT DEFINED
111  # ProgramW6432 NOT DEFINED
112
113  # By default, use the ProgramFiles env var as the base value of
114  # CMAKE_INSTALL_PREFIX:
115  #
116  set(_PREFIX_ENV_VAR "ProgramFiles")
117
118  if ("$ENV{ProgramW6432}" STREQUAL "")
119    # running on 32-bit Windows
120    # must be a 32-bit CMake, too...
121    #message("guess: this is a 32-bit CMake running on 32-bit Windows")
122  else()
123    # running on 64-bit Windows
124    if ("$ENV{ProgramW6432}" STREQUAL "$ENV{ProgramFiles}")
125      # 64-bit CMake
126      #message("guess: this is a 64-bit CMake running on 64-bit Windows")
127      if(NOT "${arch_hint}" STREQUAL "x64")
128      # building 32-bit targets
129        set(_PREFIX_ENV_VAR "ProgramFiles(x86)")
130      endif()
131    else()
132      # 32-bit CMake
133      #message("guess: this is a 32-bit CMake running on 64-bit Windows")
134      if("${arch_hint}" STREQUAL "x64")
135      # building 64-bit targets
136        set(_PREFIX_ENV_VAR "ProgramW6432")
137      endif()
138    endif()
139  endif()
140
141  #if("${arch_hint}" STREQUAL "x64")
142  #  message("guess: you are building a 64-bit app")
143  #else()
144  #  message("guess: you are building a 32-bit app")
145  #endif()
146
147  if(NOT "$ENV{${_PREFIX_ENV_VAR}}" STREQUAL "")
148    file(TO_CMAKE_PATH "$ENV{${_PREFIX_ENV_VAR}}" _base)
149  elseif(NOT "$ENV{SystemDrive}" STREQUAL "")
150    set(_base "$ENV{SystemDrive}/Program Files")
151  else()
152    set(_base "C:/Program Files")
153  endif()
154
155  set(${var} "${_base}" PARENT_SCOPE)
156endfunction()
157
158
159# Set a variable to indicate whether the value of CMAKE_INSTALL_PREFIX
160# was initialized by the block below.  This is useful for user
161# projects to change the default prefix while still allowing the
162# command line to override it.
163if(NOT DEFINED CMAKE_INSTALL_PREFIX)
164  set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 1)
165endif()
166
167# Choose a default install prefix for this platform.
168if(CMAKE_HOST_UNIX)
169  set(CMAKE_INSTALL_PREFIX "/usr/local"
170    CACHE PATH "Install path prefix, prepended onto install directories.")
171else()
172  GetDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
173  set(CMAKE_INSTALL_PREFIX
174    "${CMAKE_GENERIC_PROGRAM_FILES}/${PROJECT_NAME}"
175    CACHE PATH "Install path prefix, prepended onto install directories.")
176  set(CMAKE_GENERIC_PROGRAM_FILES)
177endif()
178
179# Set a variable which will be used as component name in install() commands
180# where no COMPONENT has been given:
181set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "Unspecified")
182
183mark_as_advanced(
184  CMAKE_SKIP_RPATH
185  CMAKE_SKIP_INSTALL_RPATH
186  CMAKE_VERBOSE_MAKEFILE
187)
188