xref: /aosp_15_r20/external/libwebm/build/msvc_runtime.cmake (revision 103e46e4cd4b6efcf6001f23fa8665fb110abf8d)
1*103e46e4SHarish Mahendrakar#  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
2*103e46e4SHarish Mahendrakar#
3*103e46e4SHarish Mahendrakar#  Use of this source code is governed by a BSD-style license
4*103e46e4SHarish Mahendrakar#  that can be found in the LICENSE file in the root of the source
5*103e46e4SHarish Mahendrakar#  tree. An additional intellectual property rights grant can be found
6*103e46e4SHarish Mahendrakar#  in the file PATENTS.  All contributing project authors may
7*103e46e4SHarish Mahendrakar#  be found in the AUTHORS file in the root of the source tree.
8*103e46e4SHarish Mahendrakar
9*103e46e4SHarish Mahendrakarif(MSVC)
10*103e46e4SHarish Mahendrakar  # CMake defaults to producing code linked to the DLL MSVC runtime. In libwebm
11*103e46e4SHarish Mahendrakar  # static is typically desired. Force static code generation unless the user
12*103e46e4SHarish Mahendrakar  # running CMake set MSVC_RUNTIME to dll.
13*103e46e4SHarish Mahendrakar  if(NOT "${MSVC_RUNTIME}" STREQUAL "dll")
14*103e46e4SHarish Mahendrakar    foreach(flag_var
15*103e46e4SHarish Mahendrakar            CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
16*103e46e4SHarish Mahendrakar            CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
17*103e46e4SHarish Mahendrakar      if(${flag_var} MATCHES "/MD")
18*103e46e4SHarish Mahendrakar        string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
19*103e46e4SHarish Mahendrakar      endif(${flag_var} MATCHES "/MD")
20*103e46e4SHarish Mahendrakar    endforeach(flag_var)
21*103e46e4SHarish Mahendrakar  endif()
22*103e46e4SHarish Mahendrakarendif()
23