mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Add installing to CMake (#2084)
This commit is contained in:
parent
ddeb7fbe53
commit
c4d7d649f1
4
.gitignore
vendored
4
.gitignore
vendored
@ -74,6 +74,10 @@ compile_commands.json
|
||||
# vscode
|
||||
**/.vscode
|
||||
|
||||
# Visual Studio CMake
|
||||
src/out
|
||||
.vs
|
||||
|
||||
# cutter-deps
|
||||
/cutter-deps
|
||||
|
||||
|
@ -7,6 +7,7 @@ endif()
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
include(DisallowInSource)
|
||||
include(Utils)
|
||||
include(CutterInstallDirs)
|
||||
|
||||
set(CUTTER_PYTHON_MIN 3.5)
|
||||
|
||||
@ -44,7 +45,6 @@ project(Cutter VERSION "${CUTTER_VERSION_FULL}")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
include_directories(core widgets common plugins menus)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
@ -169,38 +169,56 @@ add_executable(Cutter MACOSX_BUNDLE ${UI_FILES} ${QRC_FILES} ${SOURCE_FILES} ${H
|
||||
set_target_properties(Cutter PROPERTIES
|
||||
ENABLE_EXPORTS ON
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist")
|
||||
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()
|
||||
|
||||
if (TARGET Graphviz::GVC)
|
||||
target_link_libraries(Cutter Graphviz::GVC)
|
||||
target_link_libraries(Cutter PRIVATE Graphviz::GVC)
|
||||
target_compile_definitions(Cutter PRIVATE CUTTER_ENABLE_GRAPHVIZ)
|
||||
endif()
|
||||
|
||||
if(CUTTER_ENABLE_CRASH_REPORTS)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(Cutter Threads::Threads)
|
||||
target_link_libraries(Cutter PRIVATE Threads::Threads)
|
||||
|
||||
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}")
|
||||
target_link_libraries(Cutter "-framework Breakpad")
|
||||
target_link_libraries(Cutter PRIVATE "-framework Breakpad")
|
||||
else()
|
||||
find_package(Breakpad REQUIRED)
|
||||
include_directories(${BREAKPAD_INCLUDE_DIRS})
|
||||
target_link_libraries(Cutter ${BREAKPAD_LINK_LIBRARIES})
|
||||
target_link_libraries(Cutter PRIVATE ${BREAKPAD_LINK_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(Cutter Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Svg Qt5::Network)
|
||||
target_link_libraries(Cutter ${RADARE2_TARGET})
|
||||
target_link_libraries(Cutter PUBLIC Qt5::Core Qt5::Widgets Qt5::Gui PRIVATE Qt5::Svg Qt5::Network)
|
||||
target_link_libraries(Cutter PUBLIC ${RADARE2_TARGET})
|
||||
if(CUTTER_ENABLE_PYTHON)
|
||||
target_link_libraries(Cutter ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(Cutter PRIVATE ${PYTHON_LIBRARIES})
|
||||
if(CUTTER_ENABLE_PYTHON_BINDINGS)
|
||||
target_link_libraries(Cutter Shiboken2::libshiboken PySide2::pyside2)
|
||||
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()
|
||||
|
||||
get_target_property(BINDINGS_INCLUDE_DIRS Cutter INCLUDE_DIRECTORIES)
|
||||
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")
|
||||
@ -217,7 +235,36 @@ if(CUTTER_ENABLE_PYTHON)
|
||||
endif()
|
||||
|
||||
if(TARGET KF5::SyntaxHighlighting)
|
||||
target_link_libraries(Cutter KF5::SyntaxHighlighting)
|
||||
target_link_libraries(Cutter PRIVATE KF5::SyntaxHighlighting)
|
||||
target_compile_definitions(Cutter PRIVATE CUTTER_ENABLE_KSYNTAXHIGHLIGHTING)
|
||||
endif()
|
||||
|
||||
# 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
|
||||
cmake/CutterConfig.cmake
|
||||
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()
|
||||
|
@ -533,7 +533,7 @@ HEADERS += \
|
||||
widgets/ListDockWidget.h \
|
||||
widgets/AddressableItemList.h \
|
||||
dialogs/MultitypeFileSaveDialog.h \
|
||||
widgets/BoolToggleDelegate.cpp
|
||||
widgets/BoolToggleDelegate.h
|
||||
|
||||
GRAPHVIZ_HEADERS = widgets/GraphGridLayout.h
|
||||
|
||||
|
@ -2,8 +2,17 @@
|
||||
include(ExternalProject)
|
||||
|
||||
set(RADARE2_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../radare2")
|
||||
set(RADARE2_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/Radare2-prefix")
|
||||
set(MESON_OPTIONS "--prefix=${RADARE2_INSTALL_DIR}" --libdir=lib)
|
||||
if(WIN32)
|
||||
set(RADARE2_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
|
||||
set(RADARE2_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
|
||||
endif()
|
||||
set(RADARE2_INSTALL_BINPATH ".")
|
||||
set(MESON_OPTIONS "--prefix=${RADARE2_INSTALL_DIR}" "--bindir=${RADARE2_INSTALL_BINPATH}" "-Dr2_incdir=include/libr")
|
||||
else()
|
||||
set(RADARE2_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/Radare2-prefix")
|
||||
set(MESON_OPTIONS "--prefix=${RADARE2_INSTALL_DIR}" --libdir=lib)
|
||||
endif()
|
||||
|
||||
find_program(MESON meson)
|
||||
if(NOT MESON)
|
||||
@ -17,8 +26,7 @@ endif()
|
||||
|
||||
ExternalProject_Add(Radare2-Bundled
|
||||
SOURCE_DIR "${RADARE2_SOURCE_DIR}"
|
||||
INSTALL_DIR "${RADARE2_INSTALL_DIR}"
|
||||
CONFIGURE_COMMAND "${MESON}" "${RADARE2_SOURCE_DIR}" ${MESON_OPTIONS} && "${MESON}" configure ${MESON_OPTIONS}
|
||||
CONFIGURE_COMMAND "${MESON}" "<SOURCE_DIR>" ${MESON_OPTIONS} && "${MESON}" configure ${MESON_OPTIONS}
|
||||
BUILD_COMMAND "${NINJA}"
|
||||
INSTALL_COMMAND "${NINJA}" install)
|
||||
|
||||
@ -27,12 +35,38 @@ set(Radare2_INCLUDE_DIRS "${RADARE2_INSTALL_DIR}/include/libr")
|
||||
add_library(Radare2 INTERFACE)
|
||||
add_dependencies(Radare2 Radare2-Bundled)
|
||||
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.13.0"))
|
||||
target_link_directories(Radare2 INTERFACE "${RADARE2_INSTALL_DIR}/lib")
|
||||
target_link_directories(Radare2 INTERFACE
|
||||
$<BUILD_INTERFACE:${RADARE2_INSTALL_DIR}/lib>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}>)
|
||||
else()
|
||||
link_directories("${RADARE2_INSTALL_DIR}/lib")
|
||||
endif()
|
||||
target_link_libraries(Radare2 INTERFACE
|
||||
r_core r_config r_cons r_io r_util r_flag r_asm r_debug
|
||||
|
||||
set (R2_LIBS r_core r_config r_cons r_io r_util r_flag r_asm r_debug
|
||||
r_hash r_bin r_lang r_io r_anal r_parse r_bp r_egg r_reg
|
||||
r_search r_syscall r_socket r_fs r_magic r_crypto)
|
||||
target_include_directories(Radare2 INTERFACE "${Radare2_INCLUDE_DIRS}")
|
||||
set (R2_EXTRA_LIBS r_main)
|
||||
set (R2_BIN r2agent rabin2 radare2 radiff2 rafind2 ragg2 rahash2 rarun2 rasm2 rax2)
|
||||
|
||||
target_link_libraries(Radare2 INTERFACE
|
||||
${R2_LIBS})
|
||||
target_include_directories(Radare2 INTERFACE $<BUILD_INTERFACE:${Radare2_INCLUDE_DIRS}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libr>)
|
||||
|
||||
install(TARGETS Radare2 EXPORT CutterTargets)
|
||||
if (APPLE)
|
||||
elseif (WIN32)
|
||||
foreach(_lib ${R2_LIBS} ${R2_EXTRA_LIBS})
|
||||
install(FILES "${RADARE2_INSTALL_DIR}/${R2_INSTALL_BINPATH}/${_lib}.dll" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endforeach()
|
||||
foreach(_exe ${R2_BIN})
|
||||
install(FILES "${RADARE2_INSTALL_DIR}/${R2_INSTALL_BINPATH}/${_exe}.exe" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endforeach()
|
||||
install(DIRECTORY "${RADARE2_INSTALL_DIR}/share" DESTINATION ".")
|
||||
install(DIRECTORY "${RADARE2_INSTALL_DIR}/include" DESTINATION "."
|
||||
COMPONENT Devel)
|
||||
install(DIRECTORY "${RADARE2_INSTALL_DIR}/lib" DESTINATION "."
|
||||
COMPONENT Devel
|
||||
PATTERN "*.pdb" EXCLUDE)
|
||||
else ()
|
||||
install(DIRECTORY "${RADARE2_INSTALL_DIR}/" DESTINATION ".")
|
||||
endif()
|
1
src/cmake/CutterConfig.cmake
Normal file
1
src/cmake/CutterConfig.cmake
Normal file
@ -0,0 +1 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/CutterTargets.cmake")
|
10
src/cmake/CutterInstallDirs.cmake
Normal file
10
src/cmake/CutterInstallDirs.cmake
Normal file
@ -0,0 +1,10 @@
|
||||
if(WIN32)
|
||||
set(CMAKE_INSTALL_BINDIR "." CACHE PATH "Executable install directory")
|
||||
set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "Include install directory")
|
||||
set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "Library install directory")
|
||||
elseif(APPLE)
|
||||
include(GNUInstallDirs) #TODO: use appropriate paths for macOS
|
||||
else()
|
||||
include(GNUInstallDirs)
|
||||
endif()
|
||||
set(ConfigPackageLocation "${CMAKE_INSTALL_LIBDIR}/Cutter" CACHE PATH "Cmake file install location")
|
@ -1,12 +1,14 @@
|
||||
set (_module Graphviz)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
if (NOT (CMAKE_VERSION VERSION_LESS "3.12.0"))
|
||||
find_package(PkgConfig)
|
||||
if (PkgConfig_FOUND)
|
||||
if (NOT (CMAKE_VERSION VERSION_LESS "3.12.0"))
|
||||
pkg_check_modules(GVC IMPORTED_TARGET GLOBAL libgvc)
|
||||
elseif (NOT (CMAKE_VERSION VERSION_LESS "3.11.0"))
|
||||
elseif (NOT (CMAKE_VERSION VERSION_LESS "3.11.0"))
|
||||
pkg_check_modules(GVC IMPORTED_TARGET libgvc)
|
||||
else()
|
||||
else()
|
||||
pkg_check_modules(GVC libgvc)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
@ -77,32 +77,28 @@ else()
|
||||
list(APPEND CMAKE_PREFIX_PATH "$ENV{HOME}/bin/prefix/radare2")
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.6")
|
||||
pkg_search_module(Radare2 REQUIRED r_core)
|
||||
else()
|
||||
pkg_search_module(Radare2 IMPORTED_TARGET REQUIRED r_core)
|
||||
endif()
|
||||
|
||||
# reset CMAKE_PREFIX_PATH
|
||||
set(CMAKE_PREFIX_PATH ${Radare2_CMAKE_PREFIX_PATH_TEMP})
|
||||
mark_as_advanced(Radare2_CMAKE_PREFIX_PATH_TEMP)
|
||||
|
||||
if(TARGET PkgConfig::Radare2)
|
||||
if (CMAKE_VERSION VERSION_LESS "3.11.0")
|
||||
if((TARGET PkgConfig::Radare2) AND (NOT CMAKE_VERSION VERSION_LESS "3.11.0"))
|
||||
set_target_properties(PkgConfig::Radare2 PROPERTIES IMPORTED_GLOBAL ON)
|
||||
add_library(Radare2::libr ALIAS PkgConfig::Radare2)
|
||||
set(Radare2_TARGET Radare2::libr)
|
||||
elseif(Radare2_FOUND)
|
||||
add_library(Radare2::libr INTERFACE IMPORTED)
|
||||
set_target_properties(Radare2::libr PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Radare2_INCLUDE_DIRS}")
|
||||
set_target_properties(Radare2::libr PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${Radare2_LIBRARIES}")
|
||||
link_directories("${Radare2_LIBDIR}") # target specific link directory or flags require even newer cmake
|
||||
else()
|
||||
set_target_properties(PkgConfig::Radare2 PROPERTIES IMPORTED_GLOBAL ON)
|
||||
add_library(Radare2::libr ALIAS PkgConfig::Radare2)
|
||||
endif()
|
||||
set(Radare2_TARGET Radare2::libr)
|
||||
else()
|
||||
set(Radare2_TARGET Radare2_TARGET-NOTFOUND)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Radare2 REQUIRED_VARS Radare2_TARGET Radare2_LIBRARIES Radare2_INCLUDE_DIRS)
|
||||
|
||||
mark_as_advanced(Radare2_LIBRARIES_VARS Radare2_CORE_LIBRARY Radare2_TARGET)
|
||||
|
@ -76,8 +76,9 @@ ColorThemeWorker::ColorThemeWorker(QObject *parent) : QObject (parent)
|
||||
} else {
|
||||
QMessageBox::critical(nullptr,
|
||||
tr("Standard themes not found"),
|
||||
tr("The radare2 standard themes could not be found. "
|
||||
tr("The radare2 standard themes could not be found in '%1'. "
|
||||
"Most likely, radare2 is not properly installed.")
|
||||
.arg(currDir.path())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -55,5 +55,11 @@ inline QString RHexString(RVA size)
|
||||
return QString::asprintf("%#llx", size);
|
||||
}
|
||||
|
||||
#ifdef CUTTER_SOURCE_BUILD
|
||||
#define CUTTER_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define CUTTER_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // CUTTERCORE_H
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user