cmake_macosx.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2008-2014 the Urho3D project.
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. # THE SOFTWARE.
  22. #
  23. # Ensure we are in project root directory
  24. cd $( dirname $0 )
  25. # Create out-of-source build directory
  26. SOURCE=`pwd`/Source
  27. BUILD=Build
  28. if [ "$1" == "-DIOS=1" ]; then
  29. BUILD=ios-Build
  30. fi
  31. cmake -E make_directory $BUILD
  32. # Create project with the Xcode generator
  33. OPT=
  34. cmake -E chdir $BUILD cmake $OPT -G "Xcode" $@ $SOURCE
  35. # Temporary fix: can be removed when CMake minimum required has reached 2.8.12
  36. if [ "$1" == "-DIOS=1" -a -e $BUILD/CMakeScripts/XCODE_DEPEND_HELPER.make ]; then
  37. # 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,
  38. # below temporary fix is required in order to solve the auto-linking issue when dependent libraries are changed
  39. # 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
  40. sed -i '' 's/\/Contents\/MacOS//g' $BUILD/CMakeScripts/XCODE_DEPEND_HELPER.make
  41. fi
  42. # Temporary fix: known CMake bug (still exists in 2.8.12)
  43. if [ "$1" == "-DIOS=1" -a -e $BUILD/CMakeScripts/install_postBuildPhase.makeDebug ]; then
  44. # Due to a bug in the CMake/Xcode generator that prevents iOS targets (library and bundle) to be installed correctly
  45. # (see http://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=12506&graph=dependency),
  46. # below temporary fix is required to work around the bug
  47. sed -i '' 's/$(EFFECTIVE_PLATFORM_NAME)//g' $BUILD/CMakeScripts/install_postBuildPhase.make*
  48. fi
  49. # Set Xcode build settings to skip dSYM file generation for Debug configuration (other configurations still use the default dwarf-with-dsym)
  50. if [ "$1" == "-DIOS=1" -a -e $BUILD/*.xcodeproj/project.pbxproj ] && perl -v >/dev/null 2>&1; then
  51. perl -i -pe 'BEGIN {$/=undef} s/(Begin XCBuildConfiguration.*?Debug.*?Settings = {\n)/\1DEBUG_INFORMATION_FORMAT = dwarf;\n/s' $BUILD/*.xcodeproj/project.pbxproj
  52. fi
  53. # vi: set ts=4 sw=4 expandtab: