From a6e0668626de73d6d35f14a2fb9d3ee9a73e8ae3 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 12 Feb 2018 20:51:23 -0800 Subject: Fixed formatting of cmake files + some minor updates --- .../GhostCubePlugin/PluginSource/CMakeLists.txt | 136 +++++++++-------- unityplugin/GhostCubeScene/CMakeLists.txt | 122 +++++++-------- unityplugin/UnityEmulator/CMakeLists.txt | 168 ++++++++++----------- 3 files changed, 215 insertions(+), 211 deletions(-) (limited to 'unityplugin') diff --git a/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt b/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt index 95871e8..7fe077c 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt +++ b/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt @@ -3,132 +3,136 @@ cmake_minimum_required (VERSION 3.6) project(GhostCubePlugin CXX) set(SOURCE - src/RenderAPI.cpp - src/RenderingPlugin.cpp - src/SamplePlugin.cpp + src/RenderAPI.cpp + src/RenderingPlugin.cpp + src/SamplePlugin.cpp ) set(INCLUDE - src/PlatformBase.h - src/RenderAPI.h - src/SamplePlugin.h + src/PlatformBase.h + src/RenderAPI.h + src/SamplePlugin.h ) if(D3D11_SUPPORTED) - list(APPEND SOURCE src/RenderAPI_D3D11.cpp) + list(APPEND SOURCE src/RenderAPI_D3D11.cpp) endif() if(D3D12_SUPPORTED) - list(APPEND SOURCE src/RenderAPI_D3D12.cpp) + list(APPEND SOURCE src/RenderAPI_D3D12.cpp) endif() if(GL_SUPPORTED OR GLES_SUPPORTED) - list(APPEND SOURCE src/RenderAPI_OpenGLCoreES.cpp) + list(APPEND SOURCE src/RenderAPI_OpenGLCoreES.cpp) endif() set(UNITY_INTERFACES - src/Unity/IUnityGraphics.h - src/Unity/IUnityGraphicsD3D9.h - src/Unity/IUnityGraphicsD3D11.h - src/Unity/IUnityGraphicsD3D12.h - src/Unity/IUnityGraphicsMetal.h - src/Unity/IUnityInterface.h + src/Unity/IUnityGraphics.h + src/Unity/IUnityGraphicsD3D9.h + src/Unity/IUnityGraphicsD3D11.h + src/Unity/IUnityGraphicsD3D12.h + src/Unity/IUnityGraphicsMetal.h + src/Unity/IUnityInterface.h ) add_library(GhostCubePlugin-shared SHARED - ${SOURCE} ${INCLUDE} ${UNITY_INTERFACES} + ${SOURCE} ${INCLUDE} ${UNITY_INTERFACES} ) set(DLL_REL_SUFFIX _${ARCH}r) set(DLL_DBG_SUFFIX _${ARCH}d) set_target_properties(GhostCubePlugin-shared PROPERTIES - OUTPUT_NAME_DEBUG GhostCubePlugin${DLL_DBG_SUFFIX} - OUTPUT_NAME_RELEASE GhostCubePlugin${DLL_REL_SUFFIX} - OUTPUT_NAME_RELWITHDEBINFO GhostCubePlugin${DLL_REL_SUFFIX} - OUTPUT_NAME_MINSIZEREL GhostCubePlugin${DLL_REL_SUFFIX} + OUTPUT_NAME_DEBUG GhostCubePlugin${DLL_DBG_SUFFIX} + OUTPUT_NAME_RELEASE GhostCubePlugin${DLL_REL_SUFFIX} + OUTPUT_NAME_RELWITHDEBINFO GhostCubePlugin${DLL_REL_SUFFIX} + OUTPUT_NAME_MINSIZEREL GhostCubePlugin${DLL_REL_SUFFIX} ) if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS) - target_sources(GhostCubePlugin-shared - PRIVATE - src/RenderingPlugin.def - ) - source_group("src" FILES src/RenderingPlugin.def) + target_sources(GhostCubePlugin-shared + PRIVATE + src/RenderingPlugin.def + ) + source_group("src" FILES src/RenderingPlugin.def) endif() target_link_libraries(GhostCubePlugin-shared PRIVATE - BuildSettings - TargetPlatform - Common - GraphicsAccessories - GraphicsTools + BuildSettings + TargetPlatform + Common + GraphicsAccessories + GraphicsTools ) if(D3D11_SUPPORTED) - target_link_libraries(GhostCubePlugin-shared PRIVATE GraphicsEngineD3D11-static) + target_link_libraries(GhostCubePlugin-shared PRIVATE GraphicsEngineD3D11-static) endif() if(D3D12_SUPPORTED) - target_link_libraries(GhostCubePlugin-shared PRIVATE GraphicsEngineD3D12-static) + target_link_libraries(GhostCubePlugin-shared PRIVATE GraphicsEngineD3D12-static) endif() if(GL_SUPPORTED OR GLES_SUPPORTED) - target_link_libraries(GhostCubePlugin-shared PRIVATE GraphicsEngineOpenGL-static) + target_link_libraries(GhostCubePlugin-shared PRIVATE GraphicsEngineOpenGL-static) endif() set_common_target_properties(GhostCubePlugin-shared) if(MSVC) - # Disable MSVC-specific warnings - # - w4201: nonstandard extension used: nameless struct/unio - target_compile_options(GhostCubePlugin-shared PRIVATE /wd4201) - if(PLATFORM_UNIVERSAL_WINDOWS) - target_compile_definitions(GhostCubePlugin-shared PRIVATE WINDOWS_UWP UNITY_METRO) - endif() + # Disable MSVC-specific warnings + # - w4201: nonstandard extension used: nameless struct/unio + target_compile_options(GhostCubePlugin-shared PRIVATE /wd4201) + if(PLATFORM_UNIVERSAL_WINDOWS) + target_compile_definitions(GhostCubePlugin-shared PRIVATE WINDOWS_UWP UNITY_METRO) + endif() endif() if(PLATFORM_ANDROID) - target_compile_definitions(GhostCubePlugin-shared PRIVATE UNITY_ANDROID) - set_target_properties(GhostCubePlugin-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) # -fvisibility=hidden + target_compile_definitions(GhostCubePlugin-shared PRIVATE UNITY_ANDROID) elseif(PLATFORM_LINUX) - target_compile_definitions(GhostCubePlugin-shared PRIVATE UNITY_LINUX) - set_target_properties(GhostCubePlugin-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) # -fvisibility=hidden + target_compile_definitions(GhostCubePlugin-shared PRIVATE UNITY_LINUX) endif() +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR + CMAKE_CXX_COMPILER_ID MATCHES "GNU") + set_target_properties(GhostCubePlugin-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) # -fvisibility=hidden +endif() + + set(UNITY_PLUGIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../UnityProject/Assets/Plugins) if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS) - if(PLATFORM_WIN32) - if(ARCH EQUAL 64) - set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/x86_64) - else() - set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/x86) - endif() - elseif(PLATFORM_UNIVERSAL_WINDOWS) - if(ARCH EQUAL 64) - set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/Metro/UWP/x64) - else() - set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/Metro/UWP/x86) - endif() - endif() - set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/GhostCubePlugin.dll) + if(PLATFORM_WIN32) + if(ARCH EQUAL 64) + set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/x86_64) + else() + set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/x86) + endif() + elseif(PLATFORM_UNIVERSAL_WINDOWS) + if(ARCH EQUAL 64) + set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/Metro/UWP/x64) + else() + set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/Metro/UWP/x86) + endif() + endif() + set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/GhostCubePlugin.dll) elseif(PLATFORM_ANDROID) - set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/Android/libGhostCubePlugin.so) + set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/Android/libGhostCubePlugin.so) elseif(PLATFORM_LINUX) - set(UNITY_PLUGIN_PATH ${UNITY_PLUGIN_PATH}/libGhostCubePlugin.so) + 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/libGhostCubePlugin.so) elseif(PLATFORM_IOS) - message(WARNING "No unity plugin path specified") + message(WARNING "No unity plugin path specified") else() - message(FATAL_ERROR "Unsupported platform") + message(FATAL_ERROR "Unsupported platform") endif() add_custom_command(TARGET GhostCubePlugin-shared POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "\"$\"" - "${UNITY_PLUGIN_PATH}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "\"$\"" + "${UNITY_PLUGIN_PATH}" ) source_group("src" FILES ${SOURCE}) @@ -136,5 +140,5 @@ source_group("include" FILES ${INCLUDE}) source_group("include\\Unity" FILES ${UNITY_INTERFACES}) set_target_properties(GhostCubePlugin-shared PROPERTIES - FOLDER Unity + FOLDER Unity ) diff --git a/unityplugin/GhostCubeScene/CMakeLists.txt b/unityplugin/GhostCubeScene/CMakeLists.txt index ffb9929..e6cb23a 100644 --- a/unityplugin/GhostCubeScene/CMakeLists.txt +++ b/unityplugin/GhostCubeScene/CMakeLists.txt @@ -3,74 +3,74 @@ cmake_minimum_required (VERSION 3.6) project(GhostCubeScene CXX) set(SOURCE - src/GhostCubeScene.cpp + src/GhostCubeScene.cpp ) set(INCLUDE - src/GhostCubeScene.h + src/GhostCubeScene.h ) set(SHADERS - assets/shaders/Mirror.psh - assets/shaders/Mirror.vsh + assets/shaders/Mirror.psh + assets/shaders/Mirror.vsh ) set(ALL_ASSETS ${SHADERS}) set_source_files_properties(${SHADERS} PROPERTIES VS_TOOL_OVERRIDE "None") if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS) - list(APPEND SOURCE src/GhostCubeSceneResTrsnHelper.cpp) - list(APPEND INCLUDE src/GhostCubeSceneResTrsnHelper.h) + list(APPEND SOURCE src/GhostCubeSceneResTrsnHelper.cpp) + list(APPEND INCLUDE src/GhostCubeSceneResTrsnHelper.h) elseif(PLATFORM_ANDROID OR PLATFORM_LINUX OR PLATFORM_MACOS OR PLATFORM_IOS) - list(APPEND SOURCE src/LoadPluginFunctions.cpp) + list(APPEND SOURCE src/LoadPluginFunctions.cpp) endif() - + set_source_files_properties(${SHADERS} PROPERTIES - VS_DEPLOYMENT_CONTENT 1 - VS_DEPLOYMENT_LOCATION "shaders" - MACOSX_PACKAGE_LOCATION "Resources/shaders" + VS_DEPLOYMENT_CONTENT 1 + VS_DEPLOYMENT_LOCATION "shaders" + MACOSX_PACKAGE_LOCATION "Resources/shaders" ) add_target_platform_app(GhostCubeScene "${SOURCE}" "${INCLUDE}" "${ALL_ASSETS}") if(PLATFORM_WIN32) - set_target_properties(GhostCubeScene PROPERTIES - VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets" - ) - - add_custom_command(TARGET GhostCubeScene POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "\"$\"" - "\"$\"") + set_target_properties(GhostCubeScene PROPERTIES + VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets" + ) + + add_custom_command(TARGET GhostCubeScene POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "\"$\"" + "\"$\"") elseif(PLATFORM_UNIVERSAL_WINDOWS) - append_emulator_uwp_source(GhostCubeScene) - - # We cannot use genreator expression to add a file because the file name - # must not depend on the configuration - set(PLUGIN_REL_DLL ${CMAKE_CURRENT_BINARY_DIR}/GhostCubePlugin_${ARCH}r.dll) - set(PLUGIN_DBG_DLL ${CMAKE_CURRENT_BINARY_DIR}/GhostCubePlugin_${ARCH}d.dll) - - set(PLUGIN_DLLS ${PLUGIN_REL_DLL} ${PLUGIN_DBG_DLL}) - set_source_files_properties(${PLUGIN_DLLS} PROPERTIES GENERATED TRUE) - set_source_files_properties(${PLUGIN_DBG_DLL} PROPERTIES - VS_DEPLOYMENT_CONTENT $ - VS_DEPLOYMENT_LOCATION "." - ) - set_source_files_properties(${PLUGIN_REL_DLL} PROPERTIES - VS_DEPLOYMENT_CONTENT $> - VS_DEPLOYMENT_LOCATION "." - ) - - add_custom_command(TARGET GhostCubeScene PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "\"$\"" - "${CMAKE_CURRENT_BINARY_DIR}/$" - ) - - target_sources(GhostCubeScene PRIVATE ${PLUGIN_DLLS}) - source_group("assets" FILES ${PLUGIN_DLLS}) + append_emulator_uwp_source(GhostCubeScene) + + # We cannot use genreator expression to add a file because the file name + # must not depend on the configuration + set(PLUGIN_REL_DLL ${CMAKE_CURRENT_BINARY_DIR}/GhostCubePlugin_${ARCH}r.dll) + set(PLUGIN_DBG_DLL ${CMAKE_CURRENT_BINARY_DIR}/GhostCubePlugin_${ARCH}d.dll) + + set(PLUGIN_DLLS ${PLUGIN_REL_DLL} ${PLUGIN_DBG_DLL}) + set_source_files_properties(${PLUGIN_DLLS} PROPERTIES GENERATED TRUE) + set_source_files_properties(${PLUGIN_DBG_DLL} PROPERTIES + VS_DEPLOYMENT_CONTENT $ + VS_DEPLOYMENT_LOCATION "." + ) + set_source_files_properties(${PLUGIN_REL_DLL} PROPERTIES + VS_DEPLOYMENT_CONTENT $> + VS_DEPLOYMENT_LOCATION "." + ) + + add_custom_command(TARGET GhostCubeScene PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "\"$\"" + "${CMAKE_CURRENT_BINARY_DIR}/$" + ) + + target_sources(GhostCubeScene PRIVATE ${PLUGIN_DLLS}) + source_group("assets" FILES ${PLUGIN_DLLS}) endif() @@ -79,20 +79,20 @@ add_dependencies(GhostCubeScene GhostCubePlugin-shared) target_include_directories(GhostCubeScene PRIVATE - ../GhostCubePlugin/PluginSource/src/Unity + ../GhostCubePlugin/PluginSource/src/Unity ) target_link_libraries(GhostCubeScene PRIVATE - BuildSettings - NativeAppBase - UnityEmulator - TargetPlatform + BuildSettings + NativeAppBase + UnityEmulator + TargetPlatform ) if(PLATFORM_ANDROID) - target_link_libraries(GhostCubeScene PRIVATE GhostCubePlugin-shared) + target_link_libraries(GhostCubeScene PRIVATE GhostCubePlugin-shared) elseif (PLATFORM_LINUX) - target_link_libraries(GhostCubeScene PRIVATE GhostCubePlugin-shared GL X11) + target_link_libraries(GhostCubeScene PRIVATE GhostCubePlugin-shared GL X11) elseif (PLATFORM_MACOS OR PLATFORM_IOS) target_link_libraries(GhostCubeScene PRIVATE GhostCubePlugin-shared) endif() @@ -100,14 +100,14 @@ endif() set_common_target_properties(GhostCubeScene) if(MSVC) - # Disable MSVC-specific warnings - # - w4201: nonstandard extension used: nameless struct/union - target_compile_options(GhostCubeScene PRIVATE /wd4201) - - if(PLATFORM_UNIVERSAL_WINDOWS) - # Consume the windows runtime extensions - target_compile_options(GhostCubeScene PRIVATE /ZW) - endif() + # Disable MSVC-specific warnings + # - w4201: nonstandard extension used: nameless struct/union + target_compile_options(GhostCubeScene PRIVATE /wd4201) + + if(PLATFORM_UNIVERSAL_WINDOWS) + # Consume the windows runtime extensions + target_compile_options(GhostCubeScene PRIVATE /ZW) + endif() endif() source_group("src" FILES ${SOURCE}) @@ -115,5 +115,5 @@ source_group("include" FILES ${INCLUDE}) source_group("assets\\shaders" FILES ${SHADERS}) set_target_properties(GhostCubeScene PROPERTIES - FOLDER Unity + FOLDER Unity ) diff --git a/unityplugin/UnityEmulator/CMakeLists.txt b/unityplugin/UnityEmulator/CMakeLists.txt index bd6fcc1..fed3cf5 100644 --- a/unityplugin/UnityEmulator/CMakeLists.txt +++ b/unityplugin/UnityEmulator/CMakeLists.txt @@ -3,102 +3,102 @@ cmake_minimum_required (VERSION 3.6) project(UnityEmulator CXX) set(SOURCE - src/UnityGraphicsEmulator.cpp + src/UnityGraphicsEmulator.cpp ) set(INCLUDE - include/DiligentGraphicsAdapter.h - include/ResourceStateTransitionHandler.h - include/UnityGraphicsEmulator.h - include/UnitySceneBase.h + include/DiligentGraphicsAdapter.h + include/ResourceStateTransitionHandler.h + include/UnityGraphicsEmulator.h + include/UnitySceneBase.h ) if(D3D11_SUPPORTED) - list(APPEND SOURCE src/DiligentGraphicsAdapterD3D11.cpp) - list(APPEND SOURCE src/UnityGraphicsD3D11Emulator.cpp) - list(APPEND SOURCE src/UnityGraphicsD3D11Impl.h) - list(APPEND INCLUDE include/DiligentGraphicsAdapterD3D11.h) - list(APPEND INCLUDE include/UnityGraphicsD3D11Emulator.h) + list(APPEND SOURCE src/DiligentGraphicsAdapterD3D11.cpp) + list(APPEND SOURCE src/UnityGraphicsD3D11Emulator.cpp) + list(APPEND SOURCE src/UnityGraphicsD3D11Impl.h) + list(APPEND INCLUDE include/DiligentGraphicsAdapterD3D11.h) + list(APPEND INCLUDE include/UnityGraphicsD3D11Emulator.h) endif() if(D3D12_SUPPORTED) - list(APPEND SOURCE src/DiligentGraphicsAdapterD3D12.cpp) - list(APPEND SOURCE src/UnityGraphicsD3D12Emulator.cpp) - list(APPEND SOURCE src/UnityGraphicsD3D12Impl.h) - - list(APPEND INCLUDE include/DiligentGraphicsAdapterD3D12.h) - list(APPEND INCLUDE include/UnityGraphicsD3D12Emulator.h) + list(APPEND SOURCE src/DiligentGraphicsAdapterD3D12.cpp) + list(APPEND SOURCE src/UnityGraphicsD3D12Emulator.cpp) + list(APPEND SOURCE src/UnityGraphicsD3D12Impl.h) + + list(APPEND INCLUDE include/DiligentGraphicsAdapterD3D12.h) + list(APPEND INCLUDE include/UnityGraphicsD3D12Emulator.h) endif() if(GL_SUPPORTED OR GLES_SUPPORTED) - list(APPEND SOURCE src/UnityGraphicsGLCoreES_Emulator.cpp) - list(APPEND SOURCE src/DiligentGraphicsAdapterGL.cpp) + list(APPEND SOURCE src/UnityGraphicsGLCoreES_Emulator.cpp) + list(APPEND SOURCE src/DiligentGraphicsAdapterGL.cpp) - list(APPEND INCLUDE include/UnityGraphicsGLCoreES_Emulator.h) - list(APPEND INCLUDE include/DiligentGraphicsAdapterGL.h) + list(APPEND INCLUDE include/UnityGraphicsGLCoreES_Emulator.h) + list(APPEND INCLUDE include/DiligentGraphicsAdapterGL.h) endif() if(GL_SUPPORTED) - list(APPEND SOURCE src/UnityGraphicsGLCore_Impl.cpp) - list(APPEND INCLUDE src/UnityGraphicsGLCore_Impl.h) + list(APPEND SOURCE src/UnityGraphicsGLCore_Impl.cpp) + list(APPEND INCLUDE src/UnityGraphicsGLCore_Impl.h) endif() if(GLES_SUPPORTED) - if(PLATFORM_ANDROID) - list(APPEND SOURCE src/Android/UnityGraphicsGLESAndroid_Impl.cpp) - list(APPEND INCLUDE src/Android/UnityGraphicsGLESAndroid_Impl.h) - elseif(PLATFORM_IOS) - list(APPEND SOURCE src/IOS/UnityGraphicsGLES_IOS_Impl.mm) - list(APPEND INCLUDE src/IOS/UnityGraphicsGLES_IOS_Impl.h) - else() - message(FATAL_ERROR Unknown platform) - endif() + if(PLATFORM_ANDROID) + list(APPEND SOURCE src/Android/UnityGraphicsGLESAndroid_Impl.cpp) + list(APPEND INCLUDE src/Android/UnityGraphicsGLESAndroid_Impl.h) + elseif(PLATFORM_IOS) + list(APPEND SOURCE src/IOS/UnityGraphicsGLES_IOS_Impl.mm) + list(APPEND INCLUDE src/IOS/UnityGraphicsGLES_IOS_Impl.h) + else() + message(FATAL_ERROR Unknown platform) + endif() endif() if(PLATFORM_WIN32) - list(APPEND SOURCE src/Windows/UnityAppWin32.cpp src/UnityAppBase.cpp) - list(APPEND INCLUDE include/UnityAppBase.h) - + list(APPEND SOURCE src/Windows/UnityAppWin32.cpp src/UnityAppBase.cpp) + list(APPEND INCLUDE include/UnityAppBase.h) + elseif(PLATFORM_UNIVERSAL_WINDOWS) - # Windows Runtime types cannot be included into static libraries - # https://social.msdn.microsoft.com/Forums/en-US/269db513-64ef-4817-a025-43954f614eb3/lnk4264-why-are-static-libraries-not-recommended-when-authoring-windows-runtime-types?forum=winappswithnativecode - # So as a workaround, we will include all source files into the target app project - function(append_emulator_uwp_source TARGET_NAME) - - get_target_property(EMULATOR_SOURCE_DIR UnityEmulator SOURCE_DIR) - set(EMULATOR_UWP_SOURCE - ${EMULATOR_SOURCE_DIR}/src/UWP/UnityAppUWP.cpp - ${EMULATOR_SOURCE_DIR}/src/UnityAppBase.cpp - ) - set(EMULATOR_UWP_INCLUDE - ${EMULATOR_SOURCE_DIR}/include/UnityAppBase.h - ) - - target_sources(${TARGET_NAME} PRIVATE ${EMULATOR_UWP_SOURCE} ${EMULATOR_UWP_INCLUDE}) - source_group("src\\UnityEmulator" FILES ${EMULATOR_UWP_SOURCE}) - source_group("include\\UnityEmulator" FILES ${EMULATOR_UWP_INCLUDE}) - endfunction() + # Windows Runtime types cannot be included into static libraries + # https://social.msdn.microsoft.com/Forums/en-US/269db513-64ef-4817-a025-43954f614eb3/lnk4264-why-are-static-libraries-not-recommended-when-authoring-windows-runtime-types?forum=winappswithnativecode + # So as a workaround, we will include all source files into the target app project + function(append_emulator_uwp_source TARGET_NAME) + + get_target_property(EMULATOR_SOURCE_DIR UnityEmulator SOURCE_DIR) + set(EMULATOR_UWP_SOURCE + ${EMULATOR_SOURCE_DIR}/src/UWP/UnityAppUWP.cpp + ${EMULATOR_SOURCE_DIR}/src/UnityAppBase.cpp + ) + set(EMULATOR_UWP_INCLUDE + ${EMULATOR_SOURCE_DIR}/include/UnityAppBase.h + ) + + target_sources(${TARGET_NAME} PRIVATE ${EMULATOR_UWP_SOURCE} ${EMULATOR_UWP_INCLUDE}) + source_group("src\\UnityEmulator" FILES ${EMULATOR_UWP_SOURCE}) + source_group("include\\UnityEmulator" FILES ${EMULATOR_UWP_INCLUDE}) + endfunction() elseif(PLATFORM_ANDROID) - list(APPEND SOURCE - src/Android/UnityAppAndroid.cpp - src/UnityAppBase.cpp - ) - list(APPEND INCLUDE include/UnityAppBase.h) + list(APPEND SOURCE + src/Android/UnityAppAndroid.cpp + src/UnityAppBase.cpp + ) + list(APPEND INCLUDE include/UnityAppBase.h) elseif(PLATFORM_LINUX) - list(APPEND SOURCE - src/Linux/UnityAppLinux.cpp - src/UnityAppBase.cpp - ) - list(APPEND INCLUDE include/UnityAppBase.h) + list(APPEND SOURCE + src/Linux/UnityAppLinux.cpp + src/UnityAppBase.cpp + ) + list(APPEND INCLUDE include/UnityAppBase.h) elseif(PLATFORM_MACOS) list(APPEND SOURCE src/MacOS/UnityAppMacOS.cpp - src/UnityAppBase.cpp + src/UnityAppBase.cpp ) list(APPEND INCLUDE - include/UnityAppBase.h + include/UnityAppBase.h ) set_source_files_properties(src/UnityGraphicsGLCore_Impl.cpp PROPERTIES COMPILE_FLAGS "-x objective-c++" @@ -113,7 +113,7 @@ elseif(PLATFORM_IOS) include/UnityAppBase.h ) else() - message(FATAL_ERROR "Unknown platform") + message(FATAL_ERROR "Unknown platform") endif() @@ -122,49 +122,49 @@ set_common_target_properties(UnityEmulator) target_include_directories(UnityEmulator PRIVATE - ../GhostCubePlugin/PluginSource/src/Unity + ../GhostCubePlugin/PluginSource/src/Unity PUBLIC - include + include ) if(MSVC) - target_compile_options(UnityEmulator PRIVATE -DUNICODE) + target_compile_options(UnityEmulator PRIVATE -DUNICODE) endif() target_link_libraries(UnityEmulator PRIVATE - BuildSettings + BuildSettings PUBLIC - NativeAppBase - Common - GraphicsEngine - GraphicsTools - TargetPlatform + NativeAppBase + Common + GraphicsEngine + GraphicsTools + TargetPlatform ) if(GL_SUPPORTED) - target_link_libraries(UnityEmulator PRIVATE glew-static) + target_link_libraries(UnityEmulator PRIVATE glew-static) endif() if(GL_SUPPORTED OR GLES_SUPPORTED) - target_link_libraries(UnityEmulator PUBLIC GraphicsEngineOpenGL-static) + target_link_libraries(UnityEmulator PUBLIC GraphicsEngineOpenGL-static) endif() if(D3D11_SUPPORTED) - target_link_libraries(UnityEmulator PUBLIC GraphicsEngineD3DBase GraphicsEngineD3D11-static) + target_link_libraries(UnityEmulator PUBLIC GraphicsEngineD3DBase GraphicsEngineD3D11-static) endif() if(D3D12_SUPPORTED) - target_link_libraries(UnityEmulator PUBLIC GraphicsEngineD3DBase GraphicsEngineD3D12-static) + target_link_libraries(UnityEmulator PUBLIC GraphicsEngineD3DBase GraphicsEngineD3D12-static) endif() if(PLATFORM_UNIVERSAL_WINDOWS) - target_link_libraries(UnityEmulator PRIVATE dxguid.lib) + target_link_libraries(UnityEmulator PRIVATE dxguid.lib) elseif(PLATFORM_ANDROID) - target_link_libraries(UnityEmulator PRIVATE NDKHelper GLESv3 android PUBLIC NativeAppGlue) - target_include_directories(UnityEmulator PRIVATE - ${ANDROID_NDK}/sources/android/cpufeatures - ) + target_link_libraries(UnityEmulator PRIVATE NDKHelper GLESv3 android PUBLIC NativeAppGlue) + target_include_directories(UnityEmulator PRIVATE + ${ANDROID_NDK}/sources/android/cpufeatures + ) elseif(PLATFORM_MACOS) target_include_directories(UnityEmulator PUBLIC src/MacOS @@ -175,5 +175,5 @@ source_group("src" FILES ${SOURCE}) source_group("include" FILES ${INCLUDE}) set_target_properties(UnityEmulator PROPERTIES - FOLDER Unity + FOLDER Unity ) -- cgit v1.2.3