From 61b49bcc671f537a81db437fd2c3d1a3c8ea09a2 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Fri, 16 May 2025 21:05:39 +0200 Subject: [PATCH] chore: fixed qscintilla on windows --- BUILD.md | 1 + cmake/FindQScintilla.cmake | 22 ++++++++++++++++++++++ docs/qscintilla.md | 15 +++++++++++++++ editor/CMakeLists.txt | 7 +++++++ 4 files changed, 45 insertions(+) create mode 100644 docs/qscintilla.md diff --git a/BUILD.md b/BUILD.md index 67afef6..061226a 100644 --- a/BUILD.md +++ b/BUILD.md @@ -22,6 +22,7 @@ The project will be built using VCPKG and MSVC * Qt 6.8.3 or higher, with MSVC toolchain * CMake * Git (for cloning the repo, optional) +* QScintilla already built (see [docs/qscintilla.md](./docs/qscintilla.md)) *\*likely temporary\** To start, clone the repository: diff --git a/cmake/FindQScintilla.cmake b/cmake/FindQScintilla.cmake index d464d1d..b1f187d 100644 --- a/cmake/FindQScintilla.cmake +++ b/cmake/FindQScintilla.cmake @@ -1,5 +1,12 @@ # Modified from QGIS' FindQScintilla.cmake by Thomas Moenicke, Larry Schaffer +add_library(QScintilla::QScintilla UNKNOWN IMPORTED) + +### NECESSARY TO PREVENT staticMetaObject ERROR!!! See qscintilla.prf AKA qmake config +if(WIN32) + add_compile_definitions(QSCINTILLA_DLL) +endif() + FIND_PATH(QSCINTILLA_INCLUDE_DIR NAMES Qsci/qsciglobal.h PATHS @@ -7,6 +14,7 @@ FIND_PATH(QSCINTILLA_INCLUDE_DIR $ENV{LIB_DIR}/include /usr/local/include /usr/include + ${VCPKG_INSTALLED_DIR}/x64-windows/include PATH_SUFFIXES ${QSCINTILLA_PATH_SUFFIXES} ) @@ -29,4 +37,18 @@ PATHS /usr/local/lib /usr/local/lib/qt${QT_VERSION_MAJOR} /usr/lib + ${VCPKG_INSTALLED_DIR}/x64-windows/lib +) + +list(TRANSFORM QSCINTILLA_LIBRARY_NAMES APPEND ".dll" OUTPUT_VARIABLE QSCINTILLA_DLL_NAMES) + +find_file(QSCINTILLA_DLLS +NAMES ${QSCINTILLA_DLL_NAMES} +PATHS + "${QT_LIBRARY_DIR}" + $ENV{LIB_DIR}/lib + /usr/local/lib + /usr/local/lib/qt${QT_VERSION_MAJOR} + /usr/lib + ${VCPKG_INSTALLED_DIR}/x64-windows/lib ) \ No newline at end of file diff --git a/docs/qscintilla.md b/docs/qscintilla.md new file mode 100644 index 0000000..70ca8e0 --- /dev/null +++ b/docs/qscintilla.md @@ -0,0 +1,15 @@ +In order to build openblocks on Windows, qscintilla will need to already be installed. + +To do this, first download the source archive from [`https://www.riverbankcomputing.com/static/Downloads/QScintilla/2.14.1/QScintilla_src-2.14.1.tar.gz`](https://www.riverbankcomputing.com/static/Downloads/QScintilla/2.14.1/QScintilla_src-2.14.1.tar.gz) + +Next, launch the *x64 Native Tools Command Prompt for VS 2022*, and cd into the directory that you extracted the archive to + +Now, run `qmake` from your Qt's bin directory to configure it + +Once that's done, build and install the project using `nmake install` + +The library should now automatically be installed into your Qt installed directory + +--- + +To uninstall the library, run `nmake uninstall` \ No newline at end of file diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 83b0b25..fa76857 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -100,6 +100,13 @@ if (WIN32) # No sense adding opengl-sw given that hardware acceleration is necessary, anyway # Also don't want to clutter with plugins, add only needed ones + # Copy over QScintilla DLLs + # TODO: Use a better approach? + add_custom_command( + TARGET editor POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${QSCINTILLA_DLLS} $ + ) + # Copy qt.conf to override default plugins location add_custom_command( TARGET editor POST_BUILD