123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- macro(make_crt_regex regex crts)
- set(${regex} "")
- foreach(crt ${${crts}})
-
-
- set(${regex} "${${regex}}|(^| +)/${crt}($| +)")
- endforeach(crt)
- string(REGEX REPLACE "^\\|" "" ${regex} "${${regex}}")
- endmacro(make_crt_regex)
- macro(get_current_crt crt_current regex flagsvar)
-
-
- string(REGEX MATCH "${${regex}}" ${crt_current} "${${flagsvar}}")
- string(REPLACE "/" " " ${crt_current} "${${crt_current}}")
- string(STRIP "${${crt_current}}" ${crt_current})
- endmacro(get_current_crt)
- macro(set_flag_in_var flagsvar regex flag)
- string(REGEX MATCH "${${regex}}" current_flag "${${flagsvar}}")
- if("${current_flag}" STREQUAL "")
- set(${flagsvar} "${${flagsvar}}${${flag}}")
- else()
- string(REGEX REPLACE "${${regex}}" "${${flag}}" ${flagsvar} "${${flagsvar}}")
- endif()
- string(STRIP "${${flagsvar}}" ${flagsvar})
-
-
-
- get_property(flagsvar_docs CACHE ${flagsvar} PROPERTY HELPSTRING)
- set(${flagsvar} "${${flagsvar}}" CACHE STRING "${flagsvar_docs}" FORCE)
- endmacro(set_flag_in_var)
- 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()
- make_crt_regex(MSVC_CRT_REGEX ${MSVC_CRT})
- foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
- string(TOUPPER "${build_type}" build)
- if (NOT LLVM_USE_CRT_${build})
- get_current_crt(LLVM_USE_CRT_${build}
- MSVC_CRT_REGEX
- CMAKE_CXX_FLAGS_${build})
- set(LLVM_USE_CRT_${build}
- "${LLVM_USE_CRT_${build}}"
- CACHE STRING "Specify VC++ CRT to use for ${build_type} configurations."
- FORCE)
- set_property(CACHE LLVM_USE_CRT_${build}
- PROPERTY STRINGS ;${${MSVC_CRT}})
- endif(NOT LLVM_USE_CRT_${build})
- endforeach(build_type)
- foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
- string(TOUPPER "${build_type}" build)
- if ("${LLVM_USE_CRT_${build}}" STREQUAL "")
- set(flag_string " ")
- else()
- set(flag_string " /${LLVM_USE_CRT_${build}} ")
- list(FIND ${MSVC_CRT} ${LLVM_USE_CRT_${build}} idx)
- if (idx LESS 0)
- message(FATAL_ERROR
- "Invalid value for LLVM_USE_CRT_${build}: ${LLVM_USE_CRT_${build}}. Valid options are one of: ${${MSVC_CRT}}")
- endif (idx LESS 0)
- message(STATUS "Using ${build_type} VC++ CRT: ${LLVM_USE_CRT_${build}}")
- endif()
- foreach(lang C CXX)
- set_flag_in_var(CMAKE_${lang}_FLAGS_${build} MSVC_CRT_REGEX flag_string)
- endforeach(lang)
- endforeach(build_type)
- endmacro(choose_msvc_crt MSVC_CRT)
- set(MSVC_CRT
- MD
- MDd
- MT
- MTd)
- choose_msvc_crt(MSVC_CRT)
|