Merge pull request #250 from OdyX/dev-platform-enhancements-and-installers

MacOSX and Windows platform enhancements and installers
dev-ui
Piotr Dziwiński 2013-11-22 15:16:12 -08:00
commit 8ed542a881
18 changed files with 491 additions and 140 deletions

View File

@ -2,11 +2,11 @@ language: cpp
compiler:
- gcc
- clang
script: mkdir build; cd build; cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DOPENAL_SOUND=0 -DTESTS=1 && make all doc test && DESTDIR=. make install
script: mkdir build; cd build; cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DOPENAL_SOUND=1 -DTESTS=1 && make all doc test && DESTDIR=. make install
before_install:
- git submodule update --init --recursive
- sudo add-apt-repository ppa:mapnik/boost -y
- sudo apt-get update -qq
- sudo apt-get install -qq --no-install-recommends libgl1-mesa-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libpng12-dev libglew-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev google-mock libgtest-dev doxygen graphviz po4a librsvg2-bin libsndfile-dev
- sudo apt-get install -qq --no-install-recommends libgl1-mesa-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libpng12-dev libglew-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev google-mock libgtest-dev doxygen graphviz po4a librsvg2-bin libsndfile-dev libopenal-dev
notifications:
email: false

View File

@ -45,12 +45,18 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
set(PLATFORM_LINUX 0)
set(PLATFORM_MACOSX 0)
set(PLATFORM_OTHER 0)
# Platform-dependent implementation of system.h
set(SYSTEM_CPP_MODULE "system_windows.cpp")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
message(STATUS "Build for Linux system")
set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 1)
set(PLATFORM_MACOSX 0)
set(PLATFORM_OTHER 0)
# Platform-dependent implementation of system.h
set(SYSTEM_CPP_MODULE "system_linux.cpp")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
message(STATUS "Build for Mac OSX system")
set(PLATFORM_WINDOWS 0)
@ -58,6 +64,9 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(PLATFORM_MACOSX 1)
set(PLATFORM_OTHER 0)
# Platform-dependent implementation of system.h
set(SYSTEM_CPP_MODULE "system_macosx.cpp")
set(USE_SDL_MAIN 1) # fixes SDL_main
else()
message(STATUS "Build for other system")
@ -65,6 +74,9 @@ else()
set(PLATFORM_LINUX 0)
set(PLATFORM_MACOSX 0)
set(PLATFORM_OTHER 1)
# Platform-dependent implementation of system.h
set(SYSTEM_CPP_MODULE "system_other.cpp")
endif()
@ -309,6 +321,12 @@ if(PLATFORM_WINDOWS)
set(COLOBOT_INSTALL_I18N_DIR ${CMAKE_INSTALL_PREFIX}/lang CACHE PATH "Colobot translations directory")
set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/doc CACHE PATH "Colobot documentation directory")
endif()
elseif(PLATFORM_MACOSX)
set(COLOBOT_INSTALL_BIN_DIR ../MacOS CACHE STRING "Colobot binary directory")
set(COLOBOT_INSTALL_LIB_DIR ../MacOS CACHE STRING "Colobot libraries directory")
set(COLOBOT_INSTALL_DATA_DIR . CACHE STRING "Colobot shared data directory")
set(COLOBOT_INSTALL_I18N_DIR i18n CACHE SRING "Colobot translations directory")
set(COLOBOT_INSTALL_DOC_DIR doc CACHE STRING "Colobot documentation directory")
else()
set(COLOBOT_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/games CACHE PATH "Colobot binary directory")
set(COLOBOT_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/colobot CACHE PATH "Colobot libraries directory")

View File

