diff --git a/CMakeLists.txt b/CMakeLists.txt index 771bddf13..66767cddf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(DisallowInSource) include(Utils) -set(CUTTER_PYTHON_MIN 3.5) +set(CUTTER_PYTHON_MIN 3.8) option(CUTTER_USE_BUNDLED_RIZIN "Use rizin from ./rizin submodule instead of searching for it on the system" ON) option(CUTTER_USE_ADDITIONAL_RIZIN_PATHS "Search rizin in additional paths which are not part of default system library paths.\ @@ -29,7 +29,7 @@ option(CUTTER_PACKAGE_RZ_LIBSWIFT "Compile and install rz-libswift demangler dur option(CUTTER_PACKAGE_RZ_LIBYARA "Compile and install rz-libyara during the install step." OFF) option(CUTTER_PACKAGE_RZ_SILHOUETTE "Compile and install rz-silhouette during the install step." OFF) option(CUTTER_PACKAGE_JSDEC "Compile and install jsdec during install step." OFF) -OPTION(CUTTER_QT6 "Use QT6" OFF) +OPTION(CUTTER_QT5 "Use QT5" OFF) if(NOT CUTTER_ENABLE_PYTHON) set(CUTTER_ENABLE_PYTHON_BINDINGS OFF) @@ -84,11 +84,11 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) set(QT_COMPONENTS Core Widgets Gui Svg Network) -if (CUTTER_QT6) +if (CUTTER_QT5) + set(QT_PREFIX Qt5) +else() set(QT_PREFIX Qt6) list(APPEND QT_COMPONENTS Core5Compat SvgWidgets OpenGLWidgets) -else() - set(QT_PREFIX Qt5) endif() find_package(${QT_PREFIX} REQUIRED COMPONENTS ${QT_COMPONENTS}) @@ -100,7 +100,17 @@ if(CUTTER_ENABLE_PYTHON) add_definitions(-DCUTTER_ENABLE_PYTHON) if(CUTTER_ENABLE_PYTHON_BINDINGS) - if (CUTTER_QT6) + if (CUTTER_QT5) + # 5.12.3 => 5.12 + if("${Qt5_VERSION}" MATCHES "^([0-9]+\\.[0-9]+)\\.[0-9]+") + set(Shiboken2_VERSION_REQUIRED "${CMAKE_MATCH_1}") + else() + message(FATAL_ERROR "Failed to recognize Qt version") + endif() + find_package(Shiboken2 "${Shiboken2_VERSION_REQUIRED}" REQUIRED) + find_package(PySide2 "${Shiboken2_VERSION_REQUIRED}" REQUIRED) + get_target_property(PYSIDE_INCLUDE_DIRS PySide2::pyside2 INTERFACE_INCLUDE_DIRECTORIES) + else() # 6.12.3 => 6.12 if("${Qt6_VERSION}" MATCHES "^([0-9]+\\.[0-9]+)\\.[0-9]+") set(Shiboken6_VERSION_REQUIRED "${CMAKE_MATCH_1}") @@ -117,16 +127,6 @@ if(CUTTER_ENABLE_PYTHON) set(CMAKE_REQUIRED_INCLUDES "${PYSIDE_INCLUDE_DIRS};${LIBSHIBOKEN_INCLUDE_DIRS}") CHECK_INCLUDE_FILE_CXX("pysidecleanup.h" HAVE_PYSIDECLEANUP) add_compile_definitions("HAVE_PYSIDECLEANUP=${HAVE_PYSIDECLEANUP}") - else() - # 5.12.3 => 5.12 - if("${Qt5_VERSION}" MATCHES "^([0-9]+\\.[0-9]+)\\.[0-9]+") - set(Shiboken2_VERSION_REQUIRED "${CMAKE_MATCH_1}") - else() - message(FATAL_ERROR "Failed to recognize Qt version") - endif() - find_package(Shiboken2 "${Shiboken2_VERSION_REQUIRED}" REQUIRED) - find_package(PySide2 "${Shiboken2_VERSION_REQUIRED}" REQUIRED) - get_target_property(PYSIDE_INCLUDE_DIRS PySide2::pyside2 INTERFACE_INCLUDE_DIRECTORIES) endif() foreach(_dir IN LISTS PYSIDE_INCLUDE_DIRS) @@ -140,7 +140,7 @@ if(CUTTER_ENABLE_PYTHON) endif() endif() -if(CUTTER_ENABLE_KSYNTAXHIGHLIGHTING AND (NOT CUTTER_QT6)) +if(CUTTER_ENABLE_KSYNTAXHIGHLIGHTING AND CUTTER_QT5) if(CUTTER_ENABLE_KSYNTAXHIGHLIGHTING STREQUAL AUTO) find_package(KF5SyntaxHighlighting) if(KF5SyntaxHighlighting_FOUND) @@ -153,7 +153,7 @@ if(CUTTER_ENABLE_KSYNTAXHIGHLIGHTING AND (NOT CUTTER_QT6)) set(KSYNTAXHIGHLIGHTING_STATUS ON) endif() else() - if(CUTTER_ENABLE_KSYNTAXHIGHLIGHTING AND CUTTER_QT6) + if(CUTTER_ENABLE_KSYNTAXHIGHLIGHTING AND (NOT CUTTER_QT5)) message(WARNING "KSyntaxHighlighting has been disabled because not supported in QT6") endif() set(KSYNTAXHIGHLIGHTING_STATUS OFF) @@ -187,7 +187,7 @@ message(STATUS "- Package RzLibSwift: ${CUTTER_PACKAGE_RZ_LIBSWIFT}") message(STATUS "- Package RzLibYara: ${CUTTER_PACKAGE_RZ_LIBYARA}") message(STATUS "- Package RzSilhouette: ${CUTTER_PACKAGE_RZ_SILHOUETTE}") message(STATUS "- Package JSDec: ${CUTTER_PACKAGE_JSDEC}") -message(STATUS "- QT6: ${CUTTER_QT6}") +message(STATUS "- QT5: ${CUTTER_QT5}") message(STATUS "") add_subdirectory(src) diff --git a/cmake/Translations.cmake b/cmake/Translations.cmake index a57a87978..7913af8fb 100644 --- a/cmake/Translations.cmake +++ b/cmake/Translations.cmake @@ -24,12 +24,12 @@ set(TS_FILES # translations/pt-BR/cutter_pt.ts #2321 handling multiple versions of a language set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translations) -if (CUTTER_QT6) - find_package(Qt6LinguistTools REQUIRED) - qt6_add_translation(qmFiles ${TS_FILES}) -else() +if (CUTTER_QT5) find_package(Qt5LinguistTools REQUIRED) qt5_add_translation(qmFiles ${TS_FILES}) +else() + find_package(Qt6LinguistTools REQUIRED) + qt6_add_translation(qmFiles ${TS_FILES}) endif() add_custom_target(translations ALL DEPENDS ${qmFiles} SOURCES ${TS_FILES}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad69522ee..1173cb4f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -410,12 +410,12 @@ if (CUTTER_ENABLE_PYTHON) endif() if(CUTTER_ENABLE_PYTHON_BINDINGS) - if (CUTTER_QT6) - set(PYSIDE_NAME PySide6) - set(SHIBOKEN_COMMAND Shiboken6::shiboken6) - else() + if (CUTTER_QT5) set(PYSIDE_NAME PySide2) set(SHIBOKEN_COMMAND Shiboken2::shiboken2) + else() + set(PYSIDE_NAME PySide6) + set(SHIBOKEN_COMMAND Shiboken6::shiboken6) endif() set(BINDINGS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bindings") @@ -491,7 +491,7 @@ if (TARGET Graphviz::GVC) endif() target_link_libraries(Cutter PUBLIC ${QT_PREFIX}::Core ${QT_PREFIX}::Widgets ${QT_PREFIX}::Gui PRIVATE ${QT_PREFIX}::Svg ${QT_PREFIX}::Network) -if (CUTTER_QT6) +if (NOT CUTTER_QT5) target_link_libraries(Cutter PUBLIC Qt6::Core5Compat Qt6::SvgWidgets) target_link_libraries(Cutter PRIVATE Qt6::OpenGLWidgets) endif() @@ -512,10 +512,10 @@ if(CUTTER_ENABLE_PYTHON) endif() target_link_libraries(Cutter PRIVATE ${PYTHON_LIBRARIES}) if(CUTTER_ENABLE_PYTHON_BINDINGS) - if (CUTTER_QT6) - target_link_libraries(Cutter PRIVATE Shiboken6::libshiboken PySide6::pyside6) - else() + if (CUTTER_QT5) target_link_libraries(Cutter PRIVATE Shiboken2::libshiboken PySide2::pyside2) + else() + target_link_libraries(Cutter PRIVATE Shiboken6::libshiboken PySide6::pyside6) endif() get_target_property(RAW_BINDINGS_INCLUDE_DIRS Cutter INCLUDE_DIRECTORIES) @@ -539,14 +539,14 @@ if(CUTTER_ENABLE_PYTHON) list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtCore") list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtGui") list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtWidgets") - elseif(CUTTER_QT6) + elseif(NOT CUTTER_QT5) string(APPEND BINDINGS_INCLUDE_DIR_LINES "framework-include-path=${QT6_INSTALL_PREFIX}/${QT6_INSTALL_LIBS}\n") endif() endif() - if (CUTTER_QT6) - list(APPEND BINDINGS_INCLUDE_DIRS ${Qt6Core_INCLUDE_DIRS} ${Qt6Widgets_INCLUDE_DIRS} ${Qt6Gui_INCLUDE_DIRS}) - else() + if (CUTTER_QT5) list(APPEND BINDINGS_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS}) + else() + list(APPEND BINDINGS_INCLUDE_DIRS ${Qt6Core_INCLUDE_DIRS} ${Qt6Widgets_INCLUDE_DIRS} ${Qt6Gui_INCLUDE_DIRS}) endif() list(APPEND BINDINGS_INCLUDE_DIRS ${Rizin_INCLUDE_DIRS}) list(APPEND BINDINGS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")