2020-12-02 17:53:17 +00:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
|
|
|
|
|
|
|
if(POLICY CMP0074)
|
|
|
|
cmake_policy(SET CMP0074 NEW)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
include(DisallowInSource)
|
|
|
|
include(Utils)
|
|
|
|
|
|
|
|
set(CUTTER_PYTHON_MIN 3.5)
|
|
|
|
|
2021-03-15 04:47:51 +00:00
|
|
|
option(CUTTER_USE_BUNDLED_RIZIN "Use rizin from ./rizin submodule instead of searching for it on the system" ON)
|
2020-12-02 17:53:17 +00:00
|
|
|
option(CUTTER_USE_ADDITIONAL_RIZIN_PATHS "Search rizin in additional paths which are not part of default system library paths.\
|
|
|
|
Disable this option if you are linking against rizin pacakged as proper system library or in a custom path and additional are paths causing problems." ON)
|
|
|
|
option(CUTTER_ENABLE_PYTHON "Enable Python integration. Requires Python >= ${CUTTER_PYTHON_MIN}." OFF)
|
2022-05-29 08:41:54 +00:00
|
|
|
option(CUTTER_ENABLE_PYTHON_BINDINGS "Enable generating Python bindings with Shiboken. Unused if CUTTER_ENABLE_PYTHON=OFF." OFF)
|
2020-12-02 17:53:17 +00:00
|
|
|
option(CUTTER_APPIMAGE_BUILD "Enable Appimage specific changes. Doesn't cause building of Appimage itself." OFF)
|
|
|
|
tri_option(CUTTER_ENABLE_KSYNTAXHIGHLIGHTING "Use KSyntaxHighlighting" AUTO)
|
|
|
|
tri_option(CUTTER_ENABLE_GRAPHVIZ "Enable use of graphviz for graph layout" AUTO)
|
|
|
|
set(SHIBOKEN_EXTRA_OPTIONS "" CACHE STRING "Extra options for shiboken generator")
|
|
|
|
set(CUTTER_EXTRA_PLUGIN_DIRS "" CACHE STRING "List of addition plugin locations")
|
|
|
|
option(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS "Enable downloading of dependencies. Setting to OFF doesn't affect any downloads done by rizin build." OFF)
|
|
|
|
option(CUTTER_ENABLE_PACKAGING "Enable building platform-specific packages for distributing" OFF)
|
2022-06-06 09:27:13 +00:00
|
|
|
option(CUTTER_ENABLE_SIGDB "Downloads and installs sigdb (only available when CUTTER_USE_BUNDLED_RIZIN=ON)." OFF)
|
2020-12-02 17:53:17 +00:00
|
|
|
option(CUTTER_PACKAGE_DEPENDENCIES "During install step include the third party dependencies." OFF)
|
|
|
|
option(CUTTER_PACKAGE_RZ_GHIDRA "Compile and install rz-ghidra during install step." OFF)
|
2023-02-22 01:06:32 +00:00
|
|
|
option(CUTTER_PACKAGE_RZ_LIBSWIFT "Compile and install rz-libswift demangler during the install step." OFF)
|
|
|
|
option(CUTTER_PACKAGE_RZ_LIBYARA "Compile and install rz-libyara during the install step." OFF)
|
2023-04-11 03:35:52 +00:00
|
|
|
option(CUTTER_PACKAGE_RZ_SILHOUETTE "Compile and install rz-silhouette during the install step." OFF)
|
2021-01-16 10:48:31 +00:00
|
|
|
option(CUTTER_PACKAGE_JSDEC "Compile and install jsdec during install step." OFF)
|
2020-12-02 17:53:17 +00:00
|
|
|
OPTION(CUTTER_QT6 "Use QT6" OFF)
|
|
|
|
|
|
|
|
if(NOT CUTTER_ENABLE_PYTHON)
|
|
|
|
set(CUTTER_ENABLE_PYTHON_BINDINGS OFF)
|
|
|
|
endif()
|
|
|
|
|
2021-03-27 14:58:31 +00:00
|
|
|
set(CUTTER_VERSION_MAJOR 2)
|
2023-02-21 16:00:00 +00:00
|
|
|
set(CUTTER_VERSION_MINOR 2)
|
|
|
|
set(CUTTER_VERSION_PATCH 0)
|
2020-12-02 17:53:17 +00:00
|
|
|
|
2023-02-07 17:04:14 +00:00
|
|
|
set(CUTTER_VERSION "${CUTTER_VERSION_MAJOR}.${CUTTER_VERSION_MINOR}.${CUTTER_VERSION_PATCH}")
|
2020-12-02 17:53:17 +00:00
|
|
|
|
2023-02-07 17:04:14 +00:00
|
|
|
execute_process(COMMAND git log --pretty=format:'%h' -n 1
|
|
|
|
OUTPUT_VARIABLE GIT_REV
|
|
|
|
ERROR_QUIET)
|
|
|
|
|
|
|
|
# Check whether we got any revision (which isn't
|
|
|
|
# always the case, e.g. when someone downloaded a zip file
|
|
|
|
if ("${GIT_REV}" STREQUAL "")
|
|
|
|
set(CUTTER_VERSION_FULL "${CUTTER_VERSION}")
|
|
|
|
else()
|
|
|
|
execute_process(
|
|
|
|
COMMAND git rev-parse --abbrev-ref HEAD
|
|
|
|
OUTPUT_VARIABLE GIT_BRANCH)
|
|
|
|
string(STRIP "${GIT_REV}" GIT_REV)
|
|
|
|
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
|
|
|
|
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
|
|
|
|
set(CUTTER_VERSION_FULL "${CUTTER_VERSION}-${GIT_BRANCH}-${GIT_REV}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
project(Cutter VERSION "${CUTTER_VERSION}")
|
2020-12-02 17:53:17 +00:00
|
|
|
|
2022-10-23 11:40:26 +00:00
|
|
|
# Enable solution folder support
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
|
|
|
# Put Qt files in a separate folder
|
|
|
|
set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "Generated Files")
|
|
|
|
|
2020-12-02 17:53:17 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
|
|
|
|
include(CutterInstallDirs)
|
|
|
|
|
|
|
|
if(CUTTER_USE_BUNDLED_RIZIN)
|
|
|
|
include(BundledRizin)
|
|
|
|
set(RIZIN_TARGET Rizin)
|
|
|
|
else()
|
2021-12-22 08:57:58 +00:00
|
|
|
find_package(Rizin COMPONENTS Core REQUIRED)
|
|
|
|
set(RIZIN_TARGET Rizin::Core)
|
2020-12-02 17:53:17 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
2022-03-31 10:49:37 +00:00
|
|
|
set(QT_COMPONENTS Core Widgets Gui Svg Network)
|
2020-12-02 17:53:17 +00:00
|
|
|
if (CUTTER_QT6)
|
|
|
|
set(QT_PREFIX Qt6)
|
2022-03-31 10:49:37 +00:00
|
|
|
list(APPEND QT_COMPONENTS Core5Compat SvgWidgets OpenGLWidgets)
|
2020-12-02 17:53:17 +00:00
|
|
|
else()
|
|
|
|
set(QT_PREFIX Qt5)
|
|
|
|
endif()
|
2022-03-31 10:49:37 +00:00
|
|
|
find_package(${QT_PREFIX} REQUIRED COMPONENTS ${QT_COMPONENTS})
|
2020-12-02 17:53:17 +00:00
|
|
|
|
|
|
|
if(CUTTER_ENABLE_PYTHON)
|
|
|
|
find_package(PythonInterp REQUIRED)
|
|
|
|
find_package(PythonLibs ${CUTTER_PYTHON_MIN} REQUIRED)
|
|
|
|
|
|
|
|
include_directories(${PYTHON_INCLUDE_DIRS})
|
|
|
|
add_definitions(-DCUTTER_ENABLE_PYTHON)
|
|
|
|
|
|
|
|
if(CUTTER_ENABLE_PYTHON_BINDINGS)
|
2022-05-29 08:41:54 +00:00
|
|
|
if (CUTTER_QT6)
|
|
|
|
# 6.12.3 => 6.12
|
|
|
|
if("${Qt6_VERSION}" MATCHES "^([0-9]+\\.[0-9]+)\\.[0-9]+")
|
|
|
|
set(Shiboken6_VERSION_REQUIRED "${CMAKE_MATCH_1}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Failed to recognize Qt version")
|
|
|
|
endif()
|
|
|
|
find_package(Shiboken6 "${Shiboken6_VERSION_REQUIRED}" REQUIRED)
|
|
|
|
find_package(Shiboken6Tools "${Shiboken6_VERSION_REQUIRED}" REQUIRED)
|
|
|
|
find_package(PySide6 "${Shiboken6_VERSION_REQUIRED}" REQUIRED)
|
2023-02-16 04:43:03 +00:00
|
|
|
get_target_property(LIBSHIBOKEN_INCLUDE_DIRS Shiboken6::libshiboken INTERFACE_INCLUDE_DIRECTORIES)
|
2022-05-29 08:41:54 +00:00
|
|
|
get_target_property(PYSIDE_INCLUDE_DIR PySide6::pyside6 INTERFACE_INCLUDE_DIRECTORIES)
|
2023-02-16 04:42:32 +00:00
|
|
|
# Check the presence of "pysidecleanup.h"
|
2023-02-16 04:43:03 +00:00
|
|
|
include(CheckIncludeFileCXX)
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES "${PYSIDE_INCLUDE_DIR};${LIBSHIBOKEN_INCLUDE_DIRS}")
|
2023-02-16 04:42:32 +00:00
|
|
|
CHECK_INCLUDE_FILE_CXX("pysidecleanup.h" HAVE_PYSIDECLEANUP)
|
2023-02-16 04:43:03 +00:00
|
|
|
add_compile_definitions("HAVE_PYSIDECLEANUP=${HAVE_PYSIDECLEANUP}")
|
2020-12-02 17:53:17 +00:00
|
|
|
else()
|
2022-05-29 08:41:54 +00:00
|
|
|
# 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_DIR PySide2::pyside2 INTERFACE_INCLUDE_DIRECTORIES)
|
2020-12-02 17:53:17 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
list(GET PYSIDE_INCLUDE_DIR 0 PYSIDE_INCLUDE_DIR)
|
|
|
|
include_directories(${PYSIDE_INCLUDE_DIR}
|
|
|
|
${PYSIDE_INCLUDE_DIR}/QtCore
|
|
|
|
${PYSIDE_INCLUDE_DIR}/QtGui
|
|
|
|
${PYSIDE_INCLUDE_DIR}/QtWidgets)
|
|
|
|
|
|
|
|
add_definitions(-DCUTTER_ENABLE_PYTHON_BINDINGS)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CUTTER_ENABLE_KSYNTAXHIGHLIGHTING)
|
|
|
|
if(CUTTER_ENABLE_KSYNTAXHIGHLIGHTING STREQUAL AUTO)
|
|
|
|
find_package(KF5SyntaxHighlighting)
|
|
|
|
if(KF5SyntaxHighlighting_FOUND)
|
|
|
|
set(KSYNTAXHIGHLIGHTING_STATUS ON)
|
|
|
|
else()
|
|
|
|
set(KSYNTAXHIGHLIGHTING_STATUS "OFF (KSyntaxHighlighting not found)")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
find_package(KF5SyntaxHighlighting REQUIRED)
|
|
|
|
set(KSYNTAXHIGHLIGHTING_STATUS ON)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(KSYNTAXHIGHLIGHTING_STATUS OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CUTTER_ENABLE_GRAPHVIZ)
|
|
|
|
if (CUTTER_ENABLE_GRAPHVIZ STREQUAL AUTO)
|
|
|
|
find_package(Graphviz)
|
|
|
|
else()
|
|
|
|
find_package(Graphviz REQUIRED)
|
|
|
|
endif()
|
|
|
|
set (CUTTER_ENABLE_GRAPHVIZ ${Graphviz_FOUND})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "")
|
|
|
|
message(STATUS "Building Cutter version ${CUTTER_VERSION_FULL}")
|
|
|
|
message(STATUS "Options:")
|
|
|
|
message(STATUS "- Bundled rizin: ${CUTTER_USE_BUNDLED_RIZIN}")
|
2022-06-06 09:27:13 +00:00
|
|
|
if(CUTTER_USE_BUNDLED_RIZIN)
|
|
|
|
message(STATUS "- Bundled sigdb: ${CUTTER_ENABLE_SIGDB}")
|
|
|
|
endif()
|
2020-12-02 17:53:17 +00:00
|
|
|
message(STATUS "- Python: ${CUTTER_ENABLE_PYTHON}")
|
|
|
|
message(STATUS "- Python Bindings: ${CUTTER_ENABLE_PYTHON_BINDINGS}")
|
|
|
|
message(STATUS "- KSyntaxHighlighting: ${KSYNTAXHIGHLIGHTING_STATUS}")
|
|
|
|
message(STATUS "- Graphviz: ${CUTTER_ENABLE_GRAPHVIZ}")
|
2022-06-07 23:18:43 +00:00
|
|
|
message(STATUS "- Downloads dependencies: ${CUTTER_ENABLE_DEPENDENCY_DOWNLOADS}")
|
|
|
|
message(STATUS "- Enable Packaging: ${CUTTER_ENABLE_PACKAGING}")
|
|
|
|
message(STATUS "- Package Dependencies: ${CUTTER_PACKAGE_DEPENDENCIES}")
|
|
|
|
message(STATUS "- Package RzGhidra: ${CUTTER_PACKAGE_RZ_GHIDRA}")
|
|
|
|
message(STATUS "- Package RzLibSwift: ${CUTTER_PACKAGE_RZ_LIBSWIFT}")
|
|
|
|
message(STATUS "- Package RzLibYara: ${CUTTER_PACKAGE_RZ_LIBYARA}")
|
2023-04-11 03:35:52 +00:00
|
|
|
message(STATUS "- Package RzSilhouette: ${CUTTER_PACKAGE_RZ_SILHOUETTE}")
|
2022-06-07 23:18:43 +00:00
|
|
|
message(STATUS "- Package JSDec: ${CUTTER_PACKAGE_JSDEC}")
|
|
|
|
message(STATUS "- QT6: ${CUTTER_QT6}")
|
2020-12-02 17:53:17 +00:00
|
|
|
message(STATUS "")
|
|
|
|
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
|
|
if(CUTTER_ENABLE_PACKAGING)
|
|
|
|
add_subdirectory(dist)
|
|
|
|
endif()
|