@ -58,12 +58,18 @@ To cross-compile Colobot using MXE:
4. Now `cd` to directory with colobot sources. To cross-compile a CMake project,
you have to specify a CMake toolchain file. MXE has such file in MXE's directory:
`usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake`
Toolchain file is specified thus:`cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/mxe-conf.cmake .`
Toolchain file is specified that way: `cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/mxe-conf.cmake .`
CMake files in Colobot should detect that MXE is being used and they will
modify flags, paths, etc. as required. You should not run into any problems.
*Note:* you may also want to use a separate out-of-source build directory for MXE.
5. `make` should now compile the game with the resulting exe in `bin/colobot.exe`.
5. `make` should now compile the game with the resulting executable as `colobot.exe`.
The exe is linked against all libraries *statically*, so there are no dependencies
on external DLLs. However, the resulting binary will be huge with all these libraries,
so you might want to do: `strip bin/colobot.exe`.
6. If you want to create a Colobot installer, you need to additionally build 'nsis'
in MXE. Then you can create the NSIS installer that way:
`PATH=/path/to/mxe/binaries/:$PATH make package` This will create a versionned
colobot-$version.exe installer that will install Colobot in system directories,
add a shortcut in the start menu and setup an uninstaller.

60
INSTALL-MacOSX.md Normal file
View File

