Last active
December 10, 2015 13:18
-
-
Save juniorz/4440291 to your computer and use it in GitHub Desktop.
Homebrew SFML formula
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
# Documentation: https://github.com/mxcl/homebrew/wiki/Formula-Cookbook | |
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! | |
class Sfml < Formula | |
homepage 'http://www.sfml-dev.org' | |
version '2.0-rc' | |
url 'https://github.com/LaurentGomila/SFML/archive/2.0-rc.zip' | |
sha1 '71bdbd9abe46fe4f87c09175cf2a25246b7251c8' | |
head 'https://github.com/LaurentGomila/SFML/archive/master.zip' | |
depends_on 'cmake' => :build | |
depends_on 'freetype' => :build | |
depends_on 'jpeg' => :build | |
depends_on 'glew' => :build | |
depends_on 'libsndfile' => :build | |
# libsndfile depends on them (it is all or none) | |
# flac, libogg, libvorbis | |
option :universal | |
option :static, 'Build Static Libraries' | |
option :framework, 'Build Framework' | |
option :xcode, 'Install XCode 4 Templates (requires sudo to install)' | |
option 'build-examples', 'Build Examples' | |
def patches; DATA; end | |
def install | |
ENV.universal_binary if build.include? 'universal' | |
args = std_cmake_args | |
args.delete '-DCMAKE_BUILD_TYPE=None' | |
args.push '-DCMAKE_BUILD_TYPE=Release', '-DINSTALL_EXTERNAL_LIBS=FALSE' | |
args << '-DBUILD_SHARED_LIBS=FALSE' if build.include? 'static' | |
args << '-DSFML_INSTALL_XCODE4_TEMPLATES=TRUE' if build.include? 'xcode' | |
args << '-DSFML_BUILD_EXAMPLES=TRUE' if build.include? 'build-examples' | |
if build.include? 'framework' | |
args.push '-DSFML_BUILD_FRAMEWORKS=TRUE', "-DCMAKE_INSTALL_FRAMEWORK_PREFIX=#{prefix}/Frameworks" | |
end | |
system 'cmake', '.', *args | |
system 'make install' | |
end | |
def caveats | |
msg = "" | |
msg = <<-EOS.undent | |
The CMake find-module is available at #{opt_prefix}/share/sfml/cmake/Modules/FindSFML.cmake | |
You may need to copy it to #{HOMEBREW_PREFIX}/share/cmake/Modules | |
EOS | |
msg.concat framework_caveats if build.include? 'framework' | |
msg.concat examples_caveats if build.include? 'build-examples' | |
msg | |
end | |
private | |
def framework_caveats; <<-EOS.undent | |
SFML.framework was installed to: | |
#{opt_prefix}/Frameworks/SFML.framework | |
To use this Framework with IDEs it must be linked | |
to the standard OS X location: | |
sudo ln -s #{opt_prefix}/Frameworks/SFML.framework /Library/Frameworks | |
EOS | |
end | |
def examples_caveats; <<-EOS.undent | |
The examples were installed to: | |
#{opt_prefix}/share/sfml/examples | |
EOS | |
end | |
end | |
__END__ | |
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index 4e7605a..e1bad9f 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -36,6 +36,9 @@ sfml_set_option(SFML_BUILD_EXAMPLES FALSE BOOL "TRUE to build the SFML examples, | |
# add an option for building the API documentation | |
sfml_set_option(SFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it") | |
+# set an option for install included external libraries | |
+sfml_set_option(INSTALL_EXTERNAL_LIBS TRUE BOOL "TRUE to install external libraries (sndfile and openal)") | |
+ | |
# Mac OS X specific options | |
if(MACOSX) | |
# add an option to build frameworks instead of dylibs (release only) | |
@@ -215,18 +218,22 @@ install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake | |
install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR}) | |
install(FILES readme.txt DESTINATION ${INSTALL_MISC_DIR}) | |
-if(WINDOWS) | |
- if(ARCH_32BITS) | |
- install(FILES extlibs/bin/x86/libsndfile-1.dll DESTINATION bin) | |
- install(FILES extlibs/bin/x86/openal32.dll DESTINATION bin) | |
- elseif(ARCH_64BITS) | |
- install(FILES extlibs/bin/x64/libsndfile-1.dll DESTINATION bin) | |
- install(FILES extlibs/bin/x64/openal32.dll DESTINATION bin) | |
- endif() | |
-elseif(MACOSX) | |
- install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX}) | |
+if(INSTALL_EXTERNAL_LIBS) | |
+ if(WINDOWS) | |
+ if(ARCH_32BITS) | |
+ install(FILES extlibs/bin/x86/libsndfile-1.dll DESTINATION bin) | |
+ install(FILES extlibs/bin/x86/openal32.dll DESTINATION bin) | |
+ elseif(ARCH_64BITS) | |
+ install(FILES extlibs/bin/x64/libsndfile-1.dll DESTINATION bin) | |
+ install(FILES extlibs/bin/x64/openal32.dll DESTINATION bin) | |
+ endif() | |
+ elseif(MACOSX) | |
+ install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX}) | |
+ endif() | |
+endif() | |
- if(SFML_INSTALL_XCODE4_TEMPLATES) | |
- install(DIRECTORY tools/xcode/templates/SFML DESTINATION /Library/Developer/Xcode/Templates) | |
- endif() | |
+if(MACOSX) | |
+ if(SFML_INSTALL_XCODE4_TEMPLATES) | |
+ install(DIRECTORY tools/xcode/templates/SFML DESTINATION /Library/Developer/Xcode/Templates) | |
+ endif() | |
endif() | |
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt | |
index 777a72e..99cc3e2 100644 | |
--- a/examples/CMakeLists.txt | |
+++ b/examples/CMakeLists.txt | |
@@ -13,6 +13,10 @@ if(WINDOWS) | |
add_subdirectory(win32) | |
elseif(LINUX) | |
add_subdirectory(X11) | |
-elseif(MACOSX) | |
- add_subdirectory(cocoa) | |
+ elseif(MACOSX) | |
+ if(CMAKE_OSX_SYSROOT STREQUAL "" OR OSX_DEVELOPER_ROOT STREQUAL "") | |
+ message(STATUS "Could not find XCode: skipping cocoa example") | |
+ else() | |
+ add_subdirectory(cocoa) | |
+ endif() | |
endif() | |
diff --git a/cmake/Config.cmake b/cmake/Config.cmake | |
index 7fed4ac..fd2b4b6 100644 | |
--- a/cmake/Config.cmake | |
+++ b/cmake/Config.cmake | |
@@ -67,5 +67,5 @@ endif() | |
if(WINDOWS) | |
set(INSTALL_MISC_DIR .) | |
elseif(UNIX) | |
- set(INSTALL_MISC_DIR share/SFML) | |
+ set(INSTALL_MISC_DIR share/sfml) | |
endif() |
Trying to build this results in:
% brew install https://gist.github.com/raw/4440291/sfml.rb --HEAD --build-examples !6496
######################################################################## 100,0%
==> Downloading https://github.com/LaurentGomila/SFML/archive/master.zip
Already downloaded: /Library/Caches/Homebrew/sfml-HEAD.zip
==> Patching
patching file CMakeLists.txt
Hunk #2 FAILED at 218.
1 out of 2 hunks FAILED -- saving rejects to file CMakeLists.txt.rej
patching file examples/CMakeLists.txt
patching file cmake/Config.cmake
Hunk #1 succeeded at 71 (offset 4 lines).
How can i fix this?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@juniorz Now that SFML 2.0 has been released would it be possible for you to submit this to the main Homebrew repository? Thanks.