build: Fix external plugins not having a imhex version set

This commit is contained in:
WerWolv 2024-01-04 12:01:40 +01:00
parent f03bdc5f45
commit 0097d1782e
2 changed files with 15 additions and 7 deletions

View File

@ -1,10 +1,15 @@
macro(add_imhex_plugin)
# Parse arguments
set(options LIBRARY_PLUGIN)
set(oneValueArgs NAME)
set(oneValueArgs NAME IMHEX_VERSION)
set(multiValueArgs SOURCES INCLUDES LIBRARIES FEATURES)
cmake_parse_arguments(IMHEX_PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (IMHEX_PLUGIN_IMHEX_VERSION)
message(STATUS "Compiling plugin ${IMHEX_PLUGIN_NAME} for ImHex Version ${IMHEX_PLUGIN_IMHEX_VERSION}")
set(IMHEX_VERSION_STRING "${IMHEX_PLUGIN_IMHEX_VERSION}")
endif()
if (IMHEX_STATIC_LINK_PLUGINS)
set(IMHEX_PLUGIN_LIBRARY_TYPE STATIC)
@ -65,18 +70,18 @@ macro(add_imhex_plugin)
add_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature}=0)
endforeach()
# Fix rpath
if (APPLE)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES INSTALL_RPATH "@executable_path/../Frameworks")
endif()
# Add the new plugin to the main dependency list so it gets built by default
if (TARGET imhex_all)
add_dependencies(imhex_all ${IMHEX_PLUGIN_NAME})
endif()
if (IMHEX_EXTERNAL_PLUGIN_BUILD)
install(TARGETS ${IMHEX_PLUGIN_NAME} DESTINATION ".")
# Fix rpath
if (APPLE)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES INSTALL_RPATH "@executable_path/../Frameworks")
endif()
endif()
endmacro()

View File

@ -122,6 +122,7 @@ else()
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE RESULT_BRANCH
ERROR_QUIET
)
# Get the latest abbreviated commit hash of the working branch
@ -131,6 +132,7 @@ else()
OUTPUT_VARIABLE GIT_COMMIT_HASH_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE RESULT_HASH_SHORT
ERROR_QUIET
)
execute_process(
@ -139,6 +141,7 @@ else()
OUTPUT_VARIABLE GIT_COMMIT_HASH_LONG
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE RESULT_HASH_LONG
ERROR_QUIET
)
endif ()