From 8865f9d7bc6b88e6cde2e2ec53e2f7c0f41561a7 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 23 Sep 2015 21:47:56 +0200 Subject: added cmake build script and a few fixes for 64-bit compatibility --- .gitignore | 4 + CMakeLists.txt | 17 +++ src/CMakeLists.txt | 338 +++++++++++++++++++++++++++++++++++++++++++++++ src/categories.h | 2 +- src/logbuffer.h | 2 +- src/main.cpp | 39 +++--- src/mainwindow.cpp | 4 +- src/modinfodialog.cpp | 2 +- src/shared/inject.cpp | 3 + src/shared/stackdata.cpp | 4 +- 10 files changed, 390 insertions(+), 25 deletions(-) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..815caa9c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +src/moc_*.cpp +src/ui_*.h +src/*.qrc.depends +src/Modorganizer.* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..989eb9d4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +SET(DEPENDENCIES_DIR CACHE PATH "") + +# hint to find qt in dependencies path +FILE(GLOB_RECURSE QT5_FIND_MODULE ${DEPENDENCIES_DIR}/qt5.git/qtbase/bin/qmake.exe) +GET_FILENAME_COMPONENT(QT5_FIND_MODULE ${QT5_FIND_MODULE} DIRECTORY) +GET_FILENAME_COMPONENT(QT5_FIND_MODULE ${QT5_FIND_MODULE} DIRECTORY) +LIST(APPEND CMAKE_PREFIX_PATH ${QT5_FIND_MODULE}/lib/cmake) + +FILE(GLOB_RECURSE BOOST_ROOT ${DEPENDENCIES_DIR}/boost*/project-config.jam) +GET_FILENAME_COMPONENT(BOOST_ROOT ${BOOST_ROOT} DIRECTORY) + +FILE(GLOB_RECURSE ZLIB_ROOT ${DEPENDENCIES_DIR}/zlib*/zlib.h) +GET_FILENAME_COMPONENT(ZLIB_ROOT ${ZLIB_ROOT} DIRECTORY) + +ADD_SUBDIRECTORY(src) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..67b4f196 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,338 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.8) +PROJECT(organizer) + +CMAKE_POLICY(SET CMP0020 NEW) +#CMAKE_POLICY(SET CMP0043 NEW) + +SET(PROJ_AUTHOR Tannin) +SET(PROJ_ARCH x86) +IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(PROJ_ARCH x64) +ENDIF() + +SET(organizer_SRCS + transfersavesdialog.cpp + syncoverwritedialog.cpp + spawn.cpp + singleinstance.cpp + settingsdialog.cpp + settings.cpp + selfupdater.cpp + selectiondialog.cpp + savegameinfowidgetgamebryo.cpp + savegameinfowidget.cpp + savegamegamebryo.cpp + savegame.cpp + queryoverwritedialog.cpp + profilesdialog.cpp + profile.cpp + pluginlistsortproxy.cpp + pluginlist.cpp + overwriteinfodialog.cpp + nxmaccessmanager.cpp + nexusinterface.cpp + motddialog.cpp + modlistsortproxy.cpp + modlist.cpp + modinfodialog.cpp + modinfo.cpp + messagedialog.cpp + mainwindow.cpp + main.cpp + loghighlighter.cpp + logbuffer.cpp + lockeddialog.cpp + loadmechanism.cpp + installationmanager.cpp + helper.cpp + filedialogmemory.cpp + executableslist.cpp + editexecutablesdialog.cpp + downloadmanager.cpp + downloadlistwidgetcompact.cpp + downloadlistwidget.cpp + downloadlistsortproxy.cpp + downloadlist.cpp + directoryrefresher.cpp + credentialsdialog.cpp + categoriesdialog.cpp + categories.cpp + bbcode.cpp + activatemodsdialog.cpp + moapplication.cpp + profileinputdialog.cpp + icondelegate.cpp + gameinfoimpl.cpp + csvbuilder.cpp + savetextasdialog.cpp + qtgroupingproxy.cpp + modlistview.cpp + problemsdialog.cpp + serverinfo.cpp + browserview.cpp + browserdialog.cpp + persistentcookiejar.cpp + noeditdelegate.cpp + previewgenerator.cpp + previewdialog.cpp + aboutdialog.cpp + json.cpp + safewritefile.cpp + modflagicondelegate.cpp + genericicondelegate.cpp + organizerproxy.cpp + viewmarkingscrollbar.cpp + plugincontainer.cpp + organizercore.cpp + + shared/inject.cpp + shared/windows_error.cpp + shared/error_report.cpp + shared/directoryentry.cpp + shared/gameinfo.cpp + shared/oblivioninfo.cpp + shared/fallout3info.cpp + shared/falloutnvinfo.cpp + shared/util.cpp + shared/skyriminfo.cpp + shared/appconfig.cpp + shared/leaktrace.cpp + shared/stackdata.cpp + ) + +SET(organizer_HDRS + transfersavesdialog.h + syncoverwritedialog.h + spawn.h + singleinstance.h + settingsdialog.h + settings.h + selfupdater.h + selectiondialog.h + savegameinfowidgetgamebryo.h + savegameinfowidget.h + savegamegamebyro.h + savegame.h + queryoverwritedialog.h + profilesdialog.h + profile.h + pluginlistsortproxy.h + pluginlist.h + overwriteinfodialog.h + nxmaccessmanager.h + nexusinterface.h + motddialog.h + modlistsortproxy.h + modlist.h + modinfodialog.h + modinfo.h + messagedialog.h + mainwindow.h + loghighlighter.h + logbuffer.h + lockeddialog.h + loadmechanism.h + installationmanager.h + helper.h + filedialogmemory.h + executableslist.h + editexecutablesdialog.h + downloadmanager.h + downloadlistwidgetcompact.h + downloadlistwidget.h + downloadlistsortproxy.h + downloadlist.h + directoryrefresher.h + credentialsdialog.h + categoriesdialog.h + categories.h + bbcode.h + activatemodsdialog.h + moapplication.h + profileinputdialog.h + icondelegate.h + gameinfoimpl.h + csvbuilder.h + savetextasdialog.h + qtgroupingproxy.h + modlistview.h + problemsdialog.h + serverinfo.h + browserview.h + browserdialog.h + persistentcookiejar.h + noeditdelegate.h + previewgenerator.h + previewdialog.h + aboutdialog.h + json.h + safewritefile.h + pdll.h + modflagicondelegate.h + genericicondelegate.h + organizerproxy.h + viewmarkingscrollbar.h + plugincontainer.h + organizercore.h + iuserinterface.h + + shared/inject.h + shared/windows_error.h + shared/error_report.h + shared/directoryentry.h + shared/gameinfo.h + shared/oblivioninfo.h + shared/fallout3info.h + shared/falloutnvinfo.h + shared/util.h + shared/skyriminfo.h + shared/appconfig.h + shared/appconfig.inc + shared/leaktrace.h + shared/stackdata.h + ) + +SET(organizer_UIS + transfersavesdialog.ui + syncoverwritedialog.ui + simpleinstalldialog.ui + settingsdialog.ui + selectiondialog.ui + savegameinfowidget.ui + queryoverwritedialog.ui + profilesdialog.ui + overwriteinfodialog.ui + motddialog.ui + modinfodialog.ui + messagedialog.ui + mainwindow.ui + lockeddialog.ui + installdialog.ui + fomodinstallerdialog.ui + finddialog.ui + editexecutablesdialog.ui + downloadlistwidgetcompact.ui + downloadlistwidget.ui + credentialsdialog.ui + categoriesdialog.ui + baincomplexinstallerdialog.ui + activatemodsdialog.ui + profileinputdialog.ui + savetextasdialog.ui + problemsdialog.ui + previewdialog.ui + browserdialog.ui + aboutdialog.ui + ) + +SET(organizer_QRCS + resources.qrc + stylesheet_resource.qrc + ) + +SET(organizer_RCS + app_icon.rc + #version.rc + ) + + +SOURCE_GROUP(Source FILES ${organizer_SRCS}) +SOURCE_GROUP(Headers FILES ${organizer_HDRS}) +SOURCE_GROUP(UI FILES ${organizer_UIS}) + + +# Qt5 +SET(CMAKE_INCLUDE_CURRENT_DIR ON) +SET(CMAKE_AUTOMOC ON) +SET(CMAKE_AUTOUIC ON) +FIND_PACKAGE(Qt5Widgets REQUIRED) +FIND_PACKAGE(Qt5Declarative REQUIRED) +FIND_PACKAGE(Qt5Network REQUIRED) +FIND_PACKAGE(Qt5WinExtras REQUIRED) +FIND_PACKAGE(Qt5WebKitWidgets REQUIRED) +QT5_WRAP_UI(organizer_UIHDRS ${organizer_UIS}) +QT5_ADD_RESOURCES(organizer_RCCPPS ${organizer_QRCS}) + +INCLUDE_DIRECTORIES(${Qt5Declarative_INCLUDES}) + +ADD_DEFINITIONS(-DQT_MESSAGELOGCONTEXT) + +# Boost +SET(Boost_USE_STATIC_LIBS ON) +SET(Boost_USE_MULTITHREADED ON) +SET(Boost_USE_STATIC_RUNTIME OFF) +FIND_PACKAGE(Boost REQUIRED) + +INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) +LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) + + +FIND_PACKAGE(zlib REQUIRED) +# TODO FindZlib doesn't find the static zlib library + + +# MO projects + +SET(project_path "${CMAKE_SOURCE_DIR}/.." CACHE PATH "path to the other mo projects") + +INCLUDE_DIRECTORIES(${project_path}/uibase/src + ${project_path}/bsatk/src + ${project_path}/esptk/src + ${project_path}/archive/src + ${project_path}/plugin/game_features/src) + +LINK_DIRECTORIES(${project_path}/uibase/src + ${project_path}/esptk/src + ${project_path}/bsatk/src) + + +INCLUDE_DIRECTORIES(shared) +ADD_DEFINITIONS(-D_UNICODE -DUNICODE -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS) + +ADD_EXECUTABLE(ModOrganizer WIN32 ${organizer_HDRS} ${organizer_SRCS} ${organizer_UIHDRS} ${organizer_RCS} ${organizer_RCCPPS}) +TARGET_LINK_LIBRARIES(ModOrganizer + Qt5::Widgets Qt5::WinExtras Qt5::WebKitWidgets + ${Boost_LIBRARIES} + ${ZLIB_LIBRARIES} + uibase esptk bsatk + Dbghelp advapi32 Version Shlwapi) + +SET_TARGET_PROPERTIES(ModOrganizer PROPERTIES COMPILE_FLAGS /GL) +SET_TARGET_PROPERTIES(ModOrganizer PROPERTIES LINK_FLAGS_RELWITHDEBINFO + "/LTCG /INCREMENTAL:NO /LARGEADDRESSAWARE /OPT:REF /OPT:ICF") + + +QT5_USE_MODULES(ModOrganizer Widgets Declarative Network WebkitWidgets) + + +############### +## Installation + +SET(qt5bin ${Qt5Core_DIR}/../../../bin) + +FIND_PROGRAM(WINDEPLOYQT_COMMAND windeployqt PATHS ${qt5bin} NO_DEFAULT_PATH) + +INSTALL(TARGETS ModOrganizer + RUNTIME DESTINATION bin) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ModOrganizer.pdb + DESTINATION pdb) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dlls.manifest.qt5 + DESTINATION bin/dlls + RENAME dlls.manifest) + +# use windeployqt.exe to install all required libraries +SET(windeploy_parameters --no-translations --no-plugins --libdir dlls --release-with-debug-info --no-compiler-runtime) +INSTALL( + CODE + "EXECUTE_PROCESS( + COMMAND + ${qt5bin}/windeployqt.exe ModOrganizer.exe ${windeploy_parameters} + COMMAND + ${qt5bin}/windeployqt.exe uibase.dll ${windeploy_parameters} + WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin + )" +) + +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/stylesheets + ${CMAKE_CURRENT_SOURCE_DIR}/tutorials + DESTINATION bin) diff --git a/src/categories.h b/src/categories.h index f2a5de39..29e794d8 100644 --- a/src/categories.h +++ b/src/categories.h @@ -87,7 +87,7 @@ public: * * @return unsigned int number of categories **/ - unsigned numCategories() const { return m_Categories.size(); } + size_t numCategories() const { return m_Categories.size(); } /** * @brief count all categories that match a specified filter diff --git a/src/logbuffer.h b/src/logbuffer.h index f69d33fa..748aaf31 100644 --- a/src/logbuffer.h +++ b/src/logbuffer.h @@ -91,7 +91,7 @@ private: QString m_OutFileName; bool m_ShutDown; QtMsgType m_MinMsgType; - unsigned int m_NumMessages; + size_t m_NumMessages; std::vector m_Messages; }; diff --git a/src/main.cpp b/src/main.cpp index b83fde33..773bfc16 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,18 +23,6 @@ along with Mod Organizer. If not, see . #include #endif // LEAK_CHECK_WITH_VLD -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #define WIN32_LEAN_AND_MEAN #include #include @@ -64,6 +52,22 @@ along with Mod Organizer. If not, see . #include "tutorialmanager.h" #include "nxmaccessmanager.h" #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -71,10 +75,7 @@ along with Mod Organizer. If not, see . #include #include #include -#include -#include -#include -#include +#include #pragma comment(linker, "/manifestDependency:\"name='dlls' processorArchitecture='x86' version='1.0.0.0' type='win32' \"") @@ -236,10 +237,10 @@ static LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *except return EXCEPTION_EXECUTE_HANDLER; } _snprintf(errorBuffer, errorLen, "failed to save minidump to %ls (error %lu)", - dumpName.c_str(), ::GetLastError()); + dumpName.c_str(), ::GetLastError()); } else { _snprintf(errorBuffer, errorLen, "failed to create %ls (error %lu)", - dumpName.c_str(), ::GetLastError()); + dumpName.c_str(), ::GetLastError()); } } else { return result; @@ -378,7 +379,7 @@ int main(int argc, char *argv[]) LogBuffer::init(100, QtDebugMsg, qApp->property("dataPath").toString() + "/logs/mo_interface.log"); -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= 0x050000 && !defined(QT_NO_SSL) qDebug("ssl support: %d", QSslSocket::supportsSsl()); #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 41ca1589..26ff4b98 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2091,7 +2091,7 @@ void MainWindow::addContentFilters() void MainWindow::addCategoryFilters(QTreeWidgetItem *root, const std::set &categoriesUsed, int targetID) { - for (unsigned i = 1; i < m_CategoryFactory.numCategories(); ++i) { + for (size_t i = 1; i < m_CategoryFactory.numCategories(); ++i) { if ((m_CategoryFactory.getParentID(i) == targetID)) { int categoryID = m_CategoryFactory.getCategoryID(i); if (categoriesUsed.find(categoryID) != categoriesUsed.end()) { @@ -2626,7 +2626,7 @@ bool MainWindow::populateMenuCategories(QMenu *menu, int targetID) bool childEnabled = false; - for (unsigned i = 1; i < m_CategoryFactory.numCategories(); ++i) { + for (size_t i = 1; i < m_CategoryFactory.numCategories(); ++i) { if (m_CategoryFactory.getParentID(i) == targetID) { QMenu *targetMenu = menu; if (m_CategoryFactory.hasChildren(i)) { diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index 5f79a9e2..35da228b 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -348,7 +348,7 @@ void ModInfoDialog::refreshLists() void ModInfoDialog::addCategories(const CategoryFactory &factory, const std::set &enabledCategories, QTreeWidgetItem *root, int rootLevel) { - for (unsigned int i = 0; i < factory.numCategories(); ++i) { + for (size_t i = 0; i < factory.numCategories(); ++i) { if (factory.getParentID(i) != rootLevel) { continue; } diff --git a/src/shared/inject.cpp b/src/shared/inject.cpp index 36db7840..fcd4cfab 100644 --- a/src/shared/inject.cpp +++ b/src/shared/inject.cpp @@ -113,6 +113,8 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll // dizzy yet? we still have to calculate the entry point as an address relative to our stub ULONG entryPoint = 0; + // not implemented on 64 bit systems +#ifdef _X86_ CONTEXT threadContext; threadContext.ContextFlags = CONTEXT_CONTROL; if (::GetThreadContext(threadHandle, &threadContext) == 0) { @@ -139,6 +141,7 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll if (::SetThreadContext(threadHandle, &threadContext) == 0) { throw windows_error("failed to overwrite thread context"); } +#endif } } // namespace MOShared diff --git a/src/shared/stackdata.cpp b/src/shared/stackdata.cpp index 4450756d..6c5a0968 100644 --- a/src/shared/stackdata.cpp +++ b/src/shared/stackdata.cpp @@ -11,7 +11,7 @@ using namespace MOShared; -#ifdef _MSC_VER +#if defined _MSC_VER static void initDbgIfNecess() { @@ -94,6 +94,7 @@ void StackData::load_modules(HANDLE process, DWORD processID) { #pragma warning( disable : 4748 ) void StackData::initTrace() { +#ifdef _X86_ load_modules(::GetCurrentProcess(), ::GetCurrentProcessId()); CONTEXT context; std::memset(&context, 0, sizeof(CONTEXT)); @@ -134,6 +135,7 @@ void StackData::initTrace() { m_Stack[m_Count++] = reinterpret_cast(stackFrame.AddrPC.Offset); } +#endif } -- cgit v1.3.1