File: ChooseMSVCCRT.cmake

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (58 lines) | stat: -rw-r--r-- 2,101 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
56
57
58
# The macro choose_msvc_crt() takes a list of possible
# C runtimes to choose from, in the form of compiler flags,
# to present to the user. (MTd for /MTd, etc)
#
# The macro is invoked at the end of the file.
#
# This mechanism is deprecated, but kept for transitioning users.
#
# This reads the LLVM_USE_CRT_<CONFIG> options and sets
# CMAKE_MSVC_RUNTIME_LIBRARY accordingly. The previous mechanism allowed
# setting different choices for different build configurations (for
# multi-config generators), but translating multiple differing choices to
# the corresponding CMAKE_MSVC_RUNTIME_LIBRARY generator expression isn't
# supported by this transitional helper.

macro(choose_msvc_crt MSVC_CRT)
  if(LLVM_USE_CRT)
    message(FATAL_ERROR
      "LLVM_USE_CRT is deprecated. Use the CMAKE_BUILD_TYPE-specific
variables (LLVM_USE_CRT_DEBUG, etc) instead.")
  endif()

  foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
    string(TOUPPER "${build_type}" build)
    if (NOT "${LLVM_USE_CRT_${build}}" STREQUAL "")
      if (NOT ${LLVM_USE_CRT_${build}} IN_LIST ${MSVC_CRT})
        message(FATAL_ERROR
          "Invalid value for LLVM_USE_CRT_${build}: ${LLVM_USE_CRT_${build}}. Valid options are one of: ${${MSVC_CRT}}")
      endif()
      set(library "MultiThreaded")
      if ("${LLVM_USE_CRT_${build}}" MATCHES "d$")
        set(library "${library}Debug")
      endif()
      if ("${LLVM_USE_CRT_${build}}" MATCHES "^MD")
        set(library "${library}DLL")
      endif()
      if(${runtime_library_set})
        message(WARNING "Conflicting LLVM_USE_CRT_* options")
      else()
        message(WARNING "The LLVM_USE_CRT_* options are deprecated, use the CMake provided CMAKE_MSVC_RUNTIME_LIBRARY setting instead")
      endif()
      set(CMAKE_MSVC_RUNTIME_LIBRARY "${library}" CACHE STRING "" FORCE)
      message(STATUS "Using VC++ CRT: ${CMAKE_MSVC_RUNTIME_LIBRARY}")
      set(runtime_library_set 1)
    endif()
  endforeach(build_type)
endmacro(choose_msvc_crt MSVC_CRT)


# List of valid CRTs for MSVC
set(MSVC_CRT
  MD
  MDd
  MT
  MTd)

choose_msvc_crt(MSVC_CRT)