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