mirror of https://github.com/WerWolv/ImHex
build: Force-set REINSTALLMODE=amus for WiX installer
This commit is contained in:
parent
e23cb5509d
commit
2586645d02
|
|
@ -211,6 +211,7 @@ macro(configurePackingResources)
|
||||||
set(CPACK_WIX_UI_BANNER "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_banner.png")
|
set(CPACK_WIX_UI_BANNER "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_banner.png")
|
||||||
set(CPACK_WIX_UI_DIALOG "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_dialog.png")
|
set(CPACK_WIX_UI_DIALOG "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_dialog.png")
|
||||||
set(CPACK_WIX_CULTURES "en-US;de-DE;ja-JP;it-IT;pt-BR;zh-CN;zh-TW;ru-RU")
|
set(CPACK_WIX_CULTURES "en-US;de-DE;ja-JP;it-IT;pt-BR;zh-CN;zh-TW;ru-RU")
|
||||||
|
set(CPACK_WIX_PATCH_FILE "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_patch.xml")
|
||||||
|
|
||||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ImHex")
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ImHex")
|
||||||
set_property(INSTALL "$<TARGET_FILE_NAME:main>"
|
set_property(INSTALL "$<TARGET_FILE_NAME:main>"
|
||||||
|
|
@ -314,7 +315,7 @@ macro(createPackage)
|
||||||
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll"
|
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(_c_deps_FILENAMES AND NOT _c_deps STREQUAL "")
|
if(_c_deps_FILENAMES AND _c_deps AND NOT (_c_deps STREQUAL ""))
|
||||||
message(WARNING "Conflicting dependencies for library: \"${_c_deps}\"!")
|
message(WARNING "Conflicting dependencies for library: \"${_c_deps}\"!")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
@ -333,30 +334,6 @@ macro(createPackage)
|
||||||
endforeach()
|
endforeach()
|
||||||
]])
|
]])
|
||||||
|
|
||||||
if (NOT MSVC)
|
|
||||||
set(VERSIONLESS_LIBWINPTHREAD "${CMAKE_BINARY_DIR}/libwinpthread-1.dll")
|
|
||||||
find_file(LIBWINPTHREAD_PATH NAMES libwinpthread-1.dll)
|
|
||||||
if (NOT LIBWINPTHREAD_PATH)
|
|
||||||
message(FATAL_ERROR "Could not find libwinpthread-1.dll!")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${VERSIONLESS_LIBWINPTHREAD}
|
|
||||||
COMMAND $<TARGET_FILE:version-stripper> ${LIBWINPTHREAD_PATH} ${VERSIONLESS_LIBWINPTHREAD}
|
|
||||||
DEPENDS version-stripper
|
|
||||||
COMMENT "Stripping version info from libwinpthread..."
|
|
||||||
VERBATIM
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_target(versionless_libwinpthread ALL
|
|
||||||
DEPENDS ${VERSIONLESS_LIBWINPTHREAD}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES ${VERSIONLESS_LIBWINPTHREAD}
|
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
downloadImHexPatternsFiles(".")
|
downloadImHexPatternsFiles(".")
|
||||||
elseif(UNIX AND NOT APPLE)
|
elseif(UNIX AND NOT APPLE)
|
||||||
set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION})
|
set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION})
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,6 @@ endif ()
|
||||||
add_subdirectory(gui)
|
add_subdirectory(gui)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_subdirectory(forwarder)
|
add_subdirectory(forwarder)
|
||||||
|
|
||||||
if (NOT MSVC)
|
|
||||||
add_subdirectory(version_stripper)
|
|
||||||
endif()
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (NOT EMSCRIPTEN)
|
if (NOT EMSCRIPTEN)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
project(version-stripper)
|
|
||||||
|
|
||||||
add_executable(version-stripper
|
|
||||||
source/main.cpp
|
|
||||||
)
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/**
|
|
||||||
* A simple utility to strip version resources from Windows executables.
|
|
||||||
*
|
|
||||||
* Usage: version_stripper <input path> <output path>
|
|
||||||
*
|
|
||||||
* This program copies the input executable to the output path and removes
|
|
||||||
* its version resource information.
|
|
||||||
*
|
|
||||||
* Based on https://github.com/shewitt-au/nuke_version
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <filesystem>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <string>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using LangIds = std::vector<WORD>;
|
|
||||||
|
|
||||||
BOOL CALLBACK EnumResLangProc(
|
|
||||||
HMODULE hModule,
|
|
||||||
LPCTSTR lpszType,
|
|
||||||
LPCTSTR lpszName,
|
|
||||||
WORD wIDLanguage,
|
|
||||||
LONG_PTR lParam
|
|
||||||
) {
|
|
||||||
auto& langs = *reinterpret_cast<LangIds*>(lParam);
|
|
||||||
langs.push_back(wIDLanguage);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
LangIds getLangIDs(LPCTSTR pExe) {
|
|
||||||
LangIds langs;
|
|
||||||
|
|
||||||
HMODULE hMod = LoadLibrary(pExe);
|
|
||||||
if (hMod == nullptr)
|
|
||||||
throw std::runtime_error("LoadLibrary failed!");
|
|
||||||
|
|
||||||
BOOL bOK = EnumResourceLanguages(
|
|
||||||
hMod, // HMODULE hModule
|
|
||||||
RT_VERSION, // LPCTSTR lpType
|
|
||||||
MAKEINTRESOURCE(1), // LPCTSTR lpName
|
|
||||||
EnumResLangProc, // ENUMRESLANGPROC lpEnumFunc
|
|
||||||
reinterpret_cast<LONG_PTR>(&langs) // LONG_PTR lParam
|
|
||||||
);
|
|
||||||
|
|
||||||
FreeLibrary(hMod);
|
|
||||||
|
|
||||||
if (!bOK)
|
|
||||||
throw std::runtime_error("EnumResourceLanguages failed!");
|
|
||||||
|
|
||||||
return langs;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nukeVersionResource(LPCTSTR pExe) {
|
|
||||||
LangIds langs = getLangIDs(pExe);
|
|
||||||
|
|
||||||
HANDLE hResUpdate = BeginUpdateResource(pExe, FALSE);
|
|
||||||
if (hResUpdate == nullptr)
|
|
||||||
throw std::runtime_error("BeginUpdateResource failed!");
|
|
||||||
|
|
||||||
for (WORD langID : langs) {
|
|
||||||
BOOL bOK = UpdateResource(
|
|
||||||
hResUpdate, // HANDLE hUpdate
|
|
||||||
RT_VERSION, // LPCTSTR lpType
|
|
||||||
MAKEINTRESOURCE(1), // LPCTSTR lpName
|
|
||||||
langID, // WORD wLanguage
|
|
||||||
nullptr, // LPVOID lpData
|
|
||||||
0 // DWORD cb
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!bOK) {
|
|
||||||
EndUpdateResource(
|
|
||||||
hResUpdate, // HANDLE hUpdate
|
|
||||||
TRUE // BOOL fDiscard
|
|
||||||
);
|
|
||||||
|
|
||||||
throw std::runtime_error("UpdateResource failed! Nothing done!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
EndUpdateResource(
|
|
||||||
hResUpdate, // HANDLE hUpdate
|
|
||||||
FALSE // BOOL fDiscard
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
if (argc != 3) {
|
|
||||||
printf("Usage: %s <input path> <output path>\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::filesystem::path inputPath(argv[1]);
|
|
||||||
std::filesystem::path outputPath(argv[2]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
std::filesystem::copy(inputPath, outputPath, std::filesystem::copy_options::overwrite_existing);
|
|
||||||
nukeVersionResource(outputPath.c_str());
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
fprintf(stderr, "%s", e.what());
|
|
||||||
std::filesystem::remove(outputPath);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
<CPackWiXPatch>
|
||||||
|
<CPackWiXFragment Id="#PRODUCT">
|
||||||
|
<SetProperty Id="REINSTALL" Value="ALL" After="CostFinalize" />
|
||||||
|
<SetProperty Id="REINSTALLMODE" Value="amus" After="CostFinalize" />
|
||||||
|
</CPackWiXFragment>
|
||||||
|
</CPackWiXPatch>
|
||||||
Loading…
Reference in New Issue