2017-03-30 16:58:57 +00:00
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.1)
|
|
|
|
|
2019-02-28 13:56:54 +00:00
|
|
|
cmake_policy(SET CMP0074 NEW)
|
|
|
|
|
2017-07-17 12:04:32 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
include(DisallowInSource)
|
|
|
|
|
2019-02-18 16:26:24 +00:00
|
|
|
set(CUTTER_PYTHON_MIN 3.5)
|
2019-02-03 15:03:36 +00:00
|
|
|
|
2019-02-23 07:24:31 +00:00
|
|
|
option(CUTTER_ENABLE_PYTHON "Enable Python integration. Requires Python >= ${CUTTER_PYTHON_MIN}." OFF)
|
|
|
|
option(CUTTER_ENABLE_PYTHON_BINDINGS "Enable generating Python bindings with Shiboken2. Unused if CUTTER_ENABLE_PYTHON=OFF." OFF)
|
2018-03-02 13:15:53 +00:00
|
|
|
|
2019-02-11 15:58:32 +00:00
|
|
|
if(NOT CUTTER_ENABLE_PYTHON)
|
|
|
|
set(CUTTER_ENABLE_PYTHON_BINDINGS OFF)
|
|
|
|
endif()
|
|
|
|
|
2018-03-02 13:15:53 +00:00
|
|
|
|
2018-08-26 18:37:11 +00:00
|
|
|
# Parse Cutter.pro to get filenames
|
|
|
|
include(QMakeProParse)
|
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Cutter.pro"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/Cutter.pro"
|
|
|
|
COPYONLY) # trigger reconfigure if Cutter.pro changes
|
|
|
|
parse_qmake_pro("${CMAKE_CURRENT_BINARY_DIR}/Cutter.pro" CUTTER_PRO)
|
|
|
|
set(SOURCE_FILES ${CUTTER_PRO_SOURCES})
|
|
|
|
set(HEADER_FILES ${CUTTER_PRO_HEADERS})
|
|
|
|
set(UI_FILES ${CUTTER_PRO_FORMS})
|
|
|
|
set(QRC_FILES ${CUTTER_PRO_RESOURCES})
|
|
|
|
set(CUTTER_VERSION_MAJOR "${CUTTER_PRO_CUTTER_VERSION_MAJOR}")
|
|
|
|
set(CUTTER_VERSION_MINOR "${CUTTER_PRO_CUTTER_VERSION_MINOR}")
|
|
|
|
set(CUTTER_VERSION_PATCH "${CUTTER_PRO_CUTTER_VERSION_PATCH}")
|
|
|
|
|
|
|
|
set(CUTTER_VERSION_FULL "${CUTTER_VERSION_MAJOR}.${CUTTER_VERSION_MINOR}.${CUTTER_VERSION_PATCH}")
|
|
|
|
|
|
|
|
project(Cutter VERSION "${CUTTER_VERSION_FULL}")
|
|
|
|
|
2017-03-30 16:58:57 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
|
2019-03-10 13:39:13 +00:00
|
|
|
include_directories(core widgets common plugins)
|
2019-02-22 16:50:45 +00:00
|
|
|
|
2017-03-30 16:58:57 +00:00
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
2017-04-09 18:33:33 +00:00
|
|
|
set(CMAKE_AUTOUIC ON)
|
2017-03-30 16:58:57 +00:00
|
|
|
set(CMAKE_AUTORCC ON)
|
2018-09-17 13:12:50 +00:00
|
|
|
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Svg Network)
|
2017-03-30 16:58:57 +00:00
|
|
|
|
2017-03-31 11:28:27 +00:00
|
|
|
|
|
|
|
if(WIN32)
|
2017-03-31 14:52:26 +00:00
|
|
|
# use radare2 libraries from submodule on windows
|
2017-09-25 17:51:49 +00:00
|
|
|
set(CUTTER_WIN32_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../cutter_win32")
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH "${CUTTER_WIN32_DIR}")
|
2017-04-01 09:11:39 +00:00
|
|
|
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64 bit
|
2017-09-25 17:51:49 +00:00
|
|
|
list(APPEND CMAKE_LIBRARY_PATH "${CUTTER_WIN32_DIR}/radare2/lib64")
|
2017-04-01 09:11:39 +00:00
|
|
|
else()
|
2017-09-25 17:51:49 +00:00
|
|
|
list(APPEND CMAKE_LIBRARY_PATH "${CUTTER_WIN32_DIR}/radare2/lib32")
|
2017-04-01 09:11:39 +00:00
|
|
|
endif()
|
|
|
|
|
2017-09-25 17:51:49 +00:00
|
|
|
set(RADARE2_INCLUDE_DIRS "${CUTTER_WIN32_DIR}/radare2/include/libr" "${CUTTER_WIN32_DIR}/include")
|
2017-03-31 11:28:27 +00:00
|
|
|
endif()
|
|
|
|
|
2017-05-05 11:09:38 +00:00
|
|
|
|
|
|
|
find_package(Radare2 REQUIRED)
|
2017-04-25 21:49:10 +00:00
|
|
|
include_directories(${RADARE2_INCLUDE_DIRS})
|
2017-05-05 11:09:38 +00:00
|
|
|
link_directories(${RADARE2_LIBRARY_DIRS})
|
2017-04-25 21:49:10 +00:00
|
|
|
|
2019-02-03 15:03:36 +00:00
|
|
|
if(CUTTER_ENABLE_PYTHON)
|
2019-03-10 13:39:13 +00:00
|
|
|
find_package(PythonLibs ${CUTTER_PYTHON_MIN} REQUIRED)
|
2017-04-25 21:49:10 +00:00
|
|
|
|
2018-03-02 13:15:53 +00:00
|
|
|
include_directories(${PYTHON_INCLUDE_DIRS})
|
2019-02-03 15:03:36 +00:00
|
|
|
add_definitions(-DCUTTER_ENABLE_PYTHON)
|
|
|
|
|
|
|
|
if(CUTTER_ENABLE_PYTHON_BINDINGS)
|
2019-02-11 15:58:32 +00:00
|
|
|
find_package(PythonInterp REQUIRED)
|
2019-03-10 22:21:50 +00:00
|
|
|
find_package(Shiboken2 "${Qt5_VERSION}" REQUIRED)
|
|
|
|
find_package(PySide2 "${Qt5_VERSION}" REQUIRED)
|
2019-03-10 13:39:13 +00:00
|
|
|
|
|
|
|
get_target_property(PYSIDE_INCLUDE_DIR PySide2::pyside2 INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
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)
|
2019-02-13 22:24:22 +00:00
|
|
|
|
2019-02-16 10:23:33 +00:00
|
|
|
add_definitions(-DCUTTER_ENABLE_PYTHON_BINDINGS)
|
2019-02-03 15:03:36 +00:00
|
|
|
endif()
|
2018-03-02 13:15:53 +00:00
|
|
|
endif()
|
2018-02-09 15:48:02 +00:00
|
|
|
|
|
|
|
|
2017-03-31 11:28:27 +00:00
|
|
|
|
2019-02-03 15:03:36 +00:00
|
|
|
message(STATUS "")
|
2018-08-26 18:37:11 +00:00
|
|
|
message(STATUS "Building Cutter version ${CUTTER_VERSION_FULL}")
|
2019-02-03 15:03:36 +00:00
|
|
|
message(STATUS "Options:")
|
|
|
|
message(STATUS "- Python: ${CUTTER_ENABLE_PYTHON}")
|
|
|
|
message(STATUS "- Python Bindings: ${CUTTER_ENABLE_PYTHON_BINDINGS}")
|
|
|
|
message(STATUS "")
|
2017-04-12 15:53:40 +00:00
|
|
|
|
2017-03-30 16:58:57 +00:00
|
|
|
|
2018-08-26 18:37:11 +00:00
|
|
|
include(QMakeConfigureFile)
|
|
|
|
qmake_configure_file("${CMAKE_CURRENT_SOURCE_DIR}/CutterConfig.h.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/CutterConfig.h")
|
2017-03-30 16:58:57 +00:00
|
|
|
|
|
|
|
|
2019-02-11 15:58:32 +00:00
|
|
|
if(CUTTER_ENABLE_PYTHON_BINDINGS)
|
2019-02-11 20:26:11 +00:00
|
|
|
set(BINDINGS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bindings")
|
|
|
|
set(BINDINGS_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/bindings")
|
2019-02-11 15:58:32 +00:00
|
|
|
|
2019-02-11 20:26:11 +00:00
|
|
|
configure_file("${BINDINGS_SRC_DIR}/bindings.xml" "${BINDINGS_BUILD_DIR}/bindings.xml" COPYONLY) # trigger reconfigure if file changes
|
2019-02-03 15:03:36 +00:00
|
|
|
|
2019-02-11 20:26:11 +00:00
|
|
|
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${BINDINGS_SRC_DIR}/src_list.py" cmake "${BINDINGS_BUILD_DIR}" OUTPUT_VARIABLE BINDINGS_SOURCE)
|
2017-03-30 16:58:57 +00:00
|
|
|
|
2019-02-11 15:58:32 +00:00
|
|
|
set_property(SOURCE ${BINDINGS_SOURCE} PROPERTY SKIP_AUTOGEN ON)
|
2019-02-03 15:03:36 +00:00
|
|
|
|
2019-02-11 20:26:11 +00:00
|
|
|
include_directories("${BINDINGS_BUILD_DIR}/CutterBindings")
|
2019-02-11 15:58:32 +00:00
|
|
|
|
|
|
|
add_custom_command(OUTPUT ${BINDINGS_SOURCE}
|
2019-03-10 13:39:13 +00:00
|
|
|
COMMAND Shiboken2::shiboken2 --project-file="${BINDINGS_BUILD_DIR}/bindings.txt"
|
2019-02-11 15:58:32 +00:00
|
|
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/bindings/bindings.xml"
|
|
|
|
IMPLICIT_DEPENDS CXX "${CMAKE_CURRENT_SOURCE_DIR}/bindings/bindings.h"
|
|
|
|
COMMENT "Generating Python bindings with shiboken2")
|
|
|
|
else()
|
|
|
|
set(BINDINGS_SOURCE "")
|
|
|
|
endif()
|
2019-02-03 15:03:36 +00:00
|
|
|
|
|
|
|
|
2019-02-07 16:19:05 +00:00
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
|
|
|
|
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
add_definitions(-Wall -Wextra)
|
|
|
|
set_source_files_properties(${BINDINGS_SOURCE} PROPERTIES COMPILE_FLAGS -w)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2019-03-23 10:47:47 +00:00
|
|
|
add_executable(Cutter MACOSX_BUNDLE ${UI_FILES} ${QRC_FILES} ${SOURCE_FILES} ${HEADER_FILES} ${BINDINGS_SOURCE})
|
|
|
|
set_target_properties(Cutter PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist")
|
2018-05-27 14:38:08 +00:00
|
|
|
|
2018-09-17 13:12:50 +00:00
|
|
|
target_link_libraries(Cutter Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Svg Qt5::Network)
|
2018-03-04 17:42:02 +00:00
|
|
|
target_link_libraries(Cutter ${RADARE2_LIBRARIES})
|
2019-02-03 15:03:36 +00:00
|
|
|
if(CUTTER_ENABLE_PYTHON)
|
2018-03-04 17:42:02 +00:00
|
|
|
target_link_libraries(Cutter ${PYTHON_LIBRARIES})
|
2019-02-03 15:03:36 +00:00
|
|
|
if(CUTTER_ENABLE_PYTHON_BINDINGS)
|
2019-03-10 13:39:13 +00:00
|
|
|
target_link_libraries(Cutter Shiboken2::libshiboken PySide2::pyside2)
|
2019-02-11 15:58:32 +00:00
|
|
|
|
|
|
|
get_target_property(BINDINGS_INCLUDE_DIRS Cutter INCLUDE_DIRECTORIES)
|
2019-03-08 23:01:24 +00:00
|
|
|
if(APPLE AND _qt5Core_install_prefix)
|
|
|
|
list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include")
|
|
|
|
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")
|
|
|
|
endif()
|
|
|
|
list(APPEND BINDINGS_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS})
|
|
|
|
list(APPEND BINDINGS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
|
2019-02-11 15:58:32 +00:00
|
|
|
string(REPLACE ";" ":" BINDINGS_INCLUDE_DIRS "${BINDINGS_INCLUDE_DIRS}")
|
|
|
|
|
2019-02-11 20:26:11 +00:00
|
|
|
qmake_configure_file("${BINDINGS_SRC_DIR}/bindings.txt.in" "${BINDINGS_BUILD_DIR}/bindings.txt")
|
2018-03-02 13:15:53 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2017-04-25 21:49:10 +00:00
|
|
|
|
2019-03-08 23:01:24 +00:00
|
|
|
|