1
0
mirror of synced 2025-02-02 20:37:18 +01:00

build: Install include folders of plugin libraries to SDK (#2074)

Partially fixes #2068 .

This assumes the headers are in "include" for all plugins - this is
necessary since the INCLUDES argument of add_imhex_plugin may contain
paths to third party libs, whose headers should not be copied.
To fix this I think it is necessary to add a second argument like
"PRIVATE_INCLUDES", which is included, but not installed.

With this it possible to append the ui plugin for example:
```
INCLUDES
        $ENV{IMHEX_SDK_PATH}/lib/plugins/ui/
```
and to link against it:
```    
LIBRARIES
        /usr/local/lib/imhex/plugins/ui.hexpluglib
```

In a follow-up in the CMake Template for plugins imho there should be
fixed, that:

 - you can include plugin includes relative to the SDK Path
- you can link plugins relative to the lib path + without the hexpluglib
or hexplug extension

---------

Co-authored-by: Tim Blume <git@3nd.io>
Co-authored-by: Nik <werwolv98@gmail.com>
This commit is contained in:
Tim Blume 2025-02-02 12:12:40 +01:00 committed by GitHub
parent fe18cbaa41
commit 4e9f944204
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 10 deletions

View File

@ -543,16 +543,16 @@ function(downloadImHexPatternsFiles dest)
# Maybe patterns are cloned to a subdirectory
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ImHex-Patterns")
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ImHex-Patterns")
endif()
# Or a sibling directory
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ImHex-Patterns")
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ImHex-Patterns")
endif()
endif ()
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
message(WARNING "Failed to locate ImHex-Patterns repository, some resources will be missing during install!")
elseif(XCODE)
# The Xcode build has multiple configurations, which each need a copy of these files
@ -843,17 +843,20 @@ function(enableUnityBuild TARGET)
endif ()
endfunction()
function(generateSDKDirectory)
function(setSDKPaths)
if (WIN32)
set(SDK_PATH "./sdk")
set(SDK_PATH "./sdk" PARENT_SCOPE)
elseif (APPLE)
set(SDK_PATH "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/Resources/sdk")
set(SDK_PATH "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/Resources/sdk" PARENT_SCOPE)
else()
set(SDK_PATH "share/imhex/sdk")
set(SDK_PATH "share/imhex/sdk" PARENT_SCOPE)
endif()
set(SDK_BUILD_PATH "${CMAKE_BINARY_DIR}/sdk")
set(SDK_BUILD_PATH "${CMAKE_BINARY_DIR}/sdk" PARENT_SCOPE)
endfunction()
function(generateSDKDirectory)
setSDKPaths()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/libimhex DESTINATION "${SDK_PATH}/lib" PATTERN "**/source/*" EXCLUDE)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/external DESTINATION "${SDK_PATH}/lib")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/imgui DESTINATION "${SDK_PATH}/lib/third_party" PATTERN "**/source/*" EXCLUDE)
@ -897,4 +900,4 @@ function(precompileHeaders target includeFolder)
PUBLIC
"$<$<COMPILE_LANGUAGE:CXX>:${INCLUDES}>"
)
endfunction()
endfunction()

View File

@ -1,4 +1,5 @@
macro(add_imhex_plugin)
setSDKPaths()
# Parse arguments
set(options LIBRARY_PLUGIN)
set(oneValueArgs NAME IMHEX_VERSION)
@ -28,6 +29,10 @@ macro(add_imhex_plugin)
endif()
endif()
if (IMHEX_PLUGIN_LIBRARY_PLUGIN)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION "${CMAKE_INSTALL_PREFIX}/${SDK_PATH}/lib/plugins/${IMHEX_PLUGIN_NAME}/")
endif()
# Define new project for plugin
project(${IMHEX_PLUGIN_NAME})
@ -151,4 +156,4 @@ macro (enable_plugin_feature feature)
remove_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature}=0)
add_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature}=1)
endmacro()
endmacro()