@ -0,0 +1,60 @@
# Compile and install instructions on MacOSX
To compile Colobot on MacOS X, you need to first get all tools, all
building dependencies (including the recompilation of some of them), and
finally compile colobot.
* Install git from [git-osx-installer on Google Code](https://code.google.com/p/git-osx-installer/)
* Install Xcode through the Mac AppStore
* Accept the Xcode license
xcodebuild -license
* Download and install Apple's Command Line Developer Tools from within Xcode (Preferences, Download, Components)
* Download and install [Mac Ports](http://www.macports.org/install.php#requirements)
* Install GCC 4.8 through MacPorts
sudo port install gcc48
* Install all colobot build depends
sudo port install cmake libsdl libsdl_image libsdl_ttf boost libsndfile glew libicns librsvg
> [po4a](http://po4a.alioth.debian.org/) should also be installed for the translation of levels, but the [MacPorts' Portfiles have not been accepted yet](http://trac.macports.org/ticket/41227).
* Rebuild libtiff locally
This is needed because of the following error:
> libtiff.5.dylib (for architecture x86_64) because larger updated load
> commands do not fit (the program must be relinked, and you may need to
> use -headerpad or -headerpad_max_install_names)
MacPorts changed the default linker flag, a simple local rebuild suffices:
sudo port -ns upgrade --force tiff
* Rebuild boost with the same gcc that we want to use
This is needed because boost is compiled against Mac's system libstdc++
which is older than the one used by gcc-4.8
sudo port -ns upgrade --force boost configure.compiler=macports-gcc-4.8
* Build colobot with gcc-4.8
mkdir -p build
cd build
CC=/opt/local/bin/gcc-mp-4.8 CXX=/opt/local/bin/g++-mp-4.8 cmake ..
make
* Build a Colobot drag-n-drop package
make package
* Open the package
open colobot-*.dmg
* Once opened, drag the Colobot application and drop it in the
Application directory. Then just launch it as any other application.

View File

@ -1,104 +1,180 @@
cmake_minimum_required(VERSION 2.8)
if(NOT PLATFORM_WINDOWS)
# Install Desktop Entry file
set(COLOBOT_DESKTOP_FILE colobot.desktop)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
COMMAND ./create_desktop_file.sh > ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Build ${COLOBOT_DESKTOP_FILE}"
)
add_custom_target(desktopfile ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE})
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/
)
# Install Icon
set(COLOBOT_ICON_FILE colobot.svg)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/
)
# Render SVG icon in various sizes
find_program(RSVG_CONVERT rsvg-convert)
if(RSVG_CONVERT)
foreach(PNGSIZE "48" "32" "16")
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE})
add_custom_target(resize_icon_${PNGSIZE} ALL
COMMAND ${RSVG_CONVERT} -w ${PNGSIZE} -h ${PNGSIZE} ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE}
> ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${PNGSIZE}x${PNGSIZE}/apps/
)
endforeach()
endif()
# Create manpage from pod-formatted file
find_program(POD2MAN pod2man)
if(POD2MAN)
set(COLOBOT_MANPAGE_SECTION 6)
macro(podman)
cmake_parse_arguments(PM "" "PODFILE;LOCALE;" "" ${ARGN})
if(PM_LOCALE)
# This copes with the fact that english has no "/LANG" in the paths and filenames.
set(SLASHLOCALE /${PM_LOCALE})
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
COMMAND ${POD2MAN} ARGS --section=${COLOBOT_MANPAGE_SECTION}
--center="Colobot" --stderr --utf8
--release="${COLOBOT_VERSION_FULL}"
${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
COMMENT "Create ${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} manpage"
)
add_custom_target(man${PM_LOCALE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION})
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man${SLASHLOCALE}/man${COLOBOT_MANPAGE_SECTION}/ )
add_dependencies(man man${PM_LOCALE})
endmacro()
# Create the english manpage
podman(PODFILE colobot.pod)
endif()
# Translate translatable material
find_program(PO4A po4a)
if(PO4A)
add_custom_target(desktop_po4a
COMMAND ${PO4A} po4a.cfg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(desktopfile desktop_po4a)
if(POD2MAN)
add_custom_target(man_po4a
COMMAND ${PO4A} po4a.cfg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(man man_po4a)
file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO})
foreach(LOCALE ${LINGUAS})
podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE})
add_dependencies(man${PM_LOCALE} man_po4a)
endforeach()
endif()
endif()
else() # if(NOT PLATFORM_WINDOWS)
set(COLOBOT_VERSION_4COMMAS "${COLOBOT_VERSION_MAJOR},${COLOBOT_VERSION_MINOR},${COLOBOT_VERSION_REVISION},0")
configure_file(colobot.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/colobot.rc)
set(COLOBOT_ICON_FILE colobot.svg)
# Render SVG icon in various sizes
find_program(RSVG_CONVERT rsvg-convert)
if(RSVG_CONVERT AND (PLATFORM_LINUX OR PLATFORM_MACOSX))
add_custom_target(png-icons ALL)
foreach(PNGSIZE 512 256 128 48 32 16)
add_custom_command(
OUTPUT ${PNGSIZE}/colobot.png
COMMAND mkdir -p ${PNGSIZE}
COMMAND ${RSVG_CONVERT} -w ${PNGSIZE} -h ${PNGSIZE} ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE} > ${PNGSIZE}/colobot.png
)
add_custom_target(png-icon-${PNGSIZE} ALL DEPENDS ${PNGSIZE}/colobot.png)
add_dependencies(png-icons png-icon-${PNGSIZE})
if(PLATFORM_LINUX)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${PNGSIZE}x${PNGSIZE}/apps/
)
endif()
# Prepare the ICNS icon generation
list(APPEND ICNS_SRCS "${PNGSIZE}/colobot.png")
endforeach()
# Pack icon for Mac OS
find_program(PNG2ICNS png2icns)
if(PNG2ICNS AND PLATFORM_MACOSX)
add_custom_command(OUTPUT Colobot.icns
COMMAND ${PNG2ICNS} Colobot.icns ${ICNS_SRCS}
DEPENDS png-icons
)
add_custom_target(icns-icon ALL DEPENDS Colobot.icns)
endif()
endif()
if(PLATFORM_LINUX)
# Install Desktop Entry file
set(COLOBOT_DESKTOP_FILE colobot.desktop)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
COMMAND ./create_desktop_file.sh > ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Build ${COLOBOT_DESKTOP_FILE}"
)
add_custom_target(desktopfile ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE})
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/
)
# Install Icon
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/
)
# Translate translatable material
find_program(PO4A po4a)
if(PO4A)
add_custom_target(desktop_po4a
COMMAND ${PO4A} po4a.cfg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(desktopfile desktop_po4a)
endif()
# Create manpage from pod-formatted file
find_program(POD2MAN pod2man)
if(POD2MAN)
set(COLOBOT_MANPAGE_SECTION 6)
macro(podman)
cmake_parse_arguments(PM "" "PODFILE;LOCALE;" "" ${ARGN})
if(PM_LOCALE)
# This copes with the fact that english has no "/LANG" in the paths and filenames.
set(SLASHLOCALE /${PM_LOCALE})
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
COMMAND ${POD2MAN} ARGS --section=${COLOBOT_MANPAGE_SECTION}
--center="Colobot" --stderr --utf8
--release="${COLOBOT_VERSION_FULL}"
${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
COMMENT "Create ${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} manpage"
)
add_custom_target(man${PM_LOCALE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION})
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man${SLASHLOCALE}/man${COLOBOT_MANPAGE_SECTION}/ )
add_dependencies(man man${PM_LOCALE})
endmacro()
# Create the english manpage
podman(PODFILE colobot.pod)
if(PO4A)
# Translate the manpage to other languages
add_dependencies(man desktop_po4a)
file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO})
foreach(LOCALE ${LINGUAS})
podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE})
add_dependencies(man${PM_LOCALE} desktop_po4a)
endforeach()
endif()
endif()
endif(PLATFORM_LINUX)
if(PLATFORM_MACOSX)
configure_file(Info.plist.cmake ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
endif(PLATFORM_MACOSX)
if(PLATFORM_WINDOWS)
set(COLOBOT_VERSION_4COMMAS "${COLOBOT_VERSION_MAJOR},${COLOBOT_VERSION_MINOR},${COLOBOT_VERSION_REVISION},0")
configure_file(colobot.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/colobot.rc)
endif(PLATFORM_WINDOWS)
##
# Packaging
##
set(CPACK_BUNDLE_NAME "Colobot")
set(CPACK_PACKAGE_FILE_NAME "colobot-${COLOBOT_VERSION_FULL}")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Colobot - Colonize with Bots")
set(CPACK_PACKAGE_VENDOR "Polish Portal of Colobot")
set(CPACK_PACKAGE_VERSION_MAJOR ${COLOBOT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${COLOBOT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${COLOBOT_VERSION_REVISION})
if(PLATFORM_WINDOWS)
set(CPACK_STRIP_FILES TRUE)
# Don't version the install directory, and allow overwriting
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Colobot")
set(CPACK_NSIS_DEFINES "SetOverwrite on\nBrandingText \\\"Colobot ${COLOBOT_VERSION_CODENAME} (${COLOBOT_VERSION_FULL})\\\"")
# Install the executable directly in Program Files/Colobot/
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
set(CPACK_PACKAGE_EXECUTABLES "colobot" "Colobot ${COLOBOT_VERSION_CODENAME}")
# Branding
## Installation and uninstallation icons
set(CPACK_NSIS_MUI_ICON ${CMAKE_CURRENT_SOURCE_DIR}/colobot.ico)
set(CPACK_NSIS_MUI_UNIICON ${CMAKE_CURRENT_SOURCE_DIR}/colobot.ico)
## Header and Left banner images
set(CPACK_PACKAGE_ICON "")
set(CPACK_NSIS_INSTALLER_ICON_CODE "!define MUI_HEADERIMAGE_BITMAP \\\"${CMAKE_CURRENT_SOURCE_DIR}/colobot_nsis.bmp\\\"
!define MUI_WELCOMEFINISHPAGE_BITMAP \\\"${CMAKE_CURRENT_SOURCE_DIR}/colobot_nsis_left.bmp\\\"")
## Allow to directly run Colobot at the end of the installation
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "colobot.exe")
## TODO: Find a way to have no license prompt. Until that, display the GPL-3
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE.txt)
elseif(PLATFORM_MACOSX)
set(CPACK_GENERATOR "Bundle")
set(CPACK_BUNDLE_ICON ${CMAKE_CURRENT_BINARY_DIR}/Colobot.icns)
set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_BINARY_DIR}/Colobot.icns)
set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
set(CPACK_BINARY_DRAGNDROP ON)
install(CODE "
include(BundleUtilities)
message(STATUS \"fixup_bundle(\${CMAKE_INSTALL_PREFIX}/${COLOBOT_INSTALL_BIN_DIR}/colobot/\")
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${COLOBOT_INSTALL_BIN_DIR}/colobot\" \"\" \"\")
")
endif()
include(CPack)

27
desktop/Info.plist.cmake Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>Colobot</string>
<key>CFBundleExecutable</key>
<string>colobot</string>
<key>CFBundleIconFile</key>
<string>Colobot</string>
<key>CFBundleIdentifier</key>
<string>info.colobot.colobot</string>
<key>CFBundleName</key>
<string>Colobot</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>cbot</string>
<key>CFBundleVersion</key>
<string>@COLOBOT_VERSION_FULL@</string>
</dict>
</plist>

BIN
desktop/colobot_nsis.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

View File

@ -56,21 +56,13 @@ if(PLATFORM_WINDOWS)
set(RES_FILES "../desktop/colobot.rc")
endif()
# Platform-dependent implementation of system.h
if(PLATFORM_WINDOWS)
set(SYSTEM_CPP_MODULE "system_windows.cpp")
elseif(PLATFORM_LINUX)
set(SYSTEM_CPP_MODULE "system_linux.cpp")
else()
set(SYSTEM_CPP_MODULE "system_other.cpp")
endif()
# Source files
set(SOURCES
app/app.cpp
app/main.cpp
app/system.cpp
app/${SYSTEM_CPP_MODULE}
app/system_other.cpp
common/event.cpp
common/image.cpp
common/iman.cpp
@ -237,5 +229,6 @@ add_executable(colobot ${SOURCES})
target_link_libraries(colobot ${LIBS})
install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
if(NOT CBOT_STATIC)
set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
endif()

View File

@ -147,8 +147,8 @@ CApplication::CApplication()
m_mouseButtonsState = 0;
m_trackedKeys = 0;
m_dataPath = COLOBOT_DEFAULT_DATADIR;
m_langPath = COLOBOT_I18N_DIR;
m_dataPath = GetSystemUtils()->GetDataPath();
m_langPath = GetSystemUtils()->GetLangPath();
m_texPackPath = "";
m_runSceneName = "";
@ -423,7 +423,10 @@ bool CApplication::Create()
return false;
}
#if !defined(PLATFORM_MACOSX)
// On Mac OSX, the bundle can potentially change place, it doesn't make sense to cache it to the configuration file
GetProfile().SetLocalProfileString("Resources", "Data", m_dataPath);
#endif
SetLanguage(m_language);
@ -437,12 +440,16 @@ bool CApplication::Create()
m_sound->Create(true);
#if !defined(PLATFORM_MACOSX)
// On Mac OSX, the bundle can potentially change place, it doesn't make sense to cache it to the configuration file
// Cache sound files
if (defaultValues)
{
GetProfile().SetLocalProfileString("Resources", "Sound", GetDataSubdirPath(DIR_SOUND));
GetProfile().SetLocalProfileString("Resources", "Music", GetDataSubdirPath(DIR_MUSIC));
}
#endif
if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Sound", path))
{

View File

@ -25,6 +25,8 @@
#include "app/system_windows.h"
#elif defined(PLATFORM_LINUX)
#include "app/system_linux.h"
#elif defined(PLATFORM_MACOSX)
#include "app/system_macosx.h"
#else
#include "app/system_other.h"
#endif
@ -48,6 +50,8 @@ CSystemUtils* CSystemUtils::Create()
m_instance = new CSystemUtilsWindows();
#elif defined(PLATFORM_LINUX)
m_instance = new CSystemUtilsLinux();
#elif defined(PLATFORM_MACOSX)
m_instance = new CSystemUtilsMacOSX();
#else
m_instance = new CSystemUtilsOther();
#endif
@ -188,6 +192,16 @@ float CSystemUtils::TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *afte
return result;
}
std::string CSystemUtils::GetDataPath()
{
return COLOBOT_DEFAULT_DATADIR;
}
std::string CSystemUtils::GetLangPath()
{
return COLOBOT_I18N_DIR;
}
std::string CSystemUtils::GetProfileFileLocation()
{
return std::string("colobot.ini");

View File

@ -130,6 +130,12 @@ public:
/** The difference is \a after - \a before. */
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) = 0;
//! Returns the data path (containing textures, levels, helpfiles, etc)
virtual std::string GetDataPath();
//! Returns the translations path
virtual std::string GetLangPath();
//! Returns the profile (colobot.ini) file location
virtual std::string GetProfileFileLocation();

116
src/app/system_macosx.cpp Normal file
View File

@ -0,0 +1,116 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2013, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
#include "app/system_macosx.h"
#include "common/logger.h"
#include <stdlib.h>
// MacOS-specific headers
#include <CoreFoundation/CFBundle.h>
#include <CoreServices/CoreServices.h>
#include <boost/filesystem.hpp>
inline std::string CFStringRefToStdString(CFStringRef str) {
std::string stdstr;
char *fullPath;
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
// 1st try for English system
fullPath = const_cast<char*>(CFStringGetCStringPtr(str, encodingMethod));
if( fullPath == NULL )
{
// 2nd try for Japanese system
encodingMethod = kCFStringEncodingUTF8;
fullPath = const_cast<char*>(CFStringGetCStringPtr(str, encodingMethod));
}
// for safer operation.
if( fullPath == NULL )
{
CFIndex length = CFStringGetLength(str);
fullPath = static_cast<char *>(malloc( length + 1 ));
// TODO: Check boolean result of that conversion
CFStringGetCString(str, fullPath, length, kCFStringEncodingUTF8 );
stdstr = fullPath;
free( fullPath );
}
else
stdstr = fullPath;
return stdstr;
}
void CSystemUtilsMacOSX::Init()
{
// These functions are a deprecated way to get the 'Application Support' folder, but they do work, in plain C++
FSRef ref;
OSType folderType = kApplicationSupportFolderType;
char path[PATH_MAX];
FSFindFolder( kUserDomain, folderType, kCreateFolder, &ref );
FSRefMakePath( &ref, reinterpret_cast<UInt8*>(&path), PATH_MAX );
m_ASPath = path;
m_ASPath.append("/colobot/");
// Make sure the directory exists
boost::filesystem::create_directories(m_ASPath.c_str());
// Get the Resources bundle URL
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyBundleURL(mainBundle);
CFStringRef str = CFURLCopyFileSystemPath( resourcesURL, kCFURLPOSIXPathStyle );
CFRelease(resourcesURL);
m_dataPath = CFStringRefToStdString(str);
m_dataPath += "/Contents/Resources";
}
std::string CSystemUtilsMacOSX::GetDataPath()
{
return m_dataPath;
}
std::string CSystemUtilsMacOSX::GetLangPath()
{
return m_dataPath + "/i18n";
}
std::string CSystemUtilsMacOSX::GetProfileFileLocation()
{
std::string profileFile = m_ASPath + "/colobot.ini";
GetLogger()->Trace("Profile file is %s\n", profileFile.c_str());
return profileFile;
}
std::string CSystemUtilsMacOSX::GetSavegameDirectoryLocation()
{
std::string savegameDir = m_ASPath + "/savegame";
boost::filesystem::create_directories(savegameDir.c_str());
GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
return savegameDir;
}

39
src/app/system_macosx.h Normal file
View File

@ -0,0 +1,39 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
/**
* \file app/system_macosx.h
* \brief MacOSX-specific implementation of system functions
*/
#include "app/system.h"
#include "app/system_other.h"
class CSystemUtilsMacOSX : public CSystemUtilsOther
{
public:
virtual void Init() override;
virtual std::string GetDataPath() override;
virtual std::string GetLangPath() override;
virtual std::string GetProfileFileLocation() override;
virtual std::string GetSavegameDirectoryLocation() override;
private:
std::string m_ASPath;
std::string m_dataPath;
};

View File

@ -6,6 +6,11 @@
#cmakedefine PLATFORM_MACOSX @PLATFORM_MACOSX@
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
#ifdef PLATFORM_MACOSX
// Assume we have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework
#define HAVE_CFLOCALECOPYCURRENT 1
#endif
#cmakedefine GLEW_STATIC
#cmakedefine OPENAL_SOUND

View File

@ -2,15 +2,6 @@ set(SRC_DIR ${colobot_SOURCE_DIR}/src)
configure_file(${SRC_DIR}/common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
# Platform-dependent implementation of system.h
if(PLATFORM_WINDOWS)
set(SYSTEM_CPP_MODULE "system_windows.cpp")
elseif(PLATFORM_LINUX)
set(SYSTEM_CPP_MODULE "system_linux.cpp")
else()
set(SYSTEM_CPP_MODULE "system_other.cpp")
endif()
set(TEXTURE_SOURCES
${SRC_DIR}/graphics/core/color.cpp
${SRC_DIR}/graphics/opengl/gldevice.cpp
@ -28,6 +19,7 @@ ${SRC_DIR}/common/image.cpp
${SRC_DIR}/common/stringutils.cpp
${SRC_DIR}/app/system.cpp
${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
${SRC_DIR}/app/system_other.cpp
model_test.cpp
)
@ -38,6 +30,7 @@ ${SRC_DIR}/common/logger.cpp
${SRC_DIR}/common/image.cpp
${SRC_DIR}/app/system.cpp
${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
${SRC_DIR}/app/system_other.cpp
transform_test.cpp
)
@ -48,6 +41,7 @@ ${SRC_DIR}/common/logger.cpp
${SRC_DIR}/common/image.cpp
${SRC_DIR}/app/system.cpp
${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
${SRC_DIR}/app/system_other.cpp
light_test.cpp
)
@ -68,6 +62,7 @@ ${SDLIMAGE_LIBRARY}
${OPENGL_LIBRARY}
${GLEW_LIBRARY}
${PNG_LIBRARIES}
${Boost_LIBRARIES}
)
add_executable(texture_test ${TEXTURE_SOURCES})

View File

@ -18,20 +18,12 @@ endif()
# Configure file
configure_file(${SRC_DIR}/common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
# Platform-dependent implementation of system.h
if(PLATFORM_WINDOWS)
set(SYSTEM_CPP_MODULE "system_windows.cpp")
elseif(PLATFORM_LINUX)
set(SYSTEM_CPP_MODULE "system_linux.cpp")
else()
set(SYSTEM_CPP_MODULE "system_other.cpp")
endif()
# Code sources
set(COLOBOT_SOURCES
${SRC_DIR}/app/app.cpp
${SRC_DIR}/app/system.cpp
${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
${SRC_DIR}/app/system_other.cpp
${SRC_DIR}/common/event.cpp
${SRC_DIR}/common/image.cpp
${SRC_DIR}/common/iman.cpp

View File

@ -10,21 +10,18 @@ ${CLIPBOARD_INCLUDE_DIR}
# Platform-dependent implementation of CSystemUtils
if(PLATFORM_WINDOWS)
set(SYSTEM_CPP_MODULE "system_windows.cpp")
elseif(PLATFORM_LINUX)
set(SYSTEM_CPP_MODULE "system_linux.cpp")
set(ADDITIONAL_LIB "-lX11")
elseif(PLATFORM_MACOSX)
set(SYSTEM_CPP_MODULE "system_other.cpp")
set(ADDITIONAL_LIB "${X11_X11_LIB}")
else()
set(SYSTEM_CPP_MODULE "system_other.cpp")
set(ADDITIONAL_LIB "-lX11")
endif()
add_executable(edit_test
${SRC_DIR}/app/system.cpp
${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
${SRC_DIR}/app/system_other.cpp
${SRC_DIR}/common/event.cpp
${SRC_DIR}/common/logger.cpp
${SRC_DIR}/common/misc.cpp