Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Allow specifying list of plugin dependencies for IDE launch schemes #1692

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions cmake/ide_helpers.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

option(IMHEX_IDE_HELPERS_OVERRIDE_XCODE_COMPILER "Enable choice of compiler for Xcode builds, despite CMake's best efforts" OFF)
option(IMHEX_IDE_HELPERS_INTRUSIVE_IDE_TWEAKS "Enable intrusive CMake tweaks to better support IDEs with folder support" OFF)
option(IMHEX_IDE_HELPERS_MAIN_DEPENDS_ON_PLUGINS "Make main executable target depend on plugins for conveinience" OFF)

# The CMake infrastructure silently ignores the CMAKE_<>_COMPILER settings when
# using the `Xcode` generator.
Expand Down Expand Up @@ -30,9 +31,6 @@ if (IMHEX_IDE_HELPERS_OVERRIDE_XCODE_COMPILER AND CMAKE_GENERATOR STREQUAL "Xcod
set(CMAKE_XCODE_ATTRIBUTE_COMPILER_INDEX_STORE_ENABLE "NO")
endif()

# Generate a launch/build scheme for all targets
set(CMAKE_XCODE_GENERATE_SCHEME YES)

# Utility function that helps avoid messing with non-standard targets
macro(returnIfTargetIsNonTweakable target)
get_target_property(targetIsAliased ${target} ALIASED_TARGET)
Expand Down Expand Up @@ -121,9 +119,17 @@ function(_tweakTarget target path)
if (${targetType} MATCHES "EXECUTABLE|LIBRARY")
set_target_properties(${target} PROPERTIES FOLDER "${path}")
endif()

if (IMHEX_IDE_HELPERS_MAIN_DEPENDS_ON_PLUGINS)
get_target_property(imhexPlugin ${target} IMHEX_PLUGIN)

if (imhexPlugin)
add_dependencies(main ${target})
endif()
endif()
endfunction()

macro(_tweakTargetsRecursive dir)
function(_tweakTargetsRecursive dir)
get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
foreach(subdir IN LISTS subdirectories)
_tweakTargetsRecursive("${subdir}")
Expand All @@ -139,11 +145,18 @@ macro(_tweakTargetsRecursive dir)
foreach(target ${targets})
_tweakTarget(${target} "${rdir}")
endforeach()
endmacro()
endfunction()

# Tweak all targets this CMake build is aware about
function(tweakTargetsForIDESupport)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

_tweakTargetsRecursive("${CMAKE_SOURCE_DIR}")

if (XCODE)
# Make sure a scheme is generated for main in all cases
set_target_properties(main PROPERTIES
XCODE_GENERATE_SCHEME ON
)
endif()
endfunction()
6 changes: 6 additions & 0 deletions cmake/modules/ImHexPlugin.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
define_property(TARGET PROPERTY IMHEX_PLUGIN
BRIEF_DOCS "Property marking targets as an ImHex plugin for IDE integration"
FULL_DOCS "Property marking targets as an ImHex plugin for IDE integration"
)

macro(add_imhex_plugin)
# Parse arguments
set(options LIBRARY_PLUGIN)
Expand Down Expand Up @@ -59,6 +64,7 @@ macro(add_imhex_plugin)
CXX_STANDARD 23
PREFIX ""
SUFFIX ${IMHEX_PLUGIN_SUFFIX}
IMHEX_PLUGIN YES
)

# Set rpath of plugin libraries to the plugins folder
Expand Down
Loading