2
0
mirror of https://github.com/meganz/MEGAcmd synced 2025-08-30 13:27:44 +00:00

Fixes for Windows building

- unify vcpkg inclusion
- disable object_parallel_to_source for windows
- removed not available icon.rc for tests executables
- disable sanitizer for win32 in unit tests
- other building adjustments
- have InstrumentsException inherit form exception instead of
system_error
This commit is contained in:
Pablo Martin
2023-10-16 12:50:00 +02:00
parent 3be402f289
commit d9724a52c6
8 changed files with 78 additions and 75 deletions

5
.gitignore vendored
View File

@@ -120,6 +120,11 @@ contrib/QtCreator/*/*/Makefile
contrib/QtCreator/*/*/*/Makefile contrib/QtCreator/*/*/*/Makefile
test_integration test_integration
test_unit test_unit
.qtc_clangd
CMakeFiles
build-x64-windows-mega
Makefile.Debug
Makefile.Release
/Makefile* /Makefile*
build/Release_x64 build/Release_x64

View File

@@ -1,26 +1,4 @@
isEmpty(THIRDPARTY_VCPKG_BASE_PATH){ include(vcpkg_inclusion.pri)
THIRDPARTY_VCPKG_BASE_PATH = $$PWD/../../../../3rdParty_megacmd
}
win32 {
contains(QMAKE_TARGET.arch, x86_64):VCPKG_TRIPLET = x64-windows-mega
!contains(QMAKE_TARGET.arch, x86_64):VCPKG_TRIPLET = x86-windows-mega
}
macx{
isEmpty(VCPKG_TRIPLET){
contains(QT_ARCH, x86_64):VCPKG_TRIPLET = x64-osx-mega
contains(QT_ARCH, arm64):VCPKG_TRIPLET = arm64-osx-mega
}
contains(VCPKG_TRIPLET, arm64-osx-mega):contains(QMAKE_HOST.arch, arm64):QMAKE_APPLE_DEVICE_ARCHS=arm64
message("Building for macOS $$QT_ARCH in a $$QMAKE_HOST.arch host.")
}
unix:!macx:VCPKG_TRIPLET = x64-linux
message("THIRDPARTY_VCPKG_BASE_PATH: $$THIRDPARTY_VCPKG_BASE_PATH")
message("VCPKG_TRIPLET: $$VCPKG_TRIPLET")
packagesExist(libpcrecpp) | macx { packagesExist(libpcrecpp) | macx {
LIBS += -lpcrecpp LIBS += -lpcrecpp

View File

@@ -1,3 +1,4 @@
include(../../vcpkg_inclusion.pri)
MEGACMD_BASE_PATH_RELATIVE = ../../../../.. MEGACMD_BASE_PATH_RELATIVE = ../../../../..
MEGACMD_BASE_PATH = $$PWD/$$MEGACMD_BASE_PATH_RELATIVE MEGACMD_BASE_PATH = $$PWD/$$MEGACMD_BASE_PATH_RELATIVE

View File

@@ -12,7 +12,7 @@ TARGET = test_integration
TEMPLATE = app TEMPLATE = app
CONFIG -= qt CONFIG -= qt
CONFIG += object_parallel_to_source !win32:CONFIG += object_parallel_to_source
CONFIG += console CONFIG += console
DEFINES += MEGACMD_TESTING_CODE DEFINES += MEGACMD_TESTING_CODE
@@ -21,7 +21,6 @@ win32 {
LIBS += -lshlwapi -lws2_32 LIBS += -lshlwapi -lws2_32
LIBS += -lshell32 -luser32 -ladvapi32 LIBS += -lshell32 -luser32 -ladvapi32
RC_FILE = icon.rc
QMAKE_LFLAGS += /LARGEADDRESSAWARE QMAKE_LFLAGS += /LARGEADDRESSAWARE
QMAKE_LFLAGS_WINDOWS += /SUBSYSTEM:WINDOWS,5.01 QMAKE_LFLAGS_WINDOWS += /SUBSYSTEM:WINDOWS,5.01
QMAKE_LFLAGS_CONSOLE += /SUBSYSTEM:CONSOLE,5.01 QMAKE_LFLAGS_CONSOLE += /SUBSYSTEM:CONSOLE,5.01

View File

@@ -6,15 +6,11 @@ CONFIG(release, debug|release) {
CONFIG -= debug release CONFIG -= debug release
CONFIG += release CONFIG += release
} }
MEGACMD_BASE_PATH_RELATIVE = ../../../../..
MEGACMD_BASE_PATH = $$PWD/$$MEGACMD_BASE_PATH_RELATIVE
TARGET = test_unit TARGET = test_unit
TEMPLATE = app TEMPLATE = app
CONFIG -= qt CONFIG -= qt
CONFIG += object_parallel_to_source !win32:CONFIG += object_parallel_to_source
CONFIG += console CONFIG += console
DEFINES += MEGACMD_TESTING_CODE DEFINES += MEGACMD_TESTING_CODE
@@ -23,7 +19,6 @@ win32 {
LIBS += -lshlwapi -lws2_32 LIBS += -lshlwapi -lws2_32
LIBS += -lshell32 -luser32 -ladvapi32 LIBS += -lshell32 -luser32 -ladvapi32
RC_FILE = icon.rc
QMAKE_LFLAGS += /LARGEADDRESSAWARE QMAKE_LFLAGS += /LARGEADDRESSAWARE
QMAKE_LFLAGS_WINDOWS += /SUBSYSTEM:WINDOWS,5.01 QMAKE_LFLAGS_WINDOWS += /SUBSYSTEM:WINDOWS,5.01
QMAKE_LFLAGS_CONSOLE += /SUBSYSTEM:CONSOLE,5.01 QMAKE_LFLAGS_CONSOLE += /SUBSYSTEM:CONSOLE,5.01
@@ -49,21 +44,26 @@ QMAKE_CXXFLAGS-=-std=c++11
CONFIG += c++17 CONFIG += c++17
QMAKE_CXXFLAGS+=-std=c++17 QMAKE_CXXFLAGS+=-std=c++17
QMAKE_CXXFLAGS += "-fsanitize=address" !win32 {
QMAKE_LFLAGS += "-fsanitize=address" QMAKE_CXXFLAGS += "-fsanitize=address"
QMAKE_CXXFLAGS_DEBUG += "-fsanitize=address" QMAKE_LFLAGS += "-fsanitize=address"
QMAKE_CXXFLAGS_DEBUG += "-fsanitize=address"
INCLUDEPATH += \ }
$$MEGACMD_BASE_PATH_RELATIVE/sdk/include \
$$MEGACMD_BASE_PATH_RELATIVE/src \
include(../MEGAcmdTest_common/MEGAcmdTest_common.pri) include(../MEGAcmdTest_common/MEGAcmdTest_common.pri)
MEGACMD_BASE_PATH_RELATIVE = ../../../../..
MEGACMD_BASE_PATH = $$PWD/$$MEGACMD_BASE_PATH_RELATIVE
INCLUDEPATH += \
$$MEGACMD_BASE_PATH/sdk/include \
$$MEGACMD_BASE_PATH/src \
SOURCES += \ SOURCES += \
$$MEGACMD_BASE_PATH_RELATIVE/tests/unit/StringUtilsTests.cpp \ $$MEGACMD_BASE_PATH/tests/unit/StringUtilsTests.cpp \
$$MEGACMD_BASE_PATH_RELATIVE/tests/unit/main.cpp $$MEGACMD_BASE_PATH/tests/unit/main.cpp
#Dependencies: #Dependencies:
SOURCES += \ SOURCES += \
$$MEGACMD_BASE_PATH_RELATIVE/src/megacmdcommonutils.cpp $$MEGACMD_BASE_PATH/src/megacmdcommonutils.cpp

View File

@@ -1,34 +1,4 @@
isEmpty(THIRDPARTY_VCPKG_BASE_PATH){ include(../vcpkg_inclusion.pri)
THIRDPARTY_VCPKG_BASE_PATH = $$PWD/../../../../../3rdParty_megacmd
}
win32 {
contains(QMAKE_TARGET.arch, x86_64):VCPKG_TRIPLET = x64-windows-mega
!contains(QMAKE_TARGET.arch, x86_64):VCPKG_TRIPLET = x86-windows-mega
}
macx{
isEmpty(VCPKG_TRIPLET){
contains(QT_ARCH, x86_64):VCPKG_TRIPLET = x64-osx-mega
contains(QT_ARCH, arm64):VCPKG_TRIPLET = arm64-osx-mega
}
contains(VCPKG_TRIPLET, arm64-osx-mega):contains(QMAKE_HOST.arch, arm64):QMAKE_APPLE_DEVICE_ARCHS=arm64
message("Building for macOS $$QT_ARCH in a $$QMAKE_HOST.arch host.")
}
unix:!macx:VCPKG_TRIPLET = x64-linux
message("THIRDPARTY_VCPKG_BASE_PATH: $$THIRDPARTY_VCPKG_BASE_PATH")
message("VCPKG_TRIPLET: $$VCPKG_TRIPLET")
THIRDPARTY_VCPKG_PATH = $$THIRDPARTY_VCPKG_BASE_PATH/vcpkg/installed/$$VCPKG_TRIPLET
exists($$THIRDPARTY_VCPKG_PATH) {
CONFIG += vcpkg
}
vcpkg:debug:message("Building DEBUG with VCPKG 3rdparty at $$THIRDPARTY_VCPKG_PATH")
vcpkg:release:message("Building RELEASE with VCPKG 3rdparty at $$THIRDPARTY_VCPKG_PATH")
!vcpkg:message("vcpkg not used")
CONFIG -= qt CONFIG -= qt
MEGASDK_BASE_PATH = $$PWD/../../../../sdk MEGASDK_BASE_PATH = $$PWD/../../../../sdk

View File

@@ -0,0 +1,51 @@
macx|win32 {
# have VCPKG included if not done already
isEmpty(VCPKG_TRIPLET) {
MEGACMD_BASE_PATH_RELATIVE = ../../..
MEGACMD_BASE_PATH = $$PWD/$$MEGACMD_BASE_PATH_RELATIVE
isEmpty(THIRDPARTY_VCPKG_BASE_PATH){
THIRDPARTY_VCPKG_BASE_PATH = $$MEGACMD_BASE_PATH/../3rdParty_megacmd
}
win32 {
contains(QMAKE_TARGET.arch, x86_64):VCPKG_TRIPLET = x64-windows-mega
!contains(QMAKE_TARGET.arch, x86_64):VCPKG_TRIPLET = x86-windows-mega
}
macx{
isEmpty(VCPKG_TRIPLET){
contains(QT_ARCH, x86_64):VCPKG_TRIPLET = x64-osx-mega
contains(QT_ARCH, arm64):VCPKG_TRIPLET = arm64-osx-mega
}
contains(VCPKG_TRIPLET, arm64-osx-mega):contains(QMAKE_HOST.arch, arm64):QMAKE_APPLE_DEVICE_ARCHS=arm64
message("Building for macOS $$QT_ARCH in a $$QMAKE_HOST.arch host.")
}
unix:!macx:VCPKG_TRIPLET = x64-linux
message("vcpkg inclusion: THIRDPARTY_VCPKG_BASE_PATH: $$THIRDPARTY_VCPKG_BASE_PATH")
message("vcpkg inclusion: VCPKG_TRIPLET: $$VCPKG_TRIPLET")
THIRDPARTY_VCPKG_PATH = $$THIRDPARTY_VCPKG_BASE_PATH/vcpkg/installed/$$VCPKG_TRIPLET
exists($$THIRDPARTY_VCPKG_PATH) {
CONFIG += vcpkg
}
}
else {
message("vcpkg inclusion: REUSING THIRDPARTY_VCPKG_BASE_PATH: $$THIRDPARTY_VCPKG_BASE_PATH")
message("vcpkg inclusion: REUSING VCPKG_TRIPLET: $$VCPKG_TRIPLET")
}
#print vcpkg inclusion status
vcpkg:debug:message("vcpkg inclusion: Building DEBUG with VCPKG 3rdparty at $$THIRDPARTY_VCPKG_PATH")
vcpkg:release:message("vcpkg inclusion: Building RELEASE with VCPKG 3rdparty at $$THIRDPARTY_VCPKG_PATH")
!vcpkg:message("vcpkg inclusion: vcpkg not used")
# Now do the actual includes:
vcpkg:INCLUDEPATH += $$THIRDPARTY_VCPKG_PATH/include
release:LIBS += -L"$$THIRDPARTY_VCPKG_PATH/lib"
debug:LIBS += -L"$$THIRDPARTY_VCPKG_PATH/debug/lib"
} #macx|win32

View File

@@ -31,9 +31,8 @@
using MegaCmdEvent = int; //TODO: instead have MEGAcmd events used using MegaCmdEvent = int; //TODO: instead have MEGAcmd events used
struct InstrumentsException : public std::system_error struct InstrumentsException : public std::exception
{ {
using std::system_error::system_error;
virtual ~InstrumentsException() = default; virtual ~InstrumentsException() = default;
}; };