diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c7222865..c504421c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -422,6 +422,18 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") install(CODE "execute_process(COMMAND cp -a ${_qt5Core_install_prefix}/qml/QtPositioning ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Resources/qml)") install(CODE "message(STATUS \"two ERRORS here about libmysqlclient and libpq not found are harmless\")") elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + if(NOT DEFINED OBJCOPY) + set(OBJCOPY i686-w64-mingw32.shared-objcopy) + endif() + message(STATUS "Build type is 'RelWithDebInfo'. Creating debug symbols in a separate file.") + add_custom_command(TARGET ${SUBSURFACE_TARGET} POST_BUILD + COMMAND ${OBJCOPY} --only-keep-debug ${SUBSURFACE_TARGET}.exe ${SUBSURFACE_TARGET}.exe.debug + COMMAND ${OBJCOPY} --strip-debug --strip-unneeded ${SUBSURFACE_TARGET}.exe + COMMAND ${OBJCOPY} --add-gnu-debuglink=${SUBSURFACE_TARGET}.exe.debug ${SUBSURFACE_TARGET}.exe + ) + endif() + # Windows bundling rules # We don't have a helpful tool like macdeployqt for Windows, so we hardcode # which libs we need. diff --git a/packaging/windows/mxe-based-build.sh b/packaging/windows/mxe-based-build.sh index ae51109ce..3c6c7fa34 100755 --- a/packaging/windows/mxe-based-build.sh +++ b/packaging/windows/mxe-based-build.sh @@ -281,10 +281,3 @@ i686-w64-mingw32.shared-cmake \ "$BASEDIR"/subsurface make $JOBS "$@" - -OBJCOPY="i686-w64-mingw32.shared-objcopy" -if [[ "$RELEASE_MAIN" == "RelWithDebInfo" ]] ; then - $OBJCOPY --only-keep-debug subsurface.exe subsurface.exe.debug - $OBJCOPY --strip-debug --strip-unneeded subsurface.exe - $OBJCOPY --add-gnu-debuglink=subsurface.exe.debug subsurface.exe -fi