mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-23 21:35:28 +00:00
Use bundled radare2 as ExternalProject in cmake (#1674)
This commit is contained in:
parent
ae1c1a741c
commit
9dd3b2f2f3
32
.travis.yml
32
.travis.yml
@ -14,28 +14,29 @@ matrix:
|
|||||||
- name: Linux QMake + Deploy
|
- name: Linux QMake + Deploy
|
||||||
os: linux
|
os: linux
|
||||||
env: BUILD_SYSTEM=qmake DEPLOY=1
|
env: BUILD_SYSTEM=qmake DEPLOY=1
|
||||||
|
|
||||||
- name: Linux CMake
|
- name: Linux CMake
|
||||||
os: linux
|
os: linux
|
||||||
env: BUILD_SYSTEM=cmake
|
env: BUILD_SYSTEM=cmake
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get update && sudo apt-get install ninja-build # because the apt addon is broken on bionic
|
||||||
|
- pyenv global 3.7.1
|
||||||
|
- pip install meson
|
||||||
|
|
||||||
- name: macOS QMake + Deploy
|
- name: macOS QMake + Deploy
|
||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode10.1
|
osx_image: xcode10.1
|
||||||
env: BUILD_SYSTEM=qmake DEPLOY=1
|
env: BUILD_SYSTEM=qmake DEPLOY=1
|
||||||
|
|
||||||
- name: macOS CMake
|
- name: macOS CMake
|
||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode10.1
|
osx_image: xcode10.1
|
||||||
env: BUILD_SYSTEM=cmake
|
env: BUILD_SYSTEM=cmake
|
||||||
|
|
||||||
- name: Documentation + Deploy
|
- name: Documentation + Deploy
|
||||||
os: linux
|
os: linux
|
||||||
cache: ~
|
cache: ~
|
||||||
addons:
|
before_install: sudo apt-get update && sudo apt-get install doxygen python3-sphinx python3-breathe python3-sphinx-rtd-theme # because the apt addon is broken on bionic
|
||||||
apt:
|
|
||||||
update: true
|
|
||||||
packages:
|
|
||||||
- doxygen
|
|
||||||
- python3-sphinx
|
|
||||||
- python3-breathe
|
|
||||||
before_install: ~
|
|
||||||
install: ~
|
install: ~
|
||||||
before_script: ~
|
before_script: ~
|
||||||
after_success: ~
|
after_success: ~
|
||||||
@ -59,7 +60,7 @@ matrix:
|
|||||||
|
|
||||||
|
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: xenial
|
dist: bionic
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
homebrew:
|
homebrew:
|
||||||
@ -79,12 +80,13 @@ install:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- git submodule init ; git submodule update
|
|
||||||
- cd radare2
|
- cd radare2
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
- if [[ "$BUILD_SYSTEM" == "qmake" ]]; then
|
||||||
INSTALL_TARGET=install sys/install.sh;
|
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
||||||
else
|
INSTALL_TARGET=install sys/install.sh;
|
||||||
LDFLAGS=-headerpad_max_install_names INSTALL_TARGET=install sys/install.sh;
|
else
|
||||||
|
LDFLAGS=-headerpad_max_install_names INSTALL_TARGET=install sys/install.sh;
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|
||||||
@ -111,6 +113,7 @@ script:
|
|||||||
-DCUTTER_ENABLE_PYTHON=ON
|
-DCUTTER_ENABLE_PYTHON=ON
|
||||||
-DCUTTER_ENABLE_PYTHON_BINDINGS=ON
|
-DCUTTER_ENABLE_PYTHON_BINDINGS=ON
|
||||||
-DCUTTER_ENABLE_CRASH_REPORTS=ON
|
-DCUTTER_ENABLE_CRASH_REPORTS=ON
|
||||||
|
-DCUTTER_USE_BUNDLED_RADARE2=ON
|
||||||
../src &&
|
../src &&
|
||||||
make -j4;
|
make -j4;
|
||||||
fi
|
fi
|
||||||
@ -134,6 +137,7 @@ script:
|
|||||||
-DCUTTER_ENABLE_PYTHON=ON
|
-DCUTTER_ENABLE_PYTHON=ON
|
||||||
-DCUTTER_ENABLE_PYTHON_BINDINGS=ON
|
-DCUTTER_ENABLE_PYTHON_BINDINGS=ON
|
||||||
-DCUTTER_ENABLE_CRASH_REPORTS=ON
|
-DCUTTER_ENABLE_CRASH_REPORTS=ON
|
||||||
|
-DCUTTER_USE_BUNDLED_RADARE2=ON
|
||||||
-DBREAKPAD_FRAMEWORK_DIR="$BREAKPAD_FRAMEWORK_DIR"
|
-DBREAKPAD_FRAMEWORK_DIR="$BREAKPAD_FRAMEWORK_DIR"
|
||||||
../src &&
|
../src &&
|
||||||
make -j4;
|
make -j4;
|
||||||
|
@ -3,3 +3,4 @@ brew "ccache"
|
|||||||
brew "openssl"
|
brew "openssl"
|
||||||
brew "xz"
|
brew "xz"
|
||||||
brew "llvm"
|
brew "llvm"
|
||||||
|
brew "meson"
|
@ -11,6 +11,7 @@ include(Utils)
|
|||||||
|
|
||||||
set(CUTTER_PYTHON_MIN 3.5)
|
set(CUTTER_PYTHON_MIN 3.5)
|
||||||
|
|
||||||
|
option(CUTTER_USE_BUNDLED_RADARE2 "Use radare2 from src/radare2 submodule instead of searching for it on the system" OFF)
|
||||||
option(CUTTER_ENABLE_PYTHON "Enable Python integration. Requires Python >= ${CUTTER_PYTHON_MIN}." OFF)
|
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)
|
option(CUTTER_ENABLE_PYTHON_BINDINGS "Enable generating Python bindings with Shiboken2. Unused if CUTTER_ENABLE_PYTHON=OFF." OFF)
|
||||||
option(CUTTER_ENABLE_CRASH_REPORTS "Enable crash report system. Unused if CUTTER_ENABLE_CRASH_REPORTS=OFF" OFF)
|
option(CUTTER_ENABLE_CRASH_REPORTS "Enable crash report system. Unused if CUTTER_ENABLE_CRASH_REPORTS=OFF" OFF)
|
||||||
@ -49,26 +50,14 @@ set(CMAKE_AUTOUIC ON)
|
|||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Svg Network)
|
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Svg Network)
|
||||||
|
|
||||||
|
if(CUTTER_USE_BUNDLED_RADARE2)
|
||||||
if(WIN32)
|
include(BundledRadare2)
|
||||||
# use radare2 libraries from submodule on windows
|
set(RADARE2_TARGET Radare2)
|
||||||
set(CUTTER_WIN32_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../cutter_win32")
|
else()
|
||||||
list(APPEND CMAKE_PREFIX_PATH "${CUTTER_WIN32_DIR}")
|
find_package(Radare2 REQUIRED)
|
||||||
|
set(RADARE2_TARGET Radare2::libr)
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64 bit
|
|
||||||
list(APPEND CMAKE_LIBRARY_PATH "${CUTTER_WIN32_DIR}/radare2/lib64")
|
|
||||||
else()
|
|
||||||
list(APPEND CMAKE_LIBRARY_PATH "${CUTTER_WIN32_DIR}/radare2/lib32")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(RADARE2_INCLUDE_DIRS "${CUTTER_WIN32_DIR}/radare2/include/libr" "${CUTTER_WIN32_DIR}/include")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
find_package(Radare2 REQUIRED)
|
|
||||||
include_directories(${RADARE2_INCLUDE_DIRS})
|
|
||||||
link_directories(${RADARE2_LIBRARY_DIRS})
|
|
||||||
|
|
||||||
if(CUTTER_ENABLE_PYTHON)
|
if(CUTTER_ENABLE_PYTHON)
|
||||||
find_package(PythonLibs ${CUTTER_PYTHON_MIN} REQUIRED)
|
find_package(PythonLibs ${CUTTER_PYTHON_MIN} REQUIRED)
|
||||||
|
|
||||||
@ -118,6 +107,7 @@ endif()
|
|||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
message(STATUS "Building Cutter version ${CUTTER_VERSION_FULL}")
|
message(STATUS "Building Cutter version ${CUTTER_VERSION_FULL}")
|
||||||
message(STATUS "Options:")
|
message(STATUS "Options:")
|
||||||
|
message(STATUS "- Bundled radare2: ${CUTTER_USE_BUNDLED_RADARE2}")
|
||||||
message(STATUS "- Python: ${CUTTER_ENABLE_PYTHON}")
|
message(STATUS "- Python: ${CUTTER_ENABLE_PYTHON}")
|
||||||
message(STATUS "- Python Bindings: ${CUTTER_ENABLE_PYTHON_BINDINGS}")
|
message(STATUS "- Python Bindings: ${CUTTER_ENABLE_PYTHON_BINDINGS}")
|
||||||
message(STATUS "- Crash Handling: ${CUTTER_ENABLE_CRASH_REPORTS}")
|
message(STATUS "- Crash Handling: ${CUTTER_ENABLE_CRASH_REPORTS}")
|
||||||
@ -182,7 +172,7 @@ if(CUTTER_ENABLE_CRASH_REPORTS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(Cutter Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Svg Qt5::Network)
|
target_link_libraries(Cutter Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Svg Qt5::Network)
|
||||||
target_link_libraries(Cutter ${RADARE2_LIBRARIES})
|
target_link_libraries(Cutter ${RADARE2_TARGET})
|
||||||
if(CUTTER_ENABLE_PYTHON)
|
if(CUTTER_ENABLE_PYTHON)
|
||||||
target_link_libraries(Cutter ${PYTHON_LIBRARIES})
|
target_link_libraries(Cutter ${PYTHON_LIBRARIES})
|
||||||
if(CUTTER_ENABLE_PYTHON_BINDINGS)
|
if(CUTTER_ENABLE_PYTHON_BINDINGS)
|
||||||
@ -196,6 +186,7 @@ if(CUTTER_ENABLE_PYTHON)
|
|||||||
list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtWidgets")
|
list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtWidgets")
|
||||||
endif()
|
endif()
|
||||||
list(APPEND BINDINGS_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS})
|
list(APPEND BINDINGS_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS})
|
||||||
|
list(APPEND BINDINGS_INCLUDE_DIRS ${Radare2_INCLUDE_DIRS})
|
||||||
list(APPEND BINDINGS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
|
list(APPEND BINDINGS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
string(REPLACE ";" ":" BINDINGS_INCLUDE_DIRS "${BINDINGS_INCLUDE_DIRS}")
|
string(REPLACE ";" ":" BINDINGS_INCLUDE_DIRS "${BINDINGS_INCLUDE_DIRS}")
|
||||||
|
|
||||||
|
38
src/cmake/BundledRadare2.cmake
Normal file
38
src/cmake/BundledRadare2.cmake
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
find_program(MESON meson)
|
||||||
|
if(NOT MESON)
|
||||||
|
message(FATAL_ERROR "Failed to find meson, which is required to build bundled radare2")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_program(NINJA ninja)
|
||||||
|
if(NOT NINJA)
|
||||||
|
message(FATAL_ERROR "Failed to find ninja, which is required to build bundled radare2")
|
||||||
|
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}
|
||||||
|
BUILD_COMMAND "${NINJA}"
|
||||||
|
INSTALL_COMMAND "${NINJA}" install)
|
||||||
|
|
||||||
|
set(Radare2_INCLUDE_DIRS "${RADARE2_INSTALL_DIR}/include/libr")
|
||||||
|
|
||||||
|
add_library(Radare2 INTERFACE)
|
||||||
|
add_dependencies(Radare2 Radare2-Bundled)
|
||||||
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0")
|
||||||
|
target_link_directories(Radare2 INTERFACE "${RADARE2_INSTALL_DIR}/lib")
|
||||||
|
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
|
||||||
|
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}")
|
@ -1,22 +1,29 @@
|
|||||||
# - Find Radare2 (libr)
|
# - Find Radare2 (libr)
|
||||||
#
|
#
|
||||||
# RADARE2_FOUND - True if libr has been found.
|
# This module provides the following imported targets, if found:
|
||||||
# RADARE2_INCLUDE_DIRS - libr include directory
|
#
|
||||||
# RADARE2_LIBRARIES - List of libraries when using libr.
|
# Radare2::libr
|
||||||
# RADARE2_LIBRARY_DIRS - libr library directories
|
#
|
||||||
|
# This will define the following variables:
|
||||||
|
# (but don't use them if you don't know what you are doing, use Radare2::libr)
|
||||||
|
#
|
||||||
|
# Radare2_FOUND - True if libr has been found.
|
||||||
|
# Radare2_INCLUDE_DIRS - libr include directory
|
||||||
|
# Radare2_LIBRARIES - List of libraries when using libr.
|
||||||
|
# Radare2_LIBRARY_DIRS - libr library directories
|
||||||
#
|
#
|
||||||
# If libr was found using find_library and not pkg-config, the following variables will also be set:
|
# If libr was found using find_library and not pkg-config, the following variables will also be set:
|
||||||
# RADARE2_LIBRARY_<name> - Path to library r_<name>
|
# Radare2_LIBRARY_<name> - Path to library r_<name>
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
find_path(RADARE2_INCLUDE_DIRS
|
find_path(Radare2_INCLUDE_DIRS
|
||||||
NAMES r_core.h r_bin.h r_util.h
|
NAMES r_core.h r_bin.h r_util.h
|
||||||
HINTS
|
HINTS
|
||||||
"$ENV{HOME}/bin/prefix/radare2/include/libr"
|
"$ENV{HOME}/bin/prefix/radare2/include/libr"
|
||||||
/usr/local/include/libr
|
/usr/local/include/libr
|
||||||
/usr/include/libr)
|
/usr/include/libr)
|
||||||
|
|
||||||
set(RADARE2_LIBRARY_NAMES
|
set(Radare2_LIBRARY_NAMES
|
||||||
core
|
core
|
||||||
config
|
config
|
||||||
cons
|
cons
|
||||||
@ -41,35 +48,52 @@ if(WIN32)
|
|||||||
magic
|
magic
|
||||||
crypto)
|
crypto)
|
||||||
|
|
||||||
set(RADARE2_LIBRARIES "")
|
set(Radare2_LIBRARIES "")
|
||||||
set(RADARE2_LIBRARIES_VARS "")
|
set(Radare2_LIBRARIES_VARS "")
|
||||||
foreach(libname ${RADARE2_LIBRARY_NAMES})
|
foreach(libname ${Radare2_LIBRARY_NAMES})
|
||||||
find_library(RADARE2_LIBRARY_${libname}
|
find_library(Radare2_LIBRARY_${libname}
|
||||||
r_${libname}
|
r_${libname}
|
||||||
HINTS
|
HINTS
|
||||||
"$ENV{HOME}/bin/prefix/radare2/lib"
|
"$ENV{HOME}/bin/prefix/radare2/lib"
|
||||||
/usr/local/lib
|
/usr/local/lib
|
||||||
/usr/lib)
|
/usr/lib)
|
||||||
|
|
||||||
list(APPEND RADARE2_LIBRARIES ${RADARE2_LIBRARY_${libname}})
|
list(APPEND Radare2_LIBRARIES ${Radare2_LIBRARY_${libname}})
|
||||||
list(APPEND RADARE2_LIBRARIES_VARS "RADARE2_LIBRARY_${libname}")
|
list(APPEND Radare2_LIBRARIES_VARS "Radare2_LIBRARY_${libname}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set(RADARE2_LIBRARY_DIRS "")
|
set(Radare2_LIBRARY_DIRS "")
|
||||||
|
|
||||||
|
add_library(Radare2::libr UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(Radare2::libr PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${Radare2_CORE_LIBRARY}"
|
||||||
|
IMPORTED_LINK_INTERFACE_LIBRARIES "${Radare2_LIBRARIES}"
|
||||||
|
INTERFACE_LINK_DIRECTORIES "${Radare2_LIBRARY_DIRS}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${Radare2_INCLUDE_DIRS}")
|
||||||
|
set(Radare2_TARGET Radare2::libr)
|
||||||
else()
|
else()
|
||||||
# support sys/user.sh install
|
# support sys/user.sh install
|
||||||
set(RADARE2_CMAKE_PREFIX_PATH_TEMP ${CMAKE_PREFIX_PATH})
|
set(Radare2_CMAKE_PREFIX_PATH_TEMP ${CMAKE_PREFIX_PATH})
|
||||||
list(APPEND CMAKE_PREFIX_PATH "$ENV{HOME}/bin/prefix/radare2")
|
list(APPEND CMAKE_PREFIX_PATH "$ENV{HOME}/bin/prefix/radare2")
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_search_module(RADARE2 REQUIRED r_core)
|
pkg_search_module(Radare2 IMPORTED_TARGET REQUIRED r_core)
|
||||||
|
|
||||||
# reset CMAKE_PREFIX_PATH
|
# reset CMAKE_PREFIX_PATH
|
||||||
set(CMAKE_PREFIX_PATH ${RADARE2_CMAKE_PREFIX_PATH_TEMP})
|
set(CMAKE_PREFIX_PATH ${Radare2_CMAKE_PREFIX_PATH_TEMP})
|
||||||
mark_as_advanced(RADARE2_CMAKE_PREFIX_PATH_TEMP)
|
mark_as_advanced(Radare2_CMAKE_PREFIX_PATH_TEMP)
|
||||||
|
|
||||||
|
if(TARGET PkgConfig::Radare2)
|
||||||
|
set_target_properties(PkgConfig::Radare2 PROPERTIES IMPORTED_GLOBAL ON)
|
||||||
|
add_library(Radare2::libr ALIAS PkgConfig::Radare2)
|
||||||
|
set(Radare2_TARGET Radare2::libr)
|
||||||
|
else()
|
||||||
|
set(Radare2_TARGET Radare2_TARGET-NOTFOUND)
|
||||||
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(RADARE2 REQUIRED_VARS RADARE2_LIBRARIES RADARE2_INCLUDE_DIRS)
|
find_package_handle_standard_args(Radare2 REQUIRED_VARS Radare2_TARGET Radare2_LIBRARIES Radare2_INCLUDE_DIRS)
|
||||||
|
|
||||||
mark_as_advanced(RADARE2_LIBRARIES_VARS)
|
mark_as_advanced(Radare2_LIBRARIES_VARS Radare2_CORE_LIBRARY Radare2_TARGET)
|
||||||
|
Loading…
Reference in New Issue
Block a user