Skip to content

Commit

Permalink
Merge pull request #128 from Hombre57/building-on-windows
Browse files Browse the repository at this point in the history
Enable building HDRMerge on Windows using qt5
  • Loading branch information
Beep6581 authored Mar 27, 2018
2 parents 7dc4fe3 + 655ed80 commit 22c9a7b
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 21 deletions.
51 changes: 37 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ if(WIN32)
src/main.cpp
src/Launcher.cpp
data/resources.qrc
${hdrmerge_translations}
${hdrmerge_sources}
${hdrmerge_gui_sources}
${hdrmerge_moc}
Expand Down Expand Up @@ -277,29 +278,51 @@ if(WIN32)
add_executable(hdrmerge-nogui
src/main.cpp
src/Launcher.cpp
$<TARGET_OBJECTS:hdrmerge-objects>
data/resources.qrc
${hdrmerge_translations}
${hdrmerge_sources}
${hdrmerge_moc}
$<TARGET_OBJECTS:alglib-objects>
"${PLATFORM_SOURCES}"
)
target_link_libraries(hdrmerge-nogui ${STRIP} ${hdrmerge_libs})

# WARNING: ImageIO class need QImage which need Qt5::Widgets
# Launcher.cpp need QApplication which need Qt5::Widgets
target_link_libraries(hdrmerge-nogui ${STRIP} ${hdrmerge_libs} Qt5::Widgets Qt5::Core)
set_target_properties(hdrmerge-nogui PROPERTIES COMPILE_DEFINITIONS "NO_GUI")
# Create the installer with makensis
find_program(MAKENSIS_EXECUTABLE makensis.exe PATH_SUFFIXES "NSIS/Bin")
if(MAKENSIS_EXECUTABLE)
message(STATUS "NSIS found!")
message(STATUS "NSIS found")
set(SETUP_PROG hdrmerge-setup${WIN_ARCH}-${HDRMERGE_VERSION}.exe)
configure_file(
"${PROJECT_SOURCE_DIR}/data/setup.nsi"
"${PROJECT_BINARY_DIR}/setup.nsi" @ONLY
)
add_custom_command(OUTPUT ${SETUP_PROG}
COMMAND "${MAKENSIS_EXECUTABLE}" -V2 setup.nsi
MAIN_DEPENDENCY setup.nsi
DEPENDS "${PROJECT_BINARY_DIR}/hdrmerge.exe"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
add_custom_target(hdrmerge-setup ALL DEPENDS "${PROJECT_BINARY_DIR}/${SETUP_PROG}")
string(REPLACE "/" "\\" PROJ_SRC_DIR "${PROJECT_SOURCE_DIR}")
message(STATUS "PROJ_SRC_DIR = ${PROJ_SRC_DIR}")

# ASSUMING YOU'RE USING EXIV2 BUNDLED WITH MSYS2
find_program(MINGW_LIB_DIR exiv2.exe)
if(MINGW_LIB_DIR)
get_filename_component(MINGW_LIB_DIR "${MINGW_LIB_DIR}" PATH)
string(REPLACE "/" "\\" MINGW_LIB_DIR "${MINGW_LIB_DIR}")
message(STATUS "MINGW_LIB_DIR = ${MINGW_LIB_DIR}")

set(QT5_PLUGINS_DIR "${MINGW_LIB_DIR}\\..\\share\\qt5\\plugins")
message(STATUS "QT5_PLUGINS_DIR = ${QT5_PLUGINS_DIR}")

configure_file(
"${PROJECT_SOURCE_DIR}/data/setup.nsi"
"${PROJECT_BINARY_DIR}/setup.nsi" @ONLY
)
add_custom_command(OUTPUT ${SETUP_PROG}
COMMAND "${MAKENSIS_EXECUTABLE}" -V2 setup.nsi
MAIN_DEPENDENCY setup.nsi
DEPENDS "${PROJECT_BINARY_DIR}/hdrmerge.exe"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
add_custom_target(hdrmerge-setup ALL DEPENDS "${PROJECT_BINARY_DIR}/${SETUP_PROG}")
else(MINGW_LIB_DIR)
message(STATUS "Unable to locate the 'bin' directory to get the dependencies")
endif(MINGW_LIB_DIR)
else()
message(STATUS "NSIS not found!")
message(STATUS "NSIS not found")
endif()
elseif(APPLE)
set_source_files_properties(images/icon.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
Expand Down
72 changes: 66 additions & 6 deletions data/setup.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ VIAddVersionKey "FileDescription" "${APPNAME}"
VIAddVersionKey "FileVersion" "@HDRMERGE_VERSION@"
VIAddVersionKey "ProductVersion" "@HDRMERGE_VERSION@"

!define MUI_ICON "@PROJECT_SOURCE_DIR@/images/icon.ico"
!define MUI_ICON "@PROJ_SRC_DIR@\data\images\icon.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "@PROJECT_SOURCE_DIR@/images/logo.bmp"
!define MUI_HEADERIMAGE_BITMAP "@PROJ_SRC_DIR@\data\images\logo.bmp"
!define MUI_HEADERIMAGE_RIGHT

;--------------------------------

; Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "@PROJECT_SOURCE_DIR@/LICENSE"
!insertmacro MUI_PAGE_LICENSE "@PROJ_SRC_DIR@\LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
Expand All @@ -65,10 +65,41 @@ Section "HDRMerge (required)"

; Put file there
File "hdrmerge.exe" \
"@PROJECT_SOURCE_DIR@/LICENSE" \
"@PROJECT_SOURCE_DIR@/LICENSE_icons" \
"@PROJECT_SOURCE_DIR@/README.md"
"@PROJ_SRC_DIR@\LICENSE" \
"@PROJ_SRC_DIR@\LICENSE_icons" \
"@PROJ_SRC_DIR@\README.md"\
"@MINGW_LIB_DIR@\libbz2-1.dll"\
"@MINGW_LIB_DIR@\libexiv2.dll"\
"@MINGW_LIB_DIR@\libexpat-1.dll"\
"@MINGW_LIB_DIR@\libfreetype-6.dll"\
"@MINGW_LIB_DIR@\libgcc_s_seh-1.dll"\
"@MINGW_LIB_DIR@\libglib-2.0-0.dll"\
"@MINGW_LIB_DIR@\libgomp-1.dll"\
"@MINGW_LIB_DIR@\libgraphite2.dll"\
"@MINGW_LIB_DIR@\libharfbuzz-0.dll"\
"@MINGW_LIB_DIR@\libiconv-2.dll"\
"@MINGW_LIB_DIR@\libicudt58.dll"\
"@MINGW_LIB_DIR@\libicuin58.dll"\
"@MINGW_LIB_DIR@\libicuuc58.dll"\
"@MINGW_LIB_DIR@\libintl-8.dll"\
"@MINGW_LIB_DIR@\libjasper-4.dll"\
"@MINGW_LIB_DIR@\libjpeg-8.dll"\
"@MINGW_LIB_DIR@\liblcms2-2.dll"\
"@MINGW_LIB_DIR@\libpcre-1.dll"\
"@MINGW_LIB_DIR@\libpcre2-16-0.dll"\
"@MINGW_LIB_DIR@\libpng16-16.dll"\
"@MINGW_LIB_DIR@\libraw_r-16.dll"\
"@MINGW_LIB_DIR@\libstdc++-6.dll"\
"@MINGW_LIB_DIR@\libwinpthread-1.dll"\
"@MINGW_LIB_DIR@\Qt5Core.dll"\
"@MINGW_LIB_DIR@\Qt5Gui.dll"\
"@MINGW_LIB_DIR@\Qt5Widgets.dll"\
"@MINGW_LIB_DIR@\zlib1.dll"
File /oname=hdrmerge.com "hdrmerge-nogui.exe"

SetOutPath $INSTDIR\platforms

File "@QT5_PLUGINS_DIR@\platforms\qwindows.dll"

; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\${APPNAME} "Install_Dir" "$INSTDIR"
Expand Down Expand Up @@ -121,6 +152,35 @@ Section "Uninstall"
Delete "$INSTDIR\LICENSE_icons"
Delete "$INSTDIR\README.md"
Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\platforms\qwindows.dll"
RMDir "$INSTDIR\platforms"
Delete "$INSTDIR\libbz2-1.dll"
Delete "$INSTDIR\libexiv2.dll"
Delete "$INSTDIR\libexpat-1.dll"
Delete "$INSTDIR\libfreetype-6.dll"
Delete "$INSTDIR\libgcc_s_seh-1.dll"
Delete "$INSTDIR\libglib-2.0-0.dll"
Delete "$INSTDIR\libgomp-1.dll"
Delete "$INSTDIR\libgraphite2.dll"
Delete "$INSTDIR\libharfbuzz-0.dll"
Delete "$INSTDIR\libiconv-2.dll"
Delete "$INSTDIR\libicudt58.dll"
Delete "$INSTDIR\libicuin58.dll"
Delete "$INSTDIR\libicuuc58.dll"
Delete "$INSTDIR\libintl-8.dll"
Delete "$INSTDIR\libjasper-4.dll"
Delete "$INSTDIR\libjpeg-8.dll"
Delete "$INSTDIR\liblcms2-2.dll"
Delete "$INSTDIR\libpcre-1.dll"
Delete "$INSTDIR\libpcre2-16-0.dll"
Delete "$INSTDIR\libpng16-16.dll"
Delete "$INSTDIR\libraw_r-16.dll"
Delete "$INSTDIR\libstdc++-6.dll"
Delete "$INSTDIR\libwinpthread-1.dll"
Delete "$INSTDIR\Qt5Core.dll"
Delete "$INSTDIR\Qt5Gui.dll"
Delete "$INSTDIR\Qt5Widgets.dll"
Delete "$INSTDIR\zlib1.dll"
RMDir /REBOOTOK $INSTDIR

SectionEnd
2 changes: 1 addition & 1 deletion data/winres.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
iconId ICON "@PROJECT_SOURCE_DIR@/images/icon.ico"
iconId ICON "@PROJECT_SOURCE_DIR@/data/images/icon.ico"

1 VERSIONINFO
FILEVERSION @HDRMERGE_VERSION_MAJOR@,@HDRMERGE_VERSION_MINOR@,@HDRMERGE_VERSION_REV@,0
Expand Down
2 changes: 2 additions & 0 deletions src/LoadOptionsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ LoadOptionsDialog::LoadOptionsDialog(QWidget * parent, Qt::WindowFlags f)
QSettings settings;
QVBoxLayout * layout = new QVBoxLayout(this);

setMinimumSize(400, 400);

QWidget * fileSelector = new QWidget(this);
QHBoxLayout * fileSelectorLayout = new QHBoxLayout(fileSelector);
fileSelectorLayout->setMargin(0);
Expand Down

0 comments on commit 22c9a7b

Please sign in to comment.