diff options
author | Loïc Guilloux <glx22@users.noreply.github.com> | 2021-04-07 12:43:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-07 12:43:17 +0200 |
commit | f306d65ea3985de4701d4a552b653757d0cb4858 (patch) | |
tree | 3a9ec18dfd3d92ecd5324bf1d44351106907fc0a /cmake | |
parent | e7cf589868480022599f6935997ef45963fc3f5a (diff) | |
download | openttd-f306d65ea3985de4701d4a552b653757d0cb4858.tar.xz |
Fix: [CMake] Use the right run-time library depending on vcpkg triplet (#8964)
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/CompileFlags.cmake | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/cmake/CompileFlags.cmake b/cmake/CompileFlags.cmake index f4047b839..86d336b59 100644 --- a/cmake/CompileFlags.cmake +++ b/cmake/CompileFlags.cmake @@ -4,20 +4,22 @@ # macro(compile_flags) if(MSVC) - # Switch to MT (static) instead of MD (dynamic) binary - - # For MSVC two generators are available - # - a command line generator (Ninja) using CMAKE_BUILD_TYPE to specify the - # configuration of the build tree - # - an IDE generator (Visual Studio) using CMAKE_CONFIGURATION_TYPES to - # specify all configurations that will be available in the generated solution - list(APPEND MSVC_CONFIGS "${CMAKE_BUILD_TYPE}" "${CMAKE_CONFIGURATION_TYPES}") - - # Set usage of static runtime for all configurations - foreach(MSVC_CONFIG ${MSVC_CONFIGS}) - string(TOUPPER "CMAKE_CXX_FLAGS_${MSVC_CONFIG}" MSVC_FLAGS) - string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}") - endforeach() + if(VCPKG_TARGET_TRIPLET MATCHES "-static" AND NOT VCPKG_TARGET_TRIPLET MATCHES "-md") + # Switch to MT (static) instead of MD (dynamic) binary + + # For MSVC two generators are available + # - a command line generator (Ninja) using CMAKE_BUILD_TYPE to specify the + # configuration of the build tree + # - an IDE generator (Visual Studio) using CMAKE_CONFIGURATION_TYPES to + # specify all configurations that will be available in the generated solution + list(APPEND MSVC_CONFIGS "${CMAKE_BUILD_TYPE}" "${CMAKE_CONFIGURATION_TYPES}") + + # Set usage of static runtime for all configurations + foreach(MSVC_CONFIG ${MSVC_CONFIGS}) + string(TOUPPER "CMAKE_CXX_FLAGS_${MSVC_CONFIG}" MSVC_FLAGS) + string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}") + endforeach() + endif() # "If /Zc:rvalueCast is specified, the compiler follows section 5.4 of the # C++11 standard". We need C++11 for the way we use threads. |