Ver código fonte

Minor clean up to avoid code duplication.

Yao Wei Tjong 姚伟忠 8 anos atrás
pai
commit
7ec1448c07
1 arquivos alterados com 17 adições e 24 exclusões
  1. 17 24
      CMake/Modules/UrhoCommon.cmake

+ 17 - 24
CMake/Modules/UrhoCommon.cmake

@@ -1781,32 +1781,25 @@ macro (_setup_target)
         add_dependencies (${TARGET_NAME} ${RESOURCE_CHECK_${MD5ALL}})
     endif ()
     # Create symbolic links in the build tree
+    if (ANDROID)
+        foreach (I AndroidManifest.xml build.xml custom_rules.xml project.properties src res assets jni)
+            if (EXISTS ${CMAKE_SOURCE_DIR}/Android/${I} AND NOT EXISTS ${CMAKE_BINARY_DIR}/${I})    # No-ops when 'Android' is used as build tree
+                create_symlink (${CMAKE_SOURCE_DIR}/Android/${I} ${CMAKE_BINARY_DIR}/${I} FALLBACK_TO_COPY)
+            endif ()
+        endforeach ()
+        set (ASSET_ROOT assets)
+    else ()
+        set (ASSET_ROOT bin)
+    endif ()
     if (NOT URHO3D_PACKAGING)
-        if (ANDROID)
-            file (MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/Android/assets)
-            if (NOT URHO3D_PACKAGING)
-                foreach (I ${RESOURCE_DIRS})
-                    get_filename_component (NAME ${I} NAME)
-                    if (NOT EXISTS ${CMAKE_SOURCE_DIR}/Android/assets/${NAME})
-                        create_symlink (${I} ${CMAKE_SOURCE_DIR}/Android/assets/${NAME} FALLBACK_TO_COPY)
-                    endif ()
-                endforeach ()
+        # Ensure the asset root directory exist before creating the symlinks
+        file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${ASSET_ROOT})
+        foreach (I ${RESOURCE_DIRS})
+            get_filename_component (NAME ${I} NAME)
+            if (NOT EXISTS ${CMAKE_BINARY_DIR}/${ASSET_ROOT}/${NAME} AND EXISTS ${I})
+                create_symlink (${I} ${CMAKE_BINARY_DIR}/${ASSET_ROOT}/${NAME} FALLBACK_TO_COPY)
             endif ()
-            foreach (I AndroidManifest.xml build.xml custom_rules.xml project.properties src res assets jni)
-                if (EXISTS ${CMAKE_SOURCE_DIR}/Android/${I} AND NOT EXISTS ${CMAKE_BINARY_DIR}/${I})    # No-ops when 'Android' is used as build tree
-                    create_symlink (${CMAKE_SOURCE_DIR}/Android/${I} ${CMAKE_BINARY_DIR}/${I} FALLBACK_TO_COPY)
-                endif ()
-            endforeach ()
-        else ()
-            foreach (I ${RESOURCE_DIRS})
-                get_filename_component (NAME ${I} NAME)
-                if (NOT EXISTS ${CMAKE_BINARY_DIR}/bin/${NAME} AND EXISTS ${I})
-                    # Ensure the output directory exist before creating the symlinks
-                    file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
-                    create_symlink (${I} ${CMAKE_BINARY_DIR}/bin/${NAME} FALLBACK_TO_COPY)
-                endif ()
-            endforeach ()
-        endif ()
+        endforeach ()
     endif ()
     # Workaround CMake/Xcode generator bug where it always appends '/build' path element to SYMROOT attribute and as such the items in Products are always rendered as red in the Xcode as if they are not yet built
     if (NOT DEFINED ENV{TRAVIS})