Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F108361
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/.gitignore b/.gitignore
index 7124054..ac7aa52 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,33 +1,38 @@
*.cbp
*.depend
*.layout
*.exe
*.dll
*.o
*.db
*.res
*.rc
*.sav
*.bat
*.xcf
*.dat
*.cscope_file_list
DeathCertificate.png
src/MD5.cpp
src/OnlineScoring.h
src/MD5.h
# CMake / OS X
CMakeCache.txt
CMakeFiles/
CMakeScripts/
cmake_install.cmake
Debug/
*.build/
*.xcodeproj/
+_CPack_Packages/
+CPack*Config.cmake
+install_manifest.txt
+*.dmg
+*.app/
# Visual Studio
*.vcxproj*
*.opensdf
*.sdf
*.sln
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c09c59..3bdadf2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,45 +1,96 @@
cmake_minimum_required(VERSION 2.8.12)
# Projet name
project("Witch_Blast")
# Detect compiler
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(USING_GCC TRUE)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(USING_CLANG TRUE)
endif()
# For GCC and Clang, enable C++11 support and add some other flags
if(USING_GCC OR USING_CLANG)
add_compile_options(-std=c++11 -pedantic -Wall)
endif()
# Compilation options
option(ONLINE_MODE "Enable online mode, which requires src/OnlineScoring.h" OFF)
if(ONLINE_MODE)
add_compile_options(-DONLINE_MODE)
endif()
include_directories(.)
file(
GLOB_RECURSE
source_files
src/*
)
add_executable(
"Witch_Blast"
+ MACOSX_BUNDLE
${source_files}
)
+set_target_properties(Witch_Blast PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}
+ RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}
+)
+if(APPLE)
+ set_target_properties(Witch_Blast PROPERTIES
+ MACOSX_RPATH 1
+ BUILD_WITH_INSTALL_RPATH 1
+ INSTALL_RPATH "@loader_path/../Frameworks")
+ set(EXTRA_LIBRARIES "-framework CoreFoundation")
+endif()
# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
find_package(SFML 2.2 REQUIRED system window graphics audio)
-target_link_libraries(Witch_Blast ${SFML_LIBRARIES})
+target_link_libraries(Witch_Blast ${SFML_LIBRARIES} ${EXTRA_LIBRARIES})
include_directories(${SFML_INCLUDE_DIR})
Message(${SFML_LIBRARIES})
+
+if(APPLE)
+ install(
+ DIRECTORY Witch_Blast.app
+ DESTINATION "."
+ USE_SOURCE_PERMISSIONS)
+ install(
+ DIRECTORY
+ ${CMAKE_SOURCE_DIR}/data
+ ${CMAKE_SOURCE_DIR}/media
+ DESTINATION Witch_Blast.app/Contents/Resources)
+ # copy SFML frameworks into app bundle for Mac OS X
+ set(LIBS SFML sfml-system sfml-window sfml-graphics sfml-audio)
+ foreach(LIB ${LIBS})
+ install(DIRECTORY /Library/Frameworks/${LIB}.framework
+ DESTINATION Witch_Blast.app/Contents/Frameworks)
+ endforeach()
+ install(FILES
+ ${CMAKE_SOURCE_DIR}/COPYING.txt
+ ${CMAKE_SOURCE_DIR}/readme.txt
+ DESTINATION ".")
+endif()
+
+# Packaging
+SET(CPACK_PACKAGE_VERSION "0.7")
+SET(CPACK_PACKAGE_VERSION_MAJOR "0")
+SET(CPACK_PACKAGE_VERSION_MINOR "7")
+SET(CPACK_PACKAGE_VERSION_PATCH "0")
+SET(CPACK_PACKAGE_EXECUTABLES "Witch_Blast;Witch Blast")
+if(APPLE)
+ set(CPACK_GENERATOR "DragNDrop")
+ set(CPACK_DMG_FORMAT "UDBZ")
+ set(CPACK_DMG_VOLUME_NAME "Witch Blast")
+ set(CPACK_SYSTEM_NAME "OSX")
+ # TODO: CPACK_PACKAGE_ICON
+ # TODO: CPACK_DMG_BACKGROUND_IMAGE
+ # TODO: CPACK_DMG_DS_STORE
+endif()
+include(CPack)
diff --git a/src/main.cpp b/src/main.cpp
index 9cd50a5..a2ae024 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,10 +1,31 @@
#include <SFML/Graphics.hpp>
#include "WitchBlastGame.h"
+#ifdef __APPLE__
+#include "CoreFoundation/CoreFoundation.h"
+#endif
+
int main()
{
+#ifdef __APPLE__
+ // -------------------------------------------------------------------
+ // http://stackoverflow.com/a/520951/2038264
+ // This makes relative paths work in C++ in Xcode by changing
+ // directory to the Resources folder inside the .app bundle
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
+ char path[PATH_MAX];
+ if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
+ {
+ // error!
+ }
+ CFRelease(resourcesURL);
+ chdir(path);
+ // -------------------------------------------------------------------
+#endif
+
WitchBlastGame game;
game.startGame();
return 0;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Apr 1, 4:32 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
57284
Default Alt Text
(4 KB)
Attached To
Mode
R78 witchblast
Attached
Detach File
Event Timeline