1
0
mirror of synced 2024-11-30 18:34:29 +01:00

build: Streamlined plugin creation process

This commit is contained in:
WerWolv 2023-07-27 00:53:04 +02:00
parent 4792a29fac
commit 94a02c4b6d
4 changed files with 59 additions and 89 deletions

View File

@ -0,0 +1,28 @@
macro(add_imhex_plugin)
set(options "")
set(oneValueArgs NAME)
set(multiValueArgs SOURCES INCLUDES LIBRARIES)
cmake_parse_arguments(IMHEX_PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
project(${IMHEX_PLUGIN_NAME})
add_library(${IMHEX_PLUGIN_NAME} SHARED ${IMHEX_PLUGIN_SOURCES})
target_include_directories(${IMHEX_PLUGIN_NAME} PRIVATE ${IMHEX_PLUGIN_INCLUDES})
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} ${IMHEX_PLUGIN_LIBRARIES})
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".hexplug")
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}")
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_VERSION="${IMHEX_VERSION_STRING}")
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
setupCompilerFlags(${IMHEX_PLUGIN_NAME})
set(LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/romfs)
set(LIBROMFS_PROJECT_NAME ${IMHEX_PLUGIN_NAME})
add_subdirectory(${IMHEX_BASE_FOLDER}/lib/external/libromfs ${CMAKE_CURRENT_BINARY_DIR}/libromfs)
set_target_properties(${LIBROMFS_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE ${LIBROMFS_LIBRARY})
endmacro()

View File

@ -1,9 +1,11 @@
cmake_minimum_required(VERSION 3.16)
# Change this to the name of your plugin #
project(builtin)
# Add your source files here #
add_library(${PROJECT_NAME} SHARED
include(ImHexPlugin)
add_imhex_plugin(
NAME
builtin
SOURCES
source/plugin_builtin.cpp
source/content/background_services.cpp
@ -68,27 +70,7 @@ add_library(${PROJECT_NAME} SHARED
source/ui/hex_editor.cpp
source/ui/pattern_drawer.cpp
)
# Add additional include directories here #
target_include_directories(${PROJECT_NAME} PRIVATE include)
# Add additional libraries here #
target_link_libraries(${PROJECT_NAME} PRIVATE libimhex ${FMT_LIBRARIES})
# ---- No need to change anything from here downwards unless you know what you're doing ---- #
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".hexplug")
target_compile_definitions(${PROJECT_NAME} PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
target_compile_definitions(${PROJECT_NAME} PRIVATE IMHEX_VERSION="${IMHEX_VERSION_STRING}")
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
setupCompilerFlags(${PROJECT_NAME})
set(LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/romfs)
set(LIBROMFS_PROJECT_NAME ${PROJECT_NAME})
add_subdirectory(../../lib/external/libromfs ${CMAKE_CURRENT_BINARY_DIR}/libromfs)
set_target_properties(${LIBROMFS_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBROMFS_LIBRARY})
INCLUDES
include
)

View File

@ -1,19 +1,17 @@
cmake_minimum_required(VERSION 3.16)
# Change this to the name of your plugin #
project(script_loader)
# Add your source files here #
find_package(CoreClrEmbed)
add_library(${PROJECT_NAME} SHARED
add_imhex_plugin(
NAME
script_loader
SOURCES
source/plugin_script_loader.cpp
INCLUDES
include
)
# Add additional include directories here #
target_include_directories(${PROJECT_NAME} PRIVATE include)
# Add additional libraries here #
target_link_libraries(${PROJECT_NAME} PRIVATE libimhex ${FMT_LIBRARIES})
if (CoreClrEmbed_FOUND)
add_library(nethost SHARED IMPORTED)
@ -26,10 +24,10 @@ if (CoreClrEmbed_FOUND)
BUILD_RPATH ${CoreClrEmbed_FOLDER}
INSTALL_RPATH ${CoreClrEmbed_FOLDER})
target_link_directories(${PROJECT_NAME} PRIVATE ${CoreClrEmbed_FOLDER})
target_include_directories(${PROJECT_NAME} PRIVATE ${CoreClrEmbed_INCLUDE_DIRS})
target_compile_definitions(${PROJECT_NAME} PRIVATE DOTNET_PLUGINS=1)
target_sources(${PROJECT_NAME} PRIVATE
target_link_directories(script_loader PRIVATE ${CoreClrEmbed_FOLDER})
target_include_directories(script_loader PRIVATE ${CoreClrEmbed_INCLUDE_DIRS})
target_compile_definitions(script_loader PRIVATE DOTNET_PLUGINS=1)
target_sources(script_loader PRIVATE
source/loaders/dotnet/dotnet_loader.cpp
source/script_api/v1/mem.cpp
@ -44,24 +42,6 @@ if (CoreClrEmbed_FOUND)
endif ()
add_subdirectory(dotnet)
add_dependencies(${PROJECT_NAME} AssemblyLoader)
add_dependencies(script_loader AssemblyLoader)
endif ()
# ---- No need to change anything from here downwards unless you know what you're doing ---- #
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".hexplug")
target_compile_definitions(${PROJECT_NAME} PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
target_compile_definitions(${PROJECT_NAME} PRIVATE IMHEX_VERSION="${IMHEX_VERSION_STRING}")
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
setupCompilerFlags(${PROJECT_NAME})
set(LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/romfs)
set(LIBROMFS_PROJECT_NAME ${PROJECT_NAME})
add_subdirectory(../../lib/external/libromfs ${CMAKE_CURRENT_BINARY_DIR}/libromfs)
set_target_properties(${LIBROMFS_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBROMFS_LIBRARY})
endif ()

View File

@ -1,12 +1,13 @@
cmake_minimum_required(VERSION 3.16)
# Change this to the name of your plugin #
project(windows)
# Add your source files here #
if (WIN32)
add_library(${PROJECT_NAME} SHARED
include(ImHexPlugin)
add_imhex_plugin(
NAME
windows
SOURCES
source/plugin_windows.cpp
source/views/view_tty_console.cpp
@ -16,29 +17,8 @@ if (WIN32)
source/content/providers.cpp
source/content/providers/process_memory_provider.cpp
INCLUDES
include
)
# Add additional include directories here #
target_include_directories(${PROJECT_NAME} PRIVATE include)
# Add additional libraries here #
target_link_libraries(${PROJECT_NAME} PRIVATE libimhex ${FMT_LIBRARIES})
# ---- No need to change anything from here downwards unless you know what you're doing ---- #
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".hexplug")
target_compile_definitions(${PROJECT_NAME} PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
target_compile_definitions(${PROJECT_NAME} PRIVATE IMHEX_VERSION="${IMHEX_VERSION_STRING}")
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
setupCompilerFlags(${PROJECT_NAME})
set(LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/romfs)
set(LIBROMFS_PROJECT_NAME ${PROJECT_NAME})
add_subdirectory(../../lib/external/libromfs ${CMAKE_CURRENT_BINARY_DIR}/libromfs)
set_target_properties(${LIBROMFS_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBROMFS_LIBRARY})
endif ()