diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-01-10 04:52:09 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-01-10 04:52:09 +0000 |
| commit | 91d13074d5c3acd938c1514de1bbb95f57e85736 (patch) | |
| tree | 6d5fef02c0504084e175f69ec1a97555fd557665 /unityplugin/GhostCubePlugin/PluginSource | |
| parent | Updated copyright notice on iOS startup screen (diff) | |
| download | DiligentEngine-91d13074d5c3acd938c1514de1bbb95f57e85736.tar.gz DiligentEngine-91d13074d5c3acd938c1514de1bbb95f57e85736.zip | |
Fixed Unity plugin on MacOS
Diffstat (limited to 'unityplugin/GhostCubePlugin/PluginSource')
| -rw-r--r-- | unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt b/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt index 4275979..acac459 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt +++ b/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt @@ -59,8 +59,7 @@ if(MSVC) source_group("src" FILES src/RenderingPlugin.def) endif() -target_link_libraries(GhostCubePlugin-shared -PRIVATE +set(PRIVATE_DEPENDENCIES BuildSettings TargetPlatform Common @@ -69,19 +68,33 @@ PRIVATE ) if(D3D11_SUPPORTED) - target_link_libraries(GhostCubePlugin-shared PRIVATE GraphicsEngineD3D11-static) + list(APPEND PRIVATE_DEPENDENCIES GraphicsEngineD3D11-static) endif() if(D3D12_SUPPORTED) - target_link_libraries(GhostCubePlugin-shared PRIVATE GraphicsEngineD3D12-static) + list(APPEND PRIVATE_DEPENDENCIES GraphicsEngineD3D12-static) endif() if(GL_SUPPORTED OR GLES_SUPPORTED) - target_link_libraries(GhostCubePlugin-shared PRIVATE GraphicsEngineOpenGL-static) + list(APPEND PRIVATE_DEPENDENCIES GraphicsEngineOpenGL-static) endif() +target_link_libraries(GhostCubePlugin-shared PRIVATE ${PRIVATE_DEPENDENCIES}) set_common_target_properties(GhostCubePlugin-shared) +if(PLATFORM_MACOS) + # Unity wants plugin be packaged as bundle on MacOS + add_library(GhostCubePlugin-bundle MODULE + ${SOURCE} ${INCLUDE} ${UNITY_INTERFACES} + ) + set_target_properties(GhostCubePlugin-bundle PROPERTIES + BUNDLE TRUE + FOLDER Unity + ) + target_link_libraries(GhostCubePlugin-bundle PRIVATE ${PRIVATE_DEPENDENCIES}) + set_common_target_properties(GhostCubePlugin-bundle) +endif() + if(PLATFORM_WIN32) target_compile_definitions(GhostCubePlugin-shared PRIVATE UNITY_WIN=1) elseif(PLATFORM_UNIVERSAL_WINDOWS) @@ -92,6 +105,7 @@ elseif(PLATFORM_LINUX) target_compile_definitions(GhostCubePlugin-shared PRIVATE UNITY_LINUX=1) elseif(PLATFORM_MACOS) target_compile_definitions(GhostCubePlugin-shared PRIVATE UNITY_OSX=1) + target_compile_definitions(GhostCubePlugin-bundle PRIVATE UNITY_OSX=1) elseif(PLATFORM_IOS) target_compile_definitions(GhostCubePlugin-shared PRIVATE UNITY_IPHONE=1) endif() @@ -129,16 +143,22 @@ elseif(PLATFORM_ANDROID) elseif(PLATFORM_LINUX) set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/libGhostCubePlugin.so) elseif(PLATFORM_MACOS) - set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/MacOS/libGhostCubePlugin.so) + set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/MacOS/GhostCubePlugin.bundle) elseif(PLATFORM_IOS) message(WARNING "No unity plugin path specified") else() message(FATAL_ERROR "Unsupported platform") endif() -add_custom_command(TARGET GhostCubePlugin-shared POST_BUILD +if(PLATFORM_MACOS) + set(PLUGIN_TARGET GhostCubePlugin-bundle) +else() + set(PLUGIN_TARGET GhostCubePlugin-shared) +endif() + +add_custom_command(TARGET ${PLUGIN_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - "\"$<TARGET_FILE:GhostCubePlugin-shared>\"" + "\"$<TARGET_FILE:${PLUGIN_TARGET}>\"" "${UNITY_PLUGIN_PATH}" ) |
