nixpkgs/pkgs/tools/graphics/vulkan-tools/use-nix-moltenvk.patch

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

124 lines
6.5 KiB
Diff
Raw Normal View History

diff --git a/cube/CMakeLists.txt b/cube/CMakeLists.txt
2023-01-30 20:22:14 +01:00
index a2f026e7..327f5dba 100644
--- a/cube/CMakeLists.txt
+++ b/cube/CMakeLists.txt
2023-01-30 20:22:14 +01:00
@@ -257,14 +257,7 @@ else()
endif()
if(APPLE)
- # Keep RPATH so fixup_bundle can use it to find libraries
- set_target_properties(vkcube PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
- install(TARGETS vkcube BUNDLE DESTINATION "cube")
- # Fix up the library references to be self-contained within the bundle.
- install(CODE "
- include(BundleUtilities)
- fixup_bundle(\${CMAKE_INSTALL_PREFIX}/cube/vkcube.app \"\" \"${Vulkan_LIBRARY_DIR}\")
- ")
+ install(TARGETS vkcube BUNDLE DESTINATION "Applications")
else()
install(TARGETS vkcube RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
2023-01-30 20:22:14 +01:00
@@ -302,14 +295,7 @@ else()
endif()
if(APPLE)
- # Keep RPATH so fixup_bundle can use it to find libraries
- set_target_properties(vkcubepp PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
- install(TARGETS vkcubepp BUNDLE DESTINATION "cube")
- # Fix up the library references to be self-contained within the bundle.
- install(CODE "
- include(BundleUtilities)
- fixup_bundle(\${CMAKE_INSTALL_PREFIX}/cube/vkcubepp.app \"\" \"${Vulkan_LIBRARY_DIR}\")
- ")
+ install(TARGETS vkcubepp BUNDLE DESTINATION "Applications")
else()
install(TARGETS vkcubepp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
diff --git a/cube/macOS/cube/cube.cmake b/cube/macOS/cube/cube.cmake
2023-01-30 20:22:14 +01:00
index 9b823f95..0c43a2c9 100644
--- a/cube/macOS/cube/cube.cmake
+++ b/cube/macOS/cube/cube.cmake
2023-01-30 20:22:14 +01:00
@@ -72,12 +72,14 @@ set_source_files_properties("${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json"
# Copy the MoltenVK lib into the bundle.
if(${CMAKE_GENERATOR} MATCHES "^Xcode.*")
add_custom_command(TARGET vkcube POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/dylib/macOS/libMoltenVK.dylib"
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/vkcube.app/Contents/Frameworks
+ COMMAND ${CMAKE_COMMAND} -E create_symlink "${MOLTENVK_DIR}/lib/libMoltenVK.dylib"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/vkcube.app/Contents/Frameworks/libMoltenVK.dylib
DEPENDS vulkan)
else()
add_custom_command(TARGET vkcube POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/dylib/macOS/libMoltenVK.dylib"
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/vkcube.app/Contents/Frameworks
+ COMMAND ${CMAKE_COMMAND} -E create_symlink "${MOLTENVK_DIR}/lib/libMoltenVK.dylib"
${CMAKE_CURRENT_BINARY_DIR}/vkcube.app/Contents/Frameworks/libMoltenVK.dylib
DEPENDS vulkan)
endif()
diff --git a/cube/macOS/cubepp/cubepp.cmake b/cube/macOS/cubepp/cubepp.cmake
2023-01-30 20:22:14 +01:00
index eae4de3c..e528ae26 100644
--- a/cube/macOS/cubepp/cubepp.cmake
+++ b/cube/macOS/cubepp/cubepp.cmake
2023-01-30 20:22:14 +01:00
@@ -74,12 +74,14 @@ set_source_files_properties("${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json"
# Copy the MoltenVK lib into the bundle.
if(${CMAKE_GENERATOR} MATCHES "^Xcode.*")
add_custom_command(TARGET vkcubepp POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/dylib/macOS/libMoltenVK.dylib"
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/vkcubepp.app/Contents/Frameworks
+ COMMAND ${CMAKE_COMMAND} -E create_symlink "${MOLTENVK_DIR}/lib/libMoltenVK.dylib"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/vkcubepp.app/Contents/Frameworks/libMoltenVK.dylib
DEPENDS vulkan)
else()
add_custom_command(TARGET vkcubepp POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/dylib/macOS/libMoltenVK.dylib"
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/vkcubepp.app/Contents/Frameworks
+ COMMAND ${CMAKE_COMMAND} -E create_symlink "${MOLTENVK_DIR}/lib/libMoltenVK.dylib"
${CMAKE_CURRENT_BINARY_DIR}/vkcubepp.app/Contents/Frameworks/libMoltenVK.dylib
DEPENDS vulkan)
endif()
diff --git a/mac_common.cmake b/mac_common.cmake
index bad3c414..b498906d 100644
--- a/mac_common.cmake
+++ b/mac_common.cmake
@@ -23,9 +23,8 @@ set(MOLTENVK_DIR ${MOLTENVK_REPO_ROOT})
# MoltenVK JSON File
execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/staging-json)
-execute_process(COMMAND sed -e "/\"library_path\":/s$:[[:space:]]*\"[[:space:]]*[\\.\\/]*$: \"..\\/..\\/..\\/Frameworks\\/$"
- ${MOLTENVK_DIR}/MoltenVK/icd/MoltenVK_icd.json
- OUTPUT_FILE ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json)
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${MOLTENVK_DIR}/MoltenVK_icd.json
+ ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json)
# ~~~
# Modify the ICD JSON file to adjust the library path.
@@ -36,10 +35,9 @@ execute_process(COMMAND sed -e "/\"library_path\":/s$:[[:space:]]*\"[[:space:]]*
# ~~~
add_custom_target(MoltenVK_icd-staging-json ALL
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/staging-json
- COMMAND sed -e "/\"library_path\":/s$:[[:space:]]*\"[[:space:]]*[\\.\\/]*$: \"..\\/..\\/..\\/Frameworks\\/$"
- ${MOLTENVK_DIR}/MoltenVK/icd/MoltenVK_icd.json > ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json
- VERBATIM
- DEPENDS "${MOLTENVK_DIR}/MoltenVK/icd/MoltenVK_icd.json")
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${MOLTENVK_DIR}/MoltenVK_icd.json
+ ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json
+ DEPENDS "${MOLTENVK_DIR}/MoltenVK_icd.json")
set_source_files_properties(${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json PROPERTIES GENERATED TRUE)
find_library(COCOA NAMES Cocoa)
diff --git a/vulkaninfo/CMakeLists.txt b/vulkaninfo/CMakeLists.txt
2023-01-30 20:22:14 +01:00
index d23dcf89..32aa0ebb 100644
--- a/vulkaninfo/CMakeLists.txt
+++ b/vulkaninfo/CMakeLists.txt
2023-01-30 20:22:14 +01:00
@@ -136,9 +136,5 @@ elseif(APPLE)
add_definitions(-DVK_USE_PLATFORM_MACOS_MVK -DVK_USE_PLATFORM_METAL_EXT)
endif()
-if(APPLE)
- install(TARGETS vulkaninfo RUNTIME DESTINATION "vulkaninfo")
-else()
- install(TARGETS vulkaninfo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-endif()
+install(TARGETS vulkaninfo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})