diff --git a/CMakeLists.txt b/CMakeLists.txt index 16bc98f8e..053a824ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,10 @@ if (APPLE) # Build with clang ang libc++ set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + + # On OS X we use Sparkle framework for updates + find_path(SPARKLE_INCLUDE_DIR Sparkle.h) + find_library(SPARKLE_FRAMEWORK NAMES Sparkle) endif() find_package(Boost 1.46.0 COMPONENTS program_options filesystem system thread REQUIRED) diff --git a/client/CMT.cpp b/client/CMT.cpp index f1f872515..7d2c4e793 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -173,6 +173,9 @@ static void prog_help(const po::options_description &opts) // printf(" -v, --version display version information and exit\n"); } +#ifdef __APPLE__ +void OSX_checkForUpdates(); +#endif #ifdef _WIN32 int _tmain(int argc, _TCHAR* argv[]) @@ -188,6 +191,9 @@ int main(int argc, char** argv) std::string workDir = executablePath.substr(0, executablePath.rfind('/')); chdir(workDir.c_str()); + // Check for updates + OSX_checkForUpdates(); + // Check that game data is prepared. Otherwise run vcmibuilder helper application FILE* check = fopen((GVCMIDirs.UserPath + "/game_data_prepared").c_str(), "r"); if (check == NULL) { diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8002cdf38..1afeeb5ae 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -46,8 +46,15 @@ set(client_SRCS if(WIN32) add_executable(vcmiclient WIN32 ${client_SRCS}) elseif(APPLE) - # When building for OS X we need add SDLMain.m to source files - add_executable(vcmiclient MACOSX_BUNDLE ${client_SRCS} SDLMain.m vcmi.icns Info.plist) + # OS X specific includes + include_directories(${SPARKLE_INCLUDE_DIR}) + + # OS X specific source files + set(client_SRCS ${client_SRCS} SDLMain.m OSX.mm Info.plist vcmi.icns ../osx/vcmi_dsa_public.pem) + add_executable(vcmiclient MACOSX_BUNDLE ${client_SRCS}) + + # OS X specific libraries + target_link_libraries(vcmiclient ${SPARKLE_FRAMEWORK}) # Because server and AI libs would be copies to bundle they need to be built before client add_dependencies(vcmiclient vcmiserver VCAI EmptyAI StupidAI BattleAI) @@ -55,8 +62,9 @@ elseif(APPLE) # Custom Info.plist set_target_properties(vcmiclient PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) - # Copy icon file + # Copy icon file and public key for Sparkle set_source_files_properties(vcmi.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + set_source_files_properties(../osx/vcmi_dsa_public.pem PROPERTIES MACOSX_PACKAGE_LOCATION Resources) # Copy server executable, libs and game data to bundle set(BUNDLE_PATH ${CMAKE_HOME_DIRECTORY}/bin/$(CONFIGURATION)/vcmiclient.app/Contents) diff --git a/client/Info.plist b/client/Info.plist index 31bb8dfb7..fc6665743 100644 --- a/client/Info.plist +++ b/client/Info.plist @@ -2,9 +2,15 @@ - CFBundleIconFile - vcmi.icns - CFBundleVersion + CFBundleIconFile + vcmi.icns + CFBundleVersion ${VCMI_VERSION_MAJOR}.${VCMI_VERSION_MINOR} + CFBundleIdentifier + com.vcmi.vcmiclient + SUFeedURL + http://vcmi.eu/sparkle_appcast.xml + SUPublicDSAKeyFile + vcmi_dsa_public.pem diff --git a/client/OSX.mm b/client/OSX.mm new file mode 100644 index 000000000..fc8e91436 --- /dev/null +++ b/client/OSX.mm @@ -0,0 +1,7 @@ +#import +#import "Sparkle.h" + +void OSX_checkForUpdates() { + SUUpdater* updater = [[SUUpdater alloc] init]; + [[SUUpdater sharedUpdater] checkForUpdatesInBackground]; +} diff --git a/osx/sparkle_appcast.xml b/osx/sparkle_appcast.xml new file mode 100644 index 000000000..6bad84bfb --- /dev/null +++ b/osx/sparkle_appcast.xml @@ -0,0 +1,16 @@ + + + + VCMI App Changelog + http://vcmi.eu/sparkle_appcast.xml + Most recent changes with links to updates. + en + + Version 0.92 + Version 0.92 description + Wed, 09 Jan 2006 19:20:11 +0000 + http://vcmi.com/sparkle_release_notes.html + + + + \ No newline at end of file diff --git a/osx/sparkle_release_notes.html b/osx/sparkle_release_notes.html new file mode 100644 index 000000000..0237f2052 --- /dev/null +++ b/osx/sparkle_release_notes.html @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/osx/vcmi_dsa_public.pem b/osx/vcmi_dsa_public.pem new file mode 100644 index 000000000..c1092aff0 --- /dev/null +++ b/osx/vcmi_dsa_public.pem @@ -0,0 +1,12 @@ +-----BEGIN PUBLIC KEY----- +MIIBuDCCASwGByqGSM44BAEwggEfAoGBAPBRGeziJsHw0F7CM9JmSOiIOBmJ4hYl +dbmdU1iJR7XHX5lZIUOl323cCANhzOogVAzkvEVhFedA6H4iO6VRt7nTJSgLA4hO +gMqMJGKp4bDQIwupUK5xQUUcaXumT03Aj8jzzibW9YjNB8NeuSSMfMi5KGZw5pkf +nSvZM0TUVVX/AhUA74nJWqRFwUPc6aPGCOgfsRzPYMsCgYEApYMP5/tIr4yrqHVM +xHLj1s+Y/Zgs3+kRqudTLgYE20Br3Tmmi2ejM9phrEHn5mv6Ss/FYyWqKxdtzCEN +PjRA/JkKMpoX+sy/S3OE/NrrnikVjCRvgOJcM6FPt9iaENRqjz20dZMIq42vqeE9 +K5u1XJ/YtiwU2b1fX0nNtREhjUwDgYUAAoGBAJT2cMQ2qTGecdNIjEByCFMZpWg0 +nV+jKgpthNUahwxbUN3ru9nrWMUNv1pBiS3pxqFV6ec7qozKnedwyTx+IRJXTN4T +IrxYsgPJDHhkBeoVVAkacihkLUtwPSphorZWF4OMFmrlc5WsmYt2lEahR2TZGQrW +5GBNP18/S/nDBe7j +-----END PUBLIC KEY-----