diff --git a/CMakeLists.txt b/CMakeLists.txt index 095833339..41204307e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,12 +117,14 @@ when the build type is equal" OFF "CMAKE_EXPORT_PACKAGE_REGISTRY AND NOT TINY_IS_MULTI_CONFIG" OFF ) -# Don't depend on the TINY_VCPKG, the CMAKE_MSVC_RUNTIME_LIBRARY check is sufficient -# because vcpkg defines it +# The condition allows to use both mechanism to control dynamic/static, +# the CMAKE_MSVC_RUNTIME_LIBRARY or MSVC_RUNTIME_DYNAMIC +# Also this isn't allowed with vcpkg as it controls this using triplet (VCPKG_CRT_LINKAGE) feature_option_dependent(MSVC_RUNTIME_DYNAMIC "Use MSVC dynamic runtime library (-MD) instead of static (-MT), also considers \ a Debug configuration (-MTd, -MDd)" ON - "MSVC AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY" MSVC_RUNTIME_DYNAMIC-NOTFOUND + "MSVC AND (NOT TINY_VCPKG OR NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)" + MSVC_RUNTIME_DYNAMIC-NOTFOUND ) feature_option_environment(STRICT_MODE diff --git a/cmake/Modules/TinyInitDefaultVariables.cmake b/cmake/Modules/TinyInitDefaultVariables.cmake index 151d5fee2..23a407b75 100644 --- a/cmake/Modules/TinyInitDefaultVariables.cmake +++ b/cmake/Modules/TinyInitDefaultVariables.cmake @@ -43,10 +43,10 @@ DESTINATION is encountered") ) # Allow selecting dynamic or static MSVC runtime, also the TINY_VCPKG check isn't - # needed because the MSVC_RUNTIME_DYNAMIC option isn't defined during vcpkg builds, - # see the comment for the MSVC_RUNTIME_DYNAMIC option. - # The MSVC_RUNTIME_DYNAMIC is always defined so the DEFINED check isn't needed - if(MSVC AND NOT MSVC_RUNTIME_DYNAMIC STREQUAL MSVC_RUNTIME_DYNAMIC-NOTFOUND) + # strictly needed as on vcpkg the MSVC_RUNTIME_DYNAMIC isn't defined/used but with + # the TINY_VCPKG is clearly visible whats up. + # Also see the comment for the MSVC_RUNTIME_DYNAMIC option. + if(MSVC AND (NOT TINY_VCPKG OR DEFINED MSVC_RUNTIME_DYNAMIC)) if(MSVC_RUNTIME_DYNAMIC) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") else()