aboutsummaryrefslogtreecommitdiff
path: root/cmake/scripts/common/GeneratorSetup.cmake
blob: 304b5042e7b8b4ee22803f359a86d8264c464349 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Configure single-/multiconfiguration generators and variables
#
# CORE_BUILD_CONFIG that is set to
#   - CMAKE_BUILD_TYPE for single configuration generators such as make, nmake
#   - a variable that expands on build time to the current configuration for
#     multi configuration generators such as VS or Xcode
if(CMAKE_CONFIGURATION_TYPES)
  if(CMAKE_BUILD_TYPE)
    message(FATAL_ERROR "CMAKE_BUILD_TYPE must not be defined for multi-configuration generators")
  endif()
  set(CORE_BUILD_CONFIG ${CMAKE_CFG_INTDIR})
  message(STATUS "Generator: Multi-configuration (${CMAKE_GENERATOR})")
else()
  if(CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
        CACHE STRING "Choose build type (${CMAKE_BUILD_TYPES})" FORCE)
  else()
    # Set default
    set(CMAKE_BUILD_TYPE Release
        CACHE STRING "Choose build type (${CMAKE_BUILD_TYPES})" FORCE)
  endif()
  set(CORE_BUILD_CONFIG ${CMAKE_BUILD_TYPE})
  message(STATUS "Generator: Single-configuration: ${CMAKE_BUILD_TYPE} (${CMAKE_GENERATOR})")
endif()

# Print CMake version
message(STATUS "CMake Version: ${CMAKE_VERSION}")

# Deal with CMake special cases
if(CMAKE_VERSION VERSION_EQUAL 3.5.1)
  message(WARNING "CMake 3.5.1 introduced a crash during configuration. "
                  "Please consider upgrading to 3.5.2 (cmake.org/Bug/view.php?id=16044)")
endif()

# Darwin needs CMake 3.4
if(APPLE AND CMAKE_VERSION VERSION_LESS 3.4)
  message(WARNING "Build on Darwin requires CMake 3.4 or later (tdb library support) "
                  "or the usage of the patched version in depends.")
endif()

# Windows needs CMake 3.6 (VS_STARTUP_PROJECT)
if(WIN32 AND CMAKE_VERSION VERSION_LESS 3.6)
  message(FATAL_ERROR "Build on Windows needs CMake 3.6 or later")
endif()

# Ninja needs CMake 3.2 due to ExternalProject BUILD_BYPRODUCTS usage
if(CMAKE_GENERATOR STREQUAL Ninja AND CMAKE_VERSION VERSION_LESS 3.2)
  message(FATAL_ERROR "Generator: Ninja requires CMake 3.2 or later")
endif()