Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

open-scene-graph: For 10.6 fix patch and use HB clang

Open-scene-graph (osg) uses a `defaults read` command that's
broken on 10.6.  Patching that means both an inline patch
and an inreplace afterwards to insert the OSX version.

Also the existing patch for the missing `OR` may have worked,
but it turns out there's another CMakeLists.txt that needs
to be patched.

Also on 10.6, no default compiler works due to very ugly
errors about templates and overlaoded functions.  However,
osg builds just fine with HB clang-3.1 from the llvm formula.

- Add a Requirement on 10.6 for HB clang-3.1.
- Patch the top level `CMakeLists.txt` for `OSG_OSX_SDK_VERSION`
- `inreplace` the new `OSG_OSX_SDK_VERSION` to set the version.
- Patch two `CMakeLists.txt` files for `OR` syntax errors.

Fixes #16076
  • Loading branch information...
commit 296ad3ed0ca6bc2fdd45672923cd8781d09f1ad0 1 parent db15976
2bits authored

Showing 1 changed file with 108 additions and 13 deletions. Show diff stats Hide diff stats

  1. +108 13 Library/Formula/open-scene-graph.rb
121 Library/Formula/open-scene-graph.rb
... ... @@ -1,5 +1,21 @@
1 1 require 'formula'
2 2
  3 +class ModernClang < Requirement
  4 + def message
  5 + <<-EOS.undent
  6 + OpenSceneGraph needs a modern version of clang to compile on Snow Leopard,
  7 + but the Homebrew installed clang was not detected. Please install it with:
  8 +
  9 + brew install --with-clang llvm
  10 +
  11 + EOS
  12 + end
  13 + def satisfied?
  14 + File.exists? "#{HOMEBREW_PREFIX}/bin/clang"
  15 + end
  16 + def fatal?; true; end
  17 +end
  18 +
3 19 class OpenSceneGraph < Formula
4 20 homepage 'http://www.openscenegraph.org/projects/osg'
5 21 url 'http://www.openscenegraph.org/downloads/developer_releases/OpenSceneGraph-3.1.2.zip'
@@ -9,6 +25,7 @@ class OpenSceneGraph < Formula
9 25 option 'ffmpeg', 'Build with ffmpeg support'
10 26 option 'docs', 'Build the documentation with Doxygen and Graphviz'
11 27
  28 + depends_on ModernClang.new if MacOS.version == 10.6
12 29 depends_on 'cmake' => :build
13 30 depends_on 'jpeg'
14 31 depends_on 'wget'
@@ -25,15 +42,29 @@ class OpenSceneGraph < Formula
25 42 depends_on 'graphviz' if build.include? 'docs'
26 43
27 44
28   - # The mini-Boost finder in FindCOLLADA doesn't find our boost, so fix it.
29   - # Also CMakeLists is missing an OR plus code for 10.8.
  45 + # 1. The mini-Boost finder in FindCOLLADA doesn't find our boost.
  46 + # 2. The CMakeLists tries to use a `defaults read` on 10.6.8 that fails:
  47 + # -> https://github.com/mxcl/homebrew/issues/16076
  48 + # It needs to be both patched then inreplaced with the OSX version.
  49 + # 3. Also CMakeLists has a syntax error, a missing an OR.
30 50 # Reported: http://forum.openscenegraph.org/viewtopic.php?t=10647
31   - # Remove: Unknown. Neither fix is merged upstream yet.
  51 + # Remove: Unknown. None are merged upstream as of osg-3.1.2.
32 52 def patches
33 53 DATA
34 54 end
35 55
36 56 def install
  57 + # SL needs to use HB clang-3.1 or better. Nothing else works.
  58 + if MacOS.version == 10.6
  59 + ENV['CC'] = "#{HOMEBREW_PREFIX}/bin/clang"
  60 + ENV['CXX'] = "#{HOMEBREW_PREFIX}/bin/clang++"
  61 + end
  62 +
  63 + # As the second half of fixing #2 above, insert the OSX version now.
  64 + inreplace 'CMakeLists.txt', 'SET (OSG_OSX_SDK_NAME)',
  65 + "SET (OSG_OSX_SDK_NAME \"macosx#{MacOS.version}\")"
  66 +
  67 +
37 68 # Turning off FFMPEG takes this change or a dozen "-DFFMPEG_" variables
38 69 unless build.include? 'ffmpeg'
39 70 inreplace 'CMakeLists.txt', 'FIND_PACKAGE(FFmpeg)', '#FIND_PACKAGE(FFmpeg)'
@@ -71,7 +102,7 @@ def install
71 102 index 428cb29..6206580 100644
72 103 --- a/CMakeModules/FindCOLLADA.cmake
73 104 +++ b/CMakeModules/FindCOLLADA.cmake
74   -@@ -235,7 +235,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
  105 +@@ -237,7 +237,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
