2020-10-28 12:28:04 +00:00
|
|
|
|
|
|
|
include(ExternalProject)
|
|
|
|
|
2020-12-02 17:53:17 +00:00
|
|
|
set(RIZIN_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rizin")
|
2020-10-28 12:28:04 +00:00
|
|
|
if(WIN32)
|
|
|
|
set(RIZIN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
|
|
|
|
set(RIZIN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
|
|
|
|
endif()
|
|
|
|
set(RIZIN_INSTALL_BINPATH ".")
|
2021-10-28 05:48:00 +00:00
|
|
|
set(MESON_OPTIONS "--prefix=${RIZIN_INSTALL_DIR}" "--bindir=${RIZIN_INSTALL_BINPATH}")
|
2020-10-28 12:28:04 +00:00
|
|
|
else()
|
|
|
|
set(RIZIN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/Rizin-prefix")
|
|
|
|
set(MESON_OPTIONS "--prefix=${RIZIN_INSTALL_DIR}" --libdir=lib)
|
|
|
|
endif()
|
|
|
|
|
2021-04-20 03:34:52 +00:00
|
|
|
if (CUTTER_ENABLE_PACKAGING)
|
|
|
|
list(APPEND MESON_OPTIONS "-Dportable=true")
|
|
|
|
endif()
|
|
|
|
|
2022-06-06 09:27:13 +00:00
|
|
|
if (CUTTER_ENABLE_SIGDB)
|
|
|
|
list(APPEND MESON_OPTIONS "-Dinstall_sigdb=true")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CUTTER_PACKAGE_RZ_LIBSWIFT AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
|
|
|
|
list(APPEND MESON_OPTIONS "-Duse_swift_demangler=false")
|
|
|
|
endif()
|
|
|
|
|
2020-10-28 12:28:04 +00:00
|
|
|
find_program(MESON meson)
|
|
|
|
if(NOT MESON)
|
|
|
|
message(FATAL_ERROR "Failed to find meson, which is required to build bundled rizin")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_program(NINJA ninja)
|
|
|
|
if(NOT NINJA)
|
|
|
|
message(FATAL_ERROR "Failed to find ninja, which is required to build bundled rizin")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
ExternalProject_Add(Rizin-Bundled
|
|
|
|
SOURCE_DIR "${RIZIN_SOURCE_DIR}"
|
|
|
|
CONFIGURE_COMMAND "${MESON}" "<SOURCE_DIR>" ${MESON_OPTIONS} && "${MESON}" configure ${MESON_OPTIONS} --buildtype "$<$<CONFIG:Debug>:debug>$<$<NOT:$<CONFIG:Debug>>:release>"
|
|
|
|
BUILD_COMMAND "${NINJA}"
|
2023-02-07 16:48:33 +00:00
|
|
|
BUILD_ALWAYS TRUE
|
2020-10-28 12:28:04 +00:00
|
|
|
INSTALL_COMMAND "${NINJA}" install)
|
|
|
|
|
|
|
|
set(Rizin_INCLUDE_DIRS "${RIZIN_INSTALL_DIR}/include/librz" "${RIZIN_INSTALL_DIR}/include/librz/sdb")
|
|
|
|
|
|
|
|
add_library(Rizin INTERFACE)
|
|
|
|
add_dependencies(Rizin Rizin-Bundled)
|
|
|
|
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.13.0"))
|
|
|
|
target_link_directories(Rizin INTERFACE
|
|
|
|
$<BUILD_INTERFACE:${RIZIN_INSTALL_DIR}/lib>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}>)
|
|
|
|
else()
|
|
|
|
link_directories("${RIZIN_INSTALL_DIR}/lib")
|
|
|
|
endif()
|
|
|
|
|
2022-05-24 18:47:59 +00:00
|
|
|
# TODO: This version number should be fetched automatically
|
|
|
|
# instead of being hardcoded.
|
2023-09-26 02:20:26 +00:00
|
|
|
set (Rizin_VERSION 0.7)
|
2022-05-24 18:47:59 +00:00
|
|
|
|
2020-12-06 18:00:13 +00:00
|
|
|
set (RZ_LIBS rz_core rz_config rz_cons rz_io rz_util rz_flag rz_asm rz_debug
|
2021-12-22 08:57:58 +00:00
|
|
|
rz_hash rz_bin rz_lang rz_il rz_analysis rz_parse rz_bp rz_egg rz_reg
|
2022-02-08 21:22:55 +00:00
|
|
|
rz_search rz_syscall rz_socket rz_magic rz_crypto rz_type rz_diff rz_sign
|
|
|
|
rz_demangler)
|
2020-12-06 18:00:13 +00:00
|
|
|
set (RZ_EXTRA_LIBS rz_main)
|
2022-11-02 10:14:23 +00:00
|
|
|
set (RZ_BIN rz-bin rizin rz-diff rz-find rz-gg rz-hash rz-run rz-asm rz-ax)
|
2020-10-28 12:28:04 +00:00
|
|
|
|
|
|
|
target_link_libraries(Rizin INTERFACE
|
2020-12-06 18:00:13 +00:00
|
|
|
${RZ_LIBS})
|
2020-10-28 12:28:04 +00:00
|
|
|
target_include_directories(Rizin INTERFACE
|
|
|
|
"$<BUILD_INTERFACE:${Rizin_INCLUDE_DIRS}>"
|
2022-03-31 10:49:37 +00:00
|
|
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/librz>"
|
|
|
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/librz/sdb>")
|
2020-10-28 12:28:04 +00:00
|
|
|
|
|
|
|
install(TARGETS Rizin EXPORT CutterTargets)
|
2021-02-18 14:36:27 +00:00
|
|
|
if (WIN32)
|
2022-05-24 18:47:59 +00:00
|
|
|
foreach(_lib ${RZ_LIBS} ${RZ_EXTRA_LIBS})
|
|
|
|
install(FILES "${RIZIN_INSTALL_DIR}/${_lib}-${Rizin_VERSION}.dll" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
2020-10-28 12:28:04 +00:00
|
|
|
endforeach()
|
2020-12-06 18:00:13 +00:00
|
|
|
foreach(_exe ${RZ_BIN})
|
2022-05-24 18:47:59 +00:00
|
|
|
install(FILES "${RIZIN_INSTALL_DIR}/${_exe}.exe" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
2020-10-28 12:28:04 +00:00
|
|
|
endforeach()
|
|
|
|
install(DIRECTORY "${RIZIN_INSTALL_DIR}/share" DESTINATION ".")
|
|
|
|
install(DIRECTORY "${RIZIN_INSTALL_DIR}/include" DESTINATION "."
|
|
|
|
COMPONENT Devel)
|
|
|
|
install(DIRECTORY "${RIZIN_INSTALL_DIR}/lib" DESTINATION "."
|
|
|
|
COMPONENT Devel
|
|
|
|
PATTERN "*.pdb" EXCLUDE)
|
|
|
|
else ()
|
2020-12-19 10:43:33 +00:00
|
|
|
install(DIRECTORY "${RIZIN_INSTALL_DIR}/" DESTINATION "." USE_SOURCE_PERMISSIONS)
|
2020-10-28 12:28:04 +00:00
|
|
|
endif()
|