diff --git a/.gitignore b/.gitignore index 187c7e0270..25bfc94361 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ Makefile cmake*.cmake Ogre.log ogre.cfg -build +build* plugins.cfg openmw.cfg Doxygen diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a640dab30..c0ae4460d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,6 +231,16 @@ endif (CMAKE_COMPILER_IS_GNUCC) # Main executable add_executable(openmw + ${BSA} ${BSA_HEADER} + ${TOOLS} ${TOOLS_HEADER} + ${OGRE} ${OGRE_HEADER} + ${INPUT} ${INPUT_HEADER} + ${NIF} ${NIF_HEADER} + ${NIFOGRE} ${NIFOGRE_HEADER} + ${MANGLE_VFS} + ${GAME} + ${ESM_STORE} ${ESM_STORE_HEADER} + ${GAMEREND} ${GAMEREND_HEADER} MACOSX_BUNDLE ${COMPONENTS} ${COMPONENTS_HEADER} ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} @@ -255,17 +265,29 @@ add_subdirectory( apps/clientconsole ) # Apple bundling if (APPLE) - set_source_files_properties( - ${CMAKE_SOURCE_DIR}/files/openmw.cfg - ${CMAKE_SOURCE_DIR}/files/mac/plugins.cfg - PROPERTIES - MACOSX_PACKAGE_LOCATION MacOS - ) - set_target_properties( - openmw - PROPERTIES - MACOSX_BUNDLE_BUNDLE_NAME "OpenMW" - ) + set(MISC_FILES + ${CMAKE_SOURCE_DIR}/files/openmw.cfg + ${CMAKE_SOURCE_DIR}/files/mac/plugins.cfg + ${CMAKE_SOURCE_DIR}/files/mac/ogre.cfg) +install(TARGETS openmw + BUNDLE DESTINATION . + RUNTIME DESTINATION ../MacOS + COMPONENT Runtime) +install(FILES ${MISC_FILES} DESTINATION ../MacOS) +set(CPACK_GENERATOR "Bundle") +set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist") +set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns") +set(CPACK_BUNDLE_NAME "OpenMW") +set(CPACK_PACKAGE_VERSION "0.07") +set(CPACK_PACKAGE_VERSION_MAJOR "0") +set(CPACK_PACKAGE_VERSION_MINOR "07") +set(CPACK_PACKAGE_VERSION_PATCH "") + +include(CPack) + +set(CMAKE_EXE_LINKER_FLAGS "-arch i386") +set(CMAKE_CXX_FLAGS "-arch i386") + endif (APPLE) # Tools diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 63ea7e4271..af196af668 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -5,6 +5,7 @@ #include +#include "tools/fileops.hpp" #include "engine.hpp" using namespace std; @@ -37,10 +38,17 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) bpo::variables_map variables; - std::ifstream configFile ("openmw.cfg"); +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE + std::string configFilePath(macBundlePath() + "/Contents/MacOS/openmw.cfg"); + std::ifstream configFile (configFilePath.c_str()); +#else + std::ifstream configFile ("openmw.cfg"); +#endif - bpo::store ( bpo::parse_command_line (argc, argv, desc), variables ); - bpo::notify (variables); + bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); + + bpo::store(valid_opts, variables); + bpo::notify(variables); if (configFile.is_open()) bpo::store ( bpo::parse_config_file (configFile, desc), variables); diff --git a/components/misc/fileops.cpp b/components/misc/fileops.cpp index bb859836bf..b7e3b389e6 100644 --- a/components/misc/fileops.cpp +++ b/components/misc/fileops.cpp @@ -1,8 +1,34 @@ #include "fileops.hpp" #include +#include + bool isFile(const char *name) { boost::filesystem::path cfg_file_path(name); return boost::filesystem::exists(cfg_file_path); } + +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE +#include + +std::string macBundlePath() +{ + char path[1024]; + CFBundleRef mainBundle = CFBundleGetMainBundle(); + assert(mainBundle); + + CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); + assert(mainBundleURL); + + CFStringRef cfStringRef = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle); + assert(cfStringRef); + + CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); + + CFRelease(mainBundleURL); + CFRelease(cfStringRef); + + return std::string(path); +} +#endif diff --git a/components/misc/fileops.hpp b/components/misc/fileops.hpp index 6a5ad7c611..004f01dd6b 100644 --- a/components/misc/fileops.hpp +++ b/components/misc/fileops.hpp @@ -1,7 +1,13 @@ #ifndef __FILEOPS_H_ #define __FILEOPS_H_ +#include + /// Check if a given path is an existing file (not a directory) bool isFile(const char *name); +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE +std::string macBundlePath(); +#endif + #endif diff --git a/files/mac/Info.plist b/files/mac/Info.plist new file mode 100644 index 0000000000..77ec896182 --- /dev/null +++ b/files/mac/Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleIconFile + OpenMW.icns + CFBundleDevelopmentRegion + English + CFBundleExecutable + openmw + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + + CFBundleName + OpenMW + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 0.07 + CSResourcesFileMapped + + LSRequiresCarbon + + NSHumanReadableCopyright + + + diff --git a/files/mac/openmw.icns b/files/mac/openmw.icns new file mode 100644 index 0000000000..dfea246606 Binary files /dev/null and b/files/mac/openmw.icns differ