Skip to content

Commit

Permalink
Actually works now! Ooops.
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Oct 10, 2024
1 parent 01f7565 commit 6145063
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
19 changes: 17 additions & 2 deletions cmake/shared_prologue.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,31 @@ endfunction(macos_bundle_flag)
# location optionally. Called by the target_add_xyz_wrapper functions to allow self contained
# non relinked macos bundles
function(macos_include_clap_in_bundle)
set(oneValueArgs TARGET MACOS_EMBEDDED_CLAP_LOCATION)
set(oneValueArgs
TARGET
MACOS_EMBEDDED_CLAP_LOCATION
MACOSX_EMBEDDED_CLAP_LOCATION
)

cmake_parse_arguments(MBC "" "${oneValueArgs}" "" ${ARGN})

if (NOT DEFINED MBC_MACOS_EMBEDDED_CLAP_LOCATION AND DEFINED MBC_MACOSX_EMBEDDED_CLAP_LOCATION)
# resolve the alias
set(MBC_MACOS_EMBEDDED_CLAP_LOCATION ${MBC_MACOSX_EMBEDDED_CLAP_LOCATION})
endif()

if (NOT DEFINED MBC_MACOSX_EMBEDDED_CLAP_LOCATION AND DEFINED MBC_MACOS_EMBEDDED_CLAP_LOCATION)
# resolve the alias
set(MBC_MACOSX_EMBEDDED_CLAP_LOCATION ${MBC_MACOS_EMBEDDED_CLAP_LOCATION})
endif()

if (NOT APPLE)
message(WARNING "Calling macos_include_clap_in_bundle on non APPLE system. Is this intentional?")
return()
endif()

if (NOT ${MBC_MACOS_EMBEDDED_CLAP_LOCATION} STREQUAL "")
message(STATUS "clap-wraiier: including embedded clap in target ${MBC_TARGET}")
message(STATUS "clap-wrapper: including embedded clap in target ${MBC_TARGET}")
add_custom_command(TARGET ${MBC_TARGET} PRE_BUILD
WORKING_DIRECTORY $<TARGET_PROPERTY:${MBC_TARGET},LIBRARY_OUTPUT_DIRECTORY>
COMMAND ${CMAKE_COMMAND} -E echo "Installing ${MBC_MACOS_EMBEDDED_CLAP_LOCATION} in $<TARGET_PROPERTY:${MBC_TARGET},MACOSX_BUNDLE_BUNDLE_NAME>.$<TARGET_PROPERTY:${MBC_TARGET},BUNDLE_EXTENSION>/Contents/PlugIns/$<TARGET_PROPERTY:${MBC_TARGET},MACOSX_BUNDLE_BUNDLE_NAME>.clap"
Expand Down
16 changes: 15 additions & 1 deletion cmake/wrap_auv2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,24 @@ function(target_add_auv2_wrapper)
# - JUCE (use the JUCE AUV2 default)
DICTIONARY_STREAM_FORMAT

# These two are aliases of each other but the one without the X
# came first and doesn't match the rest of CMake naming standards
MACOS_EMBEDDED_CLAP_LOCATION
MACOSX_EMBEDDED_CLAP_LOCATION
)
cmake_parse_arguments(AUV2 "" "${oneValueArgs}" "" ${ARGN})


if (NOT DEFINED AUV2_MACOS_EMBEDDED_CLAP_LOCATION AND DEFINED AUV2_MACOSX_EMBEDDED_CLAP_LOCATION)
# resolve the alias
set(AUV2_MACOS_EMBEDDED_CLAP_LOCATION ${AUV2_MACOSX_EMBEDDED_CLAP_LOCATION})
endif()

if (NOT DEFINED AUV2_MACOSX_EMBEDDED_CLAP_LOCATION AND DEFINED AUV2_MACOS_EMBEDDED_CLAP_LOCATION)
# resolve the alias
set(AUV2_MACOSX_EMBEDDED_CLAP_LOCATION ${AUV2_MACOS_EMBEDDED_CLAP_LOCATION})
endif()

if (NOT APPLE)
message(STATUS "clap-wrapper: auv2 is only available on macOS")
return()
Expand Down Expand Up @@ -231,7 +245,7 @@ function(target_add_auv2_wrapper)
set_target_properties(${AUV2_TARGET} PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${AUV2_BUNDLE_IDENTIFIER}.component")

macos_include_clap_in_bundle(TARGET ${AUV2_TARGET}
MACOS_EMBEDDED_CLAP_LOCATION ${AUV2_MACOS_EMBEDDED_CLAP_LOCATION})
MACOS_EMBEDDED_CLAP_LOCATION ${AUV2_MACOSX_EMBEDDED_CLAP_LOCATION})
macos_bundle_flag(TARGET ${AUV2_TARGET})

if (${CLAP_WRAPPER_COPY_AFTER_BUILD})
Expand Down
14 changes: 11 additions & 3 deletions src/detail/auv2/build-helper/build-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,17 @@ int main(int argc, char **argv)
try
{
auto p = fs::path{clapfile};
// This is a hack for now - we get to the dll
p = p.parent_path().parent_path().parent_path();
clapfile = p.u8string();
if (fs::is_directory(p))
{
std::cout << " - CLAP is a directory. Assuming bundle\n";
}
else
{
// This is a hack for now - we get to the dll
std::cout << " - CLAP is a regular file. Assuming dll in bundle\n";
p = p.parent_path().parent_path().parent_path();
clapfile = p.u8string();
}
}
catch (const fs::filesystem_error &e)
{
Expand Down

0 comments on commit 6145063

Please sign in to comment.