Browse Source

Move the cricial post-CMake fix into CMake rules for iOS platform.
This should ensure the Xcode project generated from user calling cmake-gui directly or cmake directly (not via our build scripts) would also geting the critical fix, and also whenever CMake performs a rerun internally then our post-CMake fix is reapplied automatically.

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
3ae2942ad2
2 changed files with 20 additions and 18 deletions
  1. 0 17
      .bash_helpers.sh
  2. 20 1
      CMake/Modules/Urho3D-CMake-common.cmake

+ 0 - 17
.bash_helpers.sh

@@ -97,23 +97,6 @@ post_cmake() {
         fi
     elif [ $IOS ]; then
         echo -- post_cmake: Fix generated Xcode project for iOS platform
-
-        # Temporary fix: can be removed when CMake minimum required has reached 2.8.12
-        if [ -e $BUILD/CMakeScripts/XCODE_DEPEND_HELPER.make ]; then
-            # Due to a bug in the CMake/Xcode generator (prior to version 2.8.12) where it has wrongly assumed the IOS bundle structure to be the same as MacOSX bundle structure,
-            # below temporary fix is required in order to solve the auto-linking issue when dependent libraries are changed
-            # Since version 2.8.12 CMake does not generate XCODE_DEPEND_HELPER.make script anymore, so we skip this fix when the script does not exist
-            sed -i '' 's/\/Contents\/MacOS//g' $BUILD/CMakeScripts/XCODE_DEPEND_HELPER.make
-        fi
-
-        # Temporary fix: known CMake bug (still exists in 3.0.2)
-        if [ -e $BUILD/CMakeScripts/install_postBuildPhase.makeDebug ]; then
-            # Due to a bug in the CMake/Xcode generator that prevents iOS targets (library and bundle) to be installed correctly
-            # (see http://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=12506&graph=dependency),
-            # below temporary fix is required to work around the bug
-            sed -i '' 's/$(EFFECTIVE_PLATFORM_NAME)//g' $BUILD/CMakeScripts/install_postBuildPhase.make*
-        fi
-
         # Set Xcode build settings to skip dSYM file generation for Debug configuration (other configurations still use the default dwarf-with-dsym)
         if [ -e $BUILD/*.xcodeproj/project.pbxproj ] && perl -v >/dev/null 2>&1; then
             perl -i -pe 'BEGIN {$/=undef} s/(Begin XCBuildConfiguration.*?Debug.*?Settings = {\n)/\1DEBUG_INFORMATION_FORMAT = dwarf;\n/s' $BUILD/*.xcodeproj/project.pbxproj

+ 20 - 1
CMake/Modules/Urho3D-CMake-common.cmake

@@ -748,8 +748,8 @@ macro (setup_main_executable)
     endif ()
     
     if (IOS)
-        get_target_property (TARGET_LOC ${TARGET_NAME} LOCATION)
         # Define a custom target to check for resource modification
+        get_target_property (TARGET_LOC ${TARGET_NAME} LOCATION)
         string (REGEX REPLACE /Contents/MacOS "" TARGET_LOC ${TARGET_LOC})    # The regex replacement is temporary workaround to correct the wrong location caused by CMake/Xcode generator bug
         add_custom_target (RESOURCE_CHECK_${TARGET_NAME} ALL
             \(\( `find ${RESOURCE_FILES} -newer ${TARGET_LOC} 2>/dev/null |wc -l` \)\) && touch -cm ${SOURCE_FILES} || exit 0
@@ -758,6 +758,25 @@ macro (setup_main_executable)
     endif ()
 endmacro ()
 
+# Post-CMake fixes for iOS project
+if (IOS)
+    # TODO: can be removed when CMake minimum required has reached 2.8.12
+    if (CMAKE_VERSION VERSION_LESS 2.8.12)
+        # Due to a bug in the CMake/Xcode generator (prior to version 2.8.12) where it has wrongly assumed the IOS bundle structure to be the same as MacOSX bundle structure,
+        # below temporary fix is required in order to solve the auto-linking issue when dependent libraries are changed
+        add_custom_target (FIX_DEPEND_HELPER ALL
+            if [ ${CMAKE_BINARY_DIR}/CMakeScripts/XCODE_DEPEND_HELPER.make -nt ${CMAKE_BINARY_DIR}/CMakeScripts/.fixed-depend-helper ]\; then sed -i '' 's/\/Contents\/MacOS//g' ${CMAKE_BINARY_DIR}/CMakeScripts/XCODE_DEPEND_HELPER.make\; touch ${CMAKE_BINARY_DIR}/CMakeScripts/.fixed-depend-helper\; fi
+            COMMENT "Checking if the CMake/Xcode depend helper scripts need to be fixed")
+    endif ()
+
+    # Due to a bug in the CMake/Xcode generator (still exists in 3.1) that prevents iOS targets (library and bundle) to be installed correctly
+    # (see http://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=12506&graph=dependency),
+    # below temporary fix is required to work around the bug
+    add_custom_target (FIX_INSTALL ALL
+        if [ ${CMAKE_BINARY_DIR}/CMakeScripts/install_postBuildPhase.makeDebug -nt ${CMAKE_BINARY_DIR}/CMakeScripts/.fixed-install ]\; then sed -i '' 's/EFFECTIVE_PLATFORM_NAME//g' ${CMAKE_BINARY_DIR}/CMakeScripts/install_postBuildPhase.make*\; touch ${CMAKE_BINARY_DIR}/CMakeScripts/.fixed-install\; fi
+        COMMENT "Checking if the CMake/Xcode install scripts need to be fixed")
+endif ()
+
 # Macro for adjusting target output name by dropping _suffix from the target name
 macro (adjust_target_name)
     string (REGEX REPLACE _.*$ "" OUTPUT_NAME ${TARGET_NAME})