mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
Add support for Qt5
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
set(_QSCI_ROOT "${CMAKE_SOURCE_DIR}/third_party/qscintilla")
|
||||
|
||||
# Try to find a pre-built library first
|
||||
find_path(QScintilla_INCLUDE_DIR
|
||||
NAMES Qsci/qsciscintilla.h
|
||||
PATHS "${_QSCI_ROOT}/src" "${_QSCI_ROOT}/include"
|
||||
@@ -7,7 +8,10 @@ find_path(QScintilla_INCLUDE_DIR
|
||||
)
|
||||
|
||||
find_library(QScintilla_LIBRARY
|
||||
NAMES qscintilla2_qt6 libqscintilla2_qt6
|
||||
NAMES
|
||||
qscintilla2_qt${QT_VERSION_MAJOR} libqscintilla2_qt${QT_VERSION_MAJOR}
|
||||
qscintilla2_qt6 libqscintilla2_qt6
|
||||
qscintilla2_qt5 libqscintilla2_qt5
|
||||
PATHS
|
||||
"${_QSCI_ROOT}/src/release"
|
||||
"${_QSCI_ROOT}/src"
|
||||
@@ -15,13 +19,11 @@ find_library(QScintilla_LIBRARY
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(QScintilla DEFAULT_MSG
|
||||
QScintilla_LIBRARY QScintilla_INCLUDE_DIR)
|
||||
|
||||
if(QScintilla_FOUND)
|
||||
set(QScintilla_INCLUDE_DIRS ${QScintilla_INCLUDE_DIR})
|
||||
set(QScintilla_LIBRARIES ${QScintilla_LIBRARY})
|
||||
if(QScintilla_LIBRARY AND QScintilla_INCLUDE_DIR)
|
||||
# Use pre-built library
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(QScintilla DEFAULT_MSG
|
||||
QScintilla_LIBRARY QScintilla_INCLUDE_DIR)
|
||||
if(NOT TARGET QScintilla::QScintilla)
|
||||
add_library(QScintilla::QScintilla STATIC IMPORTED)
|
||||
set_target_properties(QScintilla::QScintilla PROPERTIES
|
||||
@@ -29,4 +31,118 @@ if(QScintilla_FOUND)
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${QScintilla_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
elseif(EXISTS "${_QSCI_ROOT}/src/qsciscintilla.cpp")
|
||||
# Build from source
|
||||
message(STATUS "Building QScintilla from source")
|
||||
|
||||
file(GLOB _QSCI_LEXER_SOURCES "${_QSCI_ROOT}/scintilla/lexers/*.cpp")
|
||||
file(GLOB _QSCI_LEXLIB_SOURCES "${_QSCI_ROOT}/scintilla/lexlib/*.cpp")
|
||||
file(GLOB _QSCI_SCI_SOURCES "${_QSCI_ROOT}/scintilla/src/*.cpp")
|
||||
file(GLOB _QSCI_HEADERS "${_QSCI_ROOT}/src/Qsci/*.h")
|
||||
|
||||
set(_QSCI_QT_SOURCES
|
||||
"${_QSCI_ROOT}/src/qsciscintilla.cpp"
|
||||
"${_QSCI_ROOT}/src/qsciscintillabase.cpp"
|
||||
"${_QSCI_ROOT}/src/qsciabstractapis.cpp"
|
||||
"${_QSCI_ROOT}/src/qsciapis.cpp"
|
||||
"${_QSCI_ROOT}/src/qscicommand.cpp"
|
||||
"${_QSCI_ROOT}/src/qscicommandset.cpp"
|
||||
"${_QSCI_ROOT}/src/qscidocument.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexer.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerasm.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexeravs.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerbash.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerbatch.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexercmake.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexercoffeescript.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexercpp.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexercsharp.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexercss.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexercustom.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerd.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerdiff.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexeredifact.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerfortran.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerfortran77.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerhex.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerhtml.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexeridl.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerintelhex.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerjava.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerjavascript.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerjson.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerlua.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexermakefile.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexermarkdown.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexermasm.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexermatlab.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexernasm.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexeroctave.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerpascal.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerperl.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerpostscript.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerpo.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerpov.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerproperties.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerpython.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerruby.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerspice.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexersql.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexersrec.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexertcl.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexertekhex.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexertex.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerverilog.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexervhdl.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexerxml.cpp"
|
||||
"${_QSCI_ROOT}/src/qscilexeryaml.cpp"
|
||||
"${_QSCI_ROOT}/src/qscimacro.cpp"
|
||||
"${_QSCI_ROOT}/src/qsciprinter.cpp"
|
||||
"${_QSCI_ROOT}/src/qscistyle.cpp"
|
||||
"${_QSCI_ROOT}/src/qscistyledtext.cpp"
|
||||
"${_QSCI_ROOT}/src/InputMethod.cpp"
|
||||
"${_QSCI_ROOT}/src/ListBoxQt.cpp"
|
||||
"${_QSCI_ROOT}/src/PlatQt.cpp"
|
||||
"${_QSCI_ROOT}/src/SciAccessibility.cpp"
|
||||
"${_QSCI_ROOT}/src/SciClasses.cpp"
|
||||
"${_QSCI_ROOT}/src/ScintillaQt.cpp"
|
||||
)
|
||||
|
||||
add_library(qscintilla2 STATIC
|
||||
${_QSCI_QT_SOURCES}
|
||||
${_QSCI_HEADERS}
|
||||
${_QSCI_LEXER_SOURCES}
|
||||
${_QSCI_LEXLIB_SOURCES}
|
||||
${_QSCI_SCI_SOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(qscintilla2 PUBLIC
|
||||
"${_QSCI_ROOT}/src"
|
||||
)
|
||||
target_include_directories(qscintilla2 PRIVATE
|
||||
"${_QSCI_ROOT}/scintilla/include"
|
||||
"${_QSCI_ROOT}/scintilla/lexlib"
|
||||
"${_QSCI_ROOT}/scintilla/src"
|
||||
)
|
||||
|
||||
target_compile_definitions(qscintilla2 PRIVATE
|
||||
SCINTILLA_QT
|
||||
SCI_LEXER
|
||||
INCLUDE_DEPRECATED_FEATURES
|
||||
)
|
||||
|
||||
target_link_libraries(qscintilla2 PUBLIC
|
||||
${QT}::Widgets
|
||||
${QT}::PrintSupport
|
||||
)
|
||||
|
||||
set_target_properties(qscintilla2 PROPERTIES AUTOMOC ON)
|
||||
|
||||
add_library(QScintilla::QScintilla ALIAS qscintilla2)
|
||||
set(QScintilla_FOUND TRUE)
|
||||
else()
|
||||
set(QScintilla_FOUND FALSE)
|
||||
if(QScintilla_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could NOT find QScintilla (missing source and pre-built library)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
36
cmake/FindQt5.cmake
Normal file
36
cmake/FindQt5.cmake
Normal file
@@ -0,0 +1,36 @@
|
||||
# Documentation: https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#find-modules
|
||||
|
||||
# Always try config mode for the requested components (handles repeated calls)
|
||||
find_package(Qt5 COMPONENTS ${Qt5_FIND_COMPONENTS} QUIET CONFIG)
|
||||
|
||||
if(Qt5_FOUND)
|
||||
if(NOT Qt5_FIND_QUIETLY)
|
||||
message(STATUS "Qt5 found: ${Qt5_DIR}")
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(Qt5_FIND_REQUIRED AND WIN32)
|
||||
message(STATUS "Downloading Qt5...")
|
||||
# Fix warnings about DOWNLOAD_EXTRACT_TIMESTAMP
|
||||
if(POLICY CMP0135)
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
endif()
|
||||
include(FetchContent)
|
||||
set(FETCHCONTENT_QUIET OFF)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
FetchContent_Declare(Qt5
|
||||
URL "https://github.com/x64dbg/deps/releases/download/2025.07.02/qt5.12.12-msvc2017_64.7z"
|
||||
URL_HASH SHA256=770490bf09514982c8192ebde9a1fac8821108ba42b021f167bac54e85ada48a
|
||||
)
|
||||
else()
|
||||
FetchContent_Declare(Qt5
|
||||
URL "https://github.com/x64dbg/deps/releases/download/2025.07.02/qt5.12.12-msvc2017.7z"
|
||||
URL_HASH SHA256=3ff2a58e5ed772be475643cd7bb2df3e5499d7169d794ddf1ed5df5c5e862cb6
|
||||
)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(Qt5)
|
||||
unset(FETCHCONTENT_QUIET)
|
||||
set(Qt5_ROOT ${qt5_SOURCE_DIR})
|
||||
find_package(Qt5 COMPONENTS ${Qt5_FIND_COMPONENTS} CONFIG REQUIRED)
|
||||
endif()
|
||||
82
cmake/deploy.cmake
Normal file
82
cmake/deploy.cmake
Normal file
@@ -0,0 +1,82 @@
|
||||
# cmake/deploy.cmake - Dual-mode script for deploying Qt runtime DLLs
|
||||
#
|
||||
# Script mode: cmake -P deploy.cmake <target_exe> <windeployqt>
|
||||
# Include mode: include(deploy) from CMakeLists.txt (creates "deploy" target)
|
||||
|
||||
if(CMAKE_SCRIPT_MODE_FILE)
|
||||
set(TARGET_EXE ${CMAKE_ARGV3})
|
||||
set(WINDEPLOYQT ${CMAKE_ARGV4})
|
||||
get_filename_component(TARGET_DIR ${TARGET_EXE} DIRECTORY)
|
||||
|
||||
# Skip if already deployed for this build
|
||||
if(EXISTS "${TARGET_DIR}/.qt_deployed")
|
||||
return()
|
||||
endif()
|
||||
|
||||
message(STATUS "Running windeployqt on ${TARGET_EXE}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${WINDEPLOYQT}
|
||||
--pdb
|
||||
--no-compiler-runtime
|
||||
--no-translations
|
||||
--no-opengl-sw
|
||||
--no-system-d3d-compiler
|
||||
--force
|
||||
${TARGET_EXE}
|
||||
RESULT_VARIABLE _result
|
||||
)
|
||||
|
||||
if(_result EQUAL 0)
|
||||
file(WRITE "${TARGET_DIR}/.qt_deployed" "")
|
||||
message(STATUS "windeployqt completed successfully")
|
||||
else()
|
||||
message(WARNING "windeployqt failed with exit code ${_result}")
|
||||
endif()
|
||||
|
||||
return()
|
||||
endif()
|
||||
|
||||
# ── Include mode: configure the deploy target ──
|
||||
|
||||
if(NOT WIN32)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Discover windeployqt from qmake
|
||||
if(NOT TARGET ${QT}::windeployqt AND TARGET ${QT}::qmake)
|
||||
get_target_property(_qt_qmake_location ${QT}::qmake IMPORTED_LOCATION)
|
||||
|
||||
execute_process(
|
||||
COMMAND "${_qt_qmake_location}" -query QT_INSTALL_PREFIX
|
||||
RESULT_VARIABLE _return_code
|
||||
OUTPUT_VARIABLE _qt_install_prefix
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
set(_windeployqt "${_qt_install_prefix}/bin/windeployqt.exe")
|
||||
if(EXISTS ${_windeployqt})
|
||||
add_executable(${QT}::windeployqt IMPORTED)
|
||||
set_target_properties(${QT}::windeployqt PROPERTIES
|
||||
IMPORTED_LOCATION ${_windeployqt}
|
||||
)
|
||||
message(STATUS "Found windeployqt: ${_windeployqt}")
|
||||
else()
|
||||
message(WARNING "windeployqt not found at ${_windeployqt}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET ${QT}::windeployqt)
|
||||
add_custom_target(deploy
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/deploy.cmake
|
||||
$<TARGET_FILE:ReclassX>
|
||||
$<TARGET_FILE:${QT}::windeployqt>
|
||||
DEPENDS ReclassX
|
||||
COMMENT "Deploying Qt runtime DLLs..."
|
||||
)
|
||||
|
||||
# Force re-deploy on rebuild
|
||||
set_target_properties(deploy PROPERTIES
|
||||
ADDITIONAL_CLEAN_FILES $<TARGET_FILE_DIR:ReclassX>/.qt_deployed
|
||||
)
|
||||
endif()
|
||||
Reference in New Issue
Block a user