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
|
|
|
|
2020-08-30 20:23:41 +00:00
|
|
|
set(SHIBOKEN_OPTIONS)
|
|
|
|
if (WIN32)
|
|
|
|
list(APPEND SHIBOKEN_OPTIONS --avoid-protected-hack)
|
|
|
|
endif()
|
|
|
|
|
2019-02-11 15:58:32 +00:00
|
|
|
add_custom_command(OUTPUT ${BINDINGS_SOURCE}
|
2020-08-30 20:23:41 +00:00
|
|
|
COMMAND Shiboken2::shiboken2 --project-file="${BINDINGS_BUILD_DIR}/bindings.txt" ${SHIBOKEN_OPTIONS} ${SHIBOKEN_EXTRA_OPTIONS}
|
2019-05-13 11:55:02 +00:00
|
|
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/bindings/bindings.xml" "${BINDINGS_BUILD_DIR}/bindings.txt"
|
2019-02-11 15:58:32 +00:00
|
|
|
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-10-06 17:35:44 +00:00
|
|
|
if (TARGET Graphviz::GVC)
|
2019-08-03 13:10:44 +00:00
|
|
|
list(APPEND SOURCE_FILES ${CUTTER_PRO_GRAPHVIZ_SOURCES})
|
|
|
|
list(APPEND HEADER_FILES ${CUTTER_PRO_GRAPHVIZ_HEADERS})
|
|
|
|
endif()
|
|
|
|
|
2020-10-10 10:52:56 +00:00
|
|
|
if (WIN32)
|
|
|
|
set(PLATFORM_RESOURCES "img/cutter.rc")
|
|
|
|
else()
|
|
|
|
set(PLATFORM_RESOURCES "")
|
|
|
|
endif()
|
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()
|
|
|
|
|
|
|
|
|
2020-12-06 18:00:13 +00:00
|
|
|
add_executable(Cutter ${UI_FILES} ${QRC_FILES} ${PLATFORM_RESOURCES} ${SOURCE_FILES} ${HEADER_FILES} ${BINDINGS_SOURCE})
|
2019-10-09 16:41:16 +00:00
|
|
|
set_target_properties(Cutter PROPERTIES
|
2020-12-02 17:53:17 +00:00
|
|
|
RUNTIME_OUTPUT_DIRECTORY ..
|
|
|
|
PDB_OUTPUT_DIRECTORY ..
|
2019-10-09 16:41:16 +00:00
|
|
|
ENABLE_EXPORTS ON
|
2020-12-06 18:00:13 +00:00
|
|
|
CXX_VISIBILITY_PRESET hidden)
|
2020-03-15 13:43:42 +00:00
|
|
|
target_compile_definitions(Cutter PRIVATE CUTTER_SOURCE_BUILD)
|
|
|
|
|
|
|
|
set(CUTTER_INCLUDE_DIRECTORIES core widgets common plugins menus .)
|
|
|
|
foreach(_dir ${CUTTER_INCLUDE_DIRECTORIES})
|
|
|
|
target_include_directories(Cutter PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${_dir}>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cutter/${_dir}>
|
|
|
|
)
|
|
|
|
endforeach()
|
2018-05-27 14:38:08 +00:00
|
|
|
|
2019-10-06 17:35:44 +00:00
|
|
|
if (TARGET Graphviz::GVC)
|
2020-03-15 13:43:42 +00:00
|
|
|
target_link_libraries(Cutter PRIVATE Graphviz::GVC)
|
2019-08-03 13:10:44 +00:00
|
|
|
target_compile_definitions(Cutter PRIVATE CUTTER_ENABLE_GRAPHVIZ)
|
|
|
|
endif()
|
|
|
|
|
2019-04-09 07:44:44 +00:00
|
|
|
if(CUTTER_ENABLE_CRASH_REPORTS)
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
2020-03-15 13:43:42 +00:00
|
|
|
target_link_libraries(Cutter PRIVATE Threads::Threads)
|
|
|
|
|
2019-04-09 07:44:44 +00:00
|
|
|
add_definitions(-DCUTTER_ENABLE_CRASH_REPORTS)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ")
|
|
|
|
if(DEFINED BREAKPAD_FRAMEWORK_DIR)
|
|
|
|
include_directories("${BREAKPAD_FRAMEWORK_DIR}/Breakpad.framework/Headers")
|
|
|
|
set_target_properties(Cutter PROPERTIES LINK_FLAGS "-Wl,-F${BREAKPAD_FRAMEWORK_DIR}")
|
2020-03-15 13:43:42 +00:00
|
|
|
target_link_libraries(Cutter PRIVATE "-framework Breakpad")
|
2019-04-09 07:44:44 +00:00
|
|
|
else()
|
|
|
|
find_package(Breakpad REQUIRED)
|
2020-09-05 08:25:34 +00:00
|
|
|
target_link_libraries(Cutter PRIVATE Breakpad::client)
|
2019-04-09 07:44:44 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-11-30 07:42:13 +00:00
|
|
|
target_link_libraries(Cutter PUBLIC ${QT_PREFIX}::Core ${QT_PREFIX}::Widgets ${QT_PREFIX}::Gui PRIVATE ${QT_PREFIX}::Svg ${QT_PREFIX}::Network)
|
2020-10-28 12:28:04 +00:00
|
|
|
target_link_libraries(Cutter PUBLIC ${RIZIN_TARGET})
|
2019-02-03 15:03:36 +00:00
|
|
|
if(CUTTER_ENABLE_PYTHON)
|
2020-08-30 20:23:41 +00:00
|
|
|
if (WIN32)
|
|
|
|
# On windows some of the Python STABLE API functions are in seperate library
|
|
|
|
# which isn't added by CMake.
|
2020-11-26 16:51:20 +00:00
|
|
|
foreach(_PYTHON_LIBRARY ${PYTHON_LIBRARIES})
|
|
|
|
# Skip extra "optimized" and "debug" values that are only meant for passing to target_link_libraries()
|
|
|
|
if((NOT _PYTHON_LIBRARY STREQUAL "optimized") AND (NOT _PYTHON_LIBRARY STREQUAL "debug"))
|
|
|
|
get_filename_component(_PYTHON_LIB_DIR ${_PYTHON_LIBRARY} DIRECTORY)
|
|
|
|
message(STATUS "Add extra library dir for Python: ${_PYTHON_LIB_DIR}")
|
|
|
|
target_link_directories(Cutter PRIVATE ${_PYTHON_LIB_DIR})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2020-08-30 20:23:41 +00:00
|
|
|
endif()
|
2020-03-15 13:43:42 +00:00
|
|
|
target_link_libraries(Cutter PRIVATE ${PYTHON_LIBRARIES})
|
2019-02-03 15:03:36 +00:00
|
|
|
if(CUTTER_ENABLE_PYTHON_BINDINGS)
|
2020-03-15 13:43:42 +00:00
|
|
|
target_link_libraries(Cutter PRIVATE Shiboken2::libshiboken PySide2::pyside2)
|
|
|
|
|
|
|
|
get_target_property(RAW_BINDINGS_INCLUDE_DIRS Cutter INCLUDE_DIRECTORIES)
|
|
|
|
set(BINDINGS_INCLUDE_DIRS "")
|
|
|
|
foreach(_dir ${RAW_BINDINGS_INCLUDE_DIRS})
|
|
|
|
string(REGEX REPLACE "\\$<BUILD_INTERFACE:(.*)>" "\\1" _dir ${_dir})
|
|
|
|
string(REGEX REPLACE "\\$<INSTALL_INTERFACE:(.*)>" "" _dir ${_dir})
|
|
|
|
if (NOT "${_dir}" STREQUAL "")
|
|
|
|
list(APPEND BINDINGS_INCLUDE_DIRS "${_dir}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2019-02-11 15:58:32 +00:00
|
|
|
|
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})
|
2020-10-28 12:28:04 +00:00
|
|
|
list(APPEND BINDINGS_INCLUDE_DIRS ${Rizin_INCLUDE_DIRS})
|
2019-03-08 23:01:24 +00:00
|
|
|
list(APPEND BINDINGS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
|
2020-08-30 20:23:41 +00:00
|
|
|
if (NOT WIN32)
|
|
|
|
string(REPLACE ";" ":" BINDINGS_INCLUDE_DIRS "${BINDINGS_INCLUDE_DIRS}")
|
|
|
|
endif()
|
2019-02-11 15:58:32 +00:00
|
|
|
|
2019-02-11 20:26:11 +00:00
|
|
|
qmake_configure_file("${BINDINGS_SRC_DIR}/bindings.txt.in" "${BINDINGS_BUILD_DIR}/bindings.txt")
|
2020-08-30 20:23:41 +00:00
|
|
|
add_compile_definitions(WIN32_LEAN_AND_MEAN)
|
2018-03-02 13:15:53 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2017-04-25 21:49:10 +00:00
|
|
|
|
2019-07-11 13:21:54 +00:00
|
|
|
if(TARGET KF5::SyntaxHighlighting)
|
2020-03-15 13:43:42 +00:00
|
|
|
target_link_libraries(Cutter PRIVATE KF5::SyntaxHighlighting)
|
2019-07-11 13:21:54 +00:00
|
|
|
target_compile_definitions(Cutter PRIVATE CUTTER_ENABLE_KSYNTAXHIGHLIGHTING)
|
|
|
|
endif()
|
2019-03-08 23:01:24 +00:00
|
|
|
|
2020-06-17 09:35:26 +00:00
|
|
|
if (CUTTER_APPIMAGE_BUILD)
|
|
|
|
target_compile_definitions(Cutter PRIVATE APPIMAGE)
|
|
|
|
endif()
|
|
|
|
|
2020-10-03 10:50:57 +00:00
|
|
|
if (CUTTER_PACKAGE_R2DEC)
|
|
|
|
target_compile_definitions(Cutter PRIVATE CUTTER_APPVEYOR_R2DEC)
|
|
|
|
endif()
|
|
|
|
|
2020-12-06 18:00:13 +00:00
|
|
|
if(APPLE AND CUTTER_ENABLE_PACKAGING AND CUTTER_USE_BUNDLED_RIZIN)
|
|
|
|
target_compile_definitions(Cutter PRIVATE MACOS_RZ_BUNDLED)
|
|
|
|
endif()
|
|
|
|
|
2020-06-17 09:35:26 +00:00
|
|
|
include(Translations)
|
|
|
|
|
2020-03-15 13:43:42 +00:00
|
|
|
# Install files
|
|
|
|
install(TARGETS Cutter
|
|
|
|
EXPORT CutterTargets
|
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
|
|
BUNDLE DESTINATION "." # needs to be tested
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Devel
|
|
|
|
)
|
|
|
|
install(EXPORT CutterTargets
|
|
|
|
NAMESPACE Cutter::
|
|
|
|
DESTINATION "${ConfigPackageLocation}"
|
|
|
|
COMPONENT Devel)
|
|
|
|
install(FILES
|
2020-12-02 17:53:17 +00:00
|
|
|
../cmake/CutterConfig.cmake
|
2020-03-15 13:43:42 +00:00
|
|
|
DESTINATION ${ConfigPackageLocation}
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
|
|
|
foreach(_file ${HEADER_FILES})
|
|
|
|
# Can't use target PUBLIC_HEADER option for installing due to multiple directories
|
|
|
|
get_filename_component(_header_dir "${_file}" DIRECTORY)
|
|
|
|
install (FILES "${_file}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/cutter/${_header_dir}" COMPONENT Devel)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
install (FILES "img/cutter.svg"
|
|
|
|
DESTINATION "share/icons/hicolor/scalable/apps/")
|
|
|
|
install(FILES "org.radare.Cutter.desktop"
|
|
|
|
DESTINATION "share/applications"
|
|
|
|
COMPONENT Devel)
|
|
|
|
endif()
|