From 2d7dd36b0d41a421b4e8e1fb39e67571fa96e241 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 12 Apr 2021 20:36:16 +0200 Subject: [PATCH] build: Improve linking and fix resource strings on windows --- CMakeLists.txt | 10 +++++++--- cmake/build_helpers.cmake | 3 ++- res/resource.rc | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fefa9728..dd75d1264 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,9 +71,13 @@ set_target_properties(imhex PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_directories(imhex PRIVATE ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS}) if (WIN32) - target_link_libraries(imhex libdl.a libmagic.a libgnurx.a libtre.a libintl.a libiconv.a libshlwapi.a libcapstone.a LLVMDemangle libimhex ${Python_LIBRARIES} wsock32 ws2_32 libyara) -elseif (UNIX) + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + target_link_libraries(imhex magic gnurx tre intl iconv libshlwapi.a ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} dl pthread wsock32 ws2_32 libyara) + else () + target_link_libraries(imhex libdl.a libmagic.a libgnurx.a libtre.a libintl.a libiconv.a libshlwapi.a libcapstone.a LLVMDemangle libimhex ${Python_LIBRARIES} wsock32 ws2_32 libyara) + endif() +else () target_link_libraries(imhex magic ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} dl pthread libyara) -endif() +endif () createPackage() diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 83104554e..0fa605b4b 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -20,6 +20,7 @@ macro(addVersionDefines) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGIT_BRANCH=\"\\\"${GIT_BRANCH}\"\\\"") endif() + set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DPROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} -DPROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR} -DPROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH} ") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE -DIMHEX_VERSION=\"\\\"${PROJECT_VERSION}\"\\\"") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -DIMHEX_VERSION=\"\\\"${PROJECT_VERSION}-Debug\"\\\"") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DRELEASE -DIMHEX_VERSION=\"\\\"${PROJECT_VERSION}-ReleaseWithDebugInfo\"\\\"") @@ -116,7 +117,7 @@ macro(configurePackageCreation) set(application_type) endif () set(imhex_icon "${PROJECT_SOURCE_DIR}/res/resource.rc") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -Wl,--allow-multiple-definition -static -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -Wl,--allow-multiple-definition -static") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wl,-subsystem,windows") if (CREATE_PACKAGE) diff --git a/res/resource.rc b/res/resource.rc index ba196a06e..dec34be73 100644 --- a/res/resource.rc +++ b/res/resource.rc @@ -1 +1,32 @@ -GLFW_ICON ICON icon.ico \ No newline at end of file +GLFW_ICON ICON icon.ico + +1 VERSIONINFO + FILEVERSION PROJECT_VERSION_MAJOR,PROJECT_VERSION_MINOR,PROJECT_VERSION_PATCH + PRODUCTVERSION PROJECT_VERSION_MAJOR,PROJECT_VERSION_MINOR,PROJECT_VERSION_PATCH + FILEFLAGSMASK 0x17L + #ifdef _DEBUG + FILEFLAGS 0x1L + #else + FILEFLAGS 0x0L + #endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "Comments", "A Hex Editor for Reverse Engineers, Programmers and people that value their eye sight when working at 3 AM." + VALUE "CompanyName", "WerWolv" + VALUE "FileDescription", "ImHex Hex Editor" + VALUE "LegalCopyright", "WerWolv 2020-2021" + VALUE "OriginalFilename", "imhex.exe" + VALUE "ProductName", "ImHex" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1200 + END + END \ No newline at end of file