Windows updates (better Blender version check, better static linking)

This commit is contained in:
Luke Street 2020-06-13 17:21:50 -04:00
parent b16174edcd
commit 45fe93ee94
4 changed files with 28 additions and 12 deletions

View File

@ -107,8 +107,10 @@ if(WIN32)
platforms/win/hecl-gui.manifest
platforms/win/hecl-gui.rc
)
# FIXME hack to fix static link with outdated Qt cmake files
target_link_libraries(hecl-gui PRIVATE C:/vcpkg/installed/x64-windows-static/$<$<CONFIG:Debug>:debug/>lib/Qt5VulkanSupport$<$<CONFIG:Debug>:d>.lib)
# Check for static linking
if(NOT "$<TARGET_PROPERTY:hecl-gui,MSVC_RUNTIME_LIBRARY>" MATCHES "DLL$")
target_link_libraries(hecl-gui PRIVATE Qt5::QWindowsIntegrationPlugin)
endif()
elseif(APPLE)
target_sources(hecl-gui PRIVATE platforms/mac/mainicon.icns)
set_source_files_properties(platforms/mac/mainicon.icns PROPERTIES

View File

@ -88,27 +88,40 @@ hecl::SystemString FindBlender(int& major, int& minor) {
if (!blenderBin)
return {};
hecl::SystemString command = hecl::SystemString(_SYS_STR("\"")) + blenderBin + _SYS_STR("\" --version");
#if _WIN32
FILE* fp = _wpopen(command.c_str(), _SYS_STR("r"));
DWORD handle = 0;
DWORD infoSize = GetFileVersionInfoSizeW(blenderBin, &handle);
if (infoSize != NULL) {
auto* infoData = new char[infoSize];
if (GetFileVersionInfoW(blenderBin, handle, infoSize, infoData)) {
UINT size = 0;
LPVOID lpBuffer = nullptr;
if (VerQueryValueW(infoData, L"\\", &lpBuffer, &size) && size != 0u) {
auto* verInfo = static_cast<VS_FIXEDFILEINFO*>(lpBuffer);
if (verInfo->dwSignature == 0xfeef04bd) {
major = static_cast<int>((verInfo->dwFileVersionMS >> 16) & 0xffff);
minor = static_cast<int>((verInfo->dwFileVersionMS >> 0 & 0xffff) * 10 +
(verInfo->dwFileVersionLS >> 16 & 0xffff));
}
}
}
delete[] infoData;
}
#else
hecl::SystemString command = hecl::SystemString(_SYS_STR("\"")) + blenderBin + _SYS_STR("\" --version");
FILE* fp = popen(command.c_str(), "r");
#endif
char versionBuf[256];
size_t rdSize = fread(versionBuf, 1, 255, fp);
versionBuf[rdSize] = '\0';
#if _WIN32
_pclose(fp);
#else
pclose(fp);
#endif
std::cmatch match;
if (std::regex_search(versionBuf, match, regBlenderVersion)) {
major = atoi(match[1].str().c_str());
minor = atoi(match[2].str().c_str());
return blenderBin;
}
#endif
return blenderBin;
}

View File

@ -1,4 +1,5 @@
#if _WIN32
#if defined(_WIN32) && !defined(_DLL)
// Static linking on Windows
#include <QtPlugin>
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
#endif

View File

@ -1,6 +1,6 @@
add_executable(mkqticon mkqticon.c)
target_link_libraries(mkqticon ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
target_include_directories(mkqticon PRIVATE ${LIBPNG_INCLUDE_DIR})
target_include_directories(mkqticon PRIVATE ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
macro(declare_qticon_target)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/hecl-gui/platforms/freedesktop/mainicon_qt.bin