Skip to content

Commit

Permalink
vcpkg bugfix dynamic/static CRT linkage
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Jun 25, 2024
1 parent 92382ca commit 51a0e56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions cmake/Modules/TinyInitDefaultVariables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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$<$<CONFIG:Debug>:Debug>DLL")
else()
Expand Down

0 comments on commit 51a0e56

Please sign in to comment.