75 106 )
76 107
77 108 FIND_LIBRARY(COLLADA_BOOST_FILESYSTEM_LIBRARY
@@ -80,7 +111,7 @@ def install
80 111 PATHS
81 112 ${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
82 113 ${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
83   -@@ -251,7 +251,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
  114 +@@ -253,7 +253,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
84 115 )
85 116
86 117 FIND_LIBRARY(COLLADA_BOOST_SYSTEM_LIBRARY
@@ -89,25 +120,89 @@ def install
89 120 PATHS
90 121 ${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
91 122 ${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
92   ---- a/CMakeLists.txt 2012-03-23 03:21:51.000000000 -0700
93   -+++ b/CMakeLists.txt 2012-08-29 11:55:21.000000000 -0700
94   -@@ -824,16 +824,15 @@
  123 +--- a/CMakeLists.txt 2012-03-23 03:21:51.000000000 -0700
  124 ++++ b/CMakeLists.txt 2012-11-15 16:32:12.000000000 -0800
  125 +@@ -189,9 +189,7 @@
  126 + IF(NOT ANDROID)
  127 + IF(APPLE)
  128 + # Determine the canonical name of the selected Platform SDK
  129 +- EXECUTE_PROCESS(COMMAND "defaults" "read" "${CMAKE_OSX_SYSROOT}/SDKSettings.plist" "CanonicalName"
  130 +- OUTPUT_VARIABLE OSG_OSX_SDK_NAME
  131 +- OUTPUT_STRIP_TRAILING_WHITESPACE)
  132 ++ SET (OSG_OSX_SDK_NAME)
  133 +
  134 + # Trying to get CMake to generate an XCode IPhone project, current efforts are to get iphoneos sdk 3.1 working
  135 + # Added option which needs manually setting to select the IPhone SDK for building. We can only have one of the below
  136 +@@ -824,27 +824,40 @@
95 137 # FORCE is used because the options are not reflected in the UI otherwise.
96 138 # Seems like a good place to add version specific compiler flags too.
97 139 IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
98   -- IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7")
99   -+ IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8")
  140 ++ IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8")
  141 ++ SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
  142 ++ # 64 Bit Works, PPC is not supported any more
  143 ++ SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX" FORCE)
  144 ++ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.8 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
  145 ++ ENDIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8")
  146 ++
  147 + IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7")
100 148 SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
101 149 # 64 Bit Works, PPC is not supported any more
102   - SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
  150 +- SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
  151 ++ SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX" FORCE)
103 152 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
104 153 - ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.6" /
105 154 - ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.5")
106   -+ ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.6" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.5")
  155 ++ ENDIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7")
  156 ++
  157 ++ IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.6")
107 158 SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
108 159 # 64-bit compiles are not supported with Carbon.
109 160 - SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
110 161 + SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
  162 ++ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.6 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
  163 ++ ENDIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.6")
  164 ++
  165 ++ IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.5")
  166 ++ SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
  167 ++ # 64-bit compiles are not supported with Carbon.
  168 ++ SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
111 169 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
112   - ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.4")
  170 +- ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.4")
  171 ++ ENDIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.5")
  172 ++
  173 ++ IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.4")
113 174 SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "quicktime" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
  175 + SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
  176 + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
  177 +- ELSE()
  178 +- # No Universal Binary support
  179 +- # Should break down further to set the -mmacosx-version-min,
  180 +- # but the SDK detection is too unreliable here.
  181 +- ENDIF()
  182 +- ENDIF()
  183 ++ ENDIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.4")
  184 ++ ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
  185 +
  186 + OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
  187 +
  188 +--- a/src/osgViewer/CMakeLists.txt 2012-03-23 03:21:51.000000000 -0700
  189 ++++ b/src/osgViewer/CMakeLists.txt 2012-11-15 15:53:04.000000000 -0800
  190 +@@ -67,15 +67,9 @@
  191 +
  192 + IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
  193 + SET(OSG_WINDOWING_SYSTEM "IOS" CACHE STRING "Windowing system type for graphics window creation, options only IOS.")
  194 +- ELSE()
  195 +- IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7" OR
  196 +- ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.6" OR
  197 +- ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.5")
  198 +- SET(OSG_WINDOWING_SYSTEM "Cocoa" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.")
  199 +- ELSE()
  200 +- SET(OSG_WINDOWING_SYSTEM "Carbon" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.")
  201 +- ENDIF()
  202 +- ENDIF()
  203 ++ ELSE(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
  204 ++ SET(OSG_WINDOWING_SYSTEM "Cocoa" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.")
  205 ++ ENDIF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
  206 +
  207 + ELSE()
  208 + IF(ANDROID)

0 comments on commit 296ad3e

Adam Vandenberg

Way too much indentation here

Adam Vandenberg

But, is it better to just say "install Lion"?

Please sign in to comment.
Something went wrong with that request. Please try again.