summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt50
-rw-r--r--src/client.cpp18
-rw-r--r--src/main.cpp11
-rw-r--r--src/utils/specialfolder.cpp23
-rw-r--r--src/utils/specialfolder.h5
5 files changed, 74 insertions, 33 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 72b44ac6..bf0a3e4c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,10 +20,10 @@ ENDIF()
SET(FLAGS "-DPACKAGE_VERSION=\\\"${VERSION}\\\"")
IF (WIN32)
- SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${PKG_DATADIR}/\\\"")
+ SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${CMAKE_INSTALL_DATADIR}/\\\"")
SET(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${CMAKE_INSTALL_LOCALEDIR}/\\\"")
-ELSE()
- SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${CMAKE_INSTALL_FULL_DATAROOTDIR}/mana/\\\"")
+ELSEIF(NOT APPLE)
+ SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${CMAKE_INSTALL_FULL_DATADIR}/\\\"")
SET(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${CMAKE_INSTALL_FULL_LOCALEDIR}/\\\"")
ENDIF()
@@ -384,6 +384,8 @@ SET(SRCS
utils/physfsrwops.h
utils/sha256.cpp
utils/sha256.h
+ utils/specialfolder.cpp
+ utils/specialfolder.h
utils/stringutils.cpp
utils/stringutils.h
utils/mutex.h
@@ -613,20 +615,20 @@ SET(SRCS_MANA
IF (WIN32)
CONFIGURE_FILE(mana.rc.in mana.rc)
- SET(SRCS
- ${SRCS}
- utils/specialfolder.cpp
- utils/specialfolder.h
- ${CMAKE_CURRENT_BINARY_DIR}/mana.rc
- )
+ SET(SRCS ${SRCS} ${CMAKE_CURRENT_BINARY_DIR}/mana.rc)
ENDIF (WIN32)
SET (PROGRAMS mana)
+set(APP_ICON_NAME "mana.icns")
+set(APP_ICON_FILE "${CMAKE_SOURCE_DIR}/data/icons/${APP_ICON_NAME}")
+set_source_files_properties(${APP_ICON_FILE} PROPERTIES
+ MACOSX_PACKAGE_LOCATION "Resources")
+
IF (ENABLE_MANASERV)
- ADD_EXECUTABLE(mana WIN32 ${SRCS} ${SRCS_MANA} ${SRCS_TMWA})
+ ADD_EXECUTABLE(mana WIN32 ${SRCS} ${SRCS_MANA} ${SRCS_TMWA} ${APP_ICON_FILE})
ELSE(ENABLE_MANASERV)
- ADD_EXECUTABLE(mana WIN32 ${SRCS} ${SRCS_TMWA})
+ ADD_EXECUTABLE(mana WIN32 ${SRCS} ${SRCS_TMWA} ${APP_ICON_FILE})
ENDIF(ENABLE_MANASERV)
TARGET_LINK_LIBRARIES(mana PRIVATE
@@ -641,16 +643,34 @@ TARGET_LINK_LIBRARIES(mana PRIVATE
${LIBINTL_LIBRARIES}
${EXTRA_LIBRARIES})
+SET_TARGET_PROPERTIES(mana PROPERTIES
+ COMPILE_FLAGS "${FLAGS}"
+ MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
+ MACOSX_BUNDLE_GUI_IDENTIFIER org.manasource.Mana
+ MACOSX_BUNDLE_ICON_FILE ${APP_ICON_NAME}
+ MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
+ MACOSX_BUNDLE_COPYRIGHT "(C) 2004-2024 ${CPACK_PACKAGE_VENDOR}"
+ MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}
+ MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
+
+INSTALL(TARGETS mana
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+
if(APPLE)
target_link_libraries(mana PRIVATE "-framework Foundation")
-endif()
+ SET_TARGET_PROPERTIES(mana PROPERTIES
+ OUTPUT_NAME Mana)
+
+ set(CPACK_GENERATOR "DRAGNDROP")
-INSTALL(TARGETS mana RUNTIME DESTINATION ${PKG_BINDIR})
+ install(CODE "include(BundleUtilities)
+ fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Mana.app\" \"\" \"/usr/local/lib\")")
+endif()
IF (CMAKE_SYSTEM_NAME STREQUAL SunOS)
# we expect the SMCgtxt package to be present on Solaris;
# the Solaris gettext is not API-compatible to GNU gettext
SET_TARGET_PROPERTIES(mana PROPERTIES LINK_FLAGS "-L/usr/local/lib")
ENDIF()
-
-SET_TARGET_PROPERTIES(mana PROPERTIES COMPILE_FLAGS "${FLAGS}")
diff --git a/src/client.cpp b/src/client.cpp
index 6e12a579..6fe64b2a 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -70,17 +70,13 @@
#include "utils/gettext.h"
#include "utils/mkdir.h"
+#include "utils/specialfolder.h"
#include "utils/stringutils.h"
-#ifdef __APPLE__
-#include <CoreFoundation/CFBundle.h>
-#endif
-
#include <physfs.h>
#include <SDL_image.h>
#ifdef _WIN32
-#include "utils/specialfolder.h"
#include <SDL_syswm.h>
#include <winuser.h>
#endif
@@ -264,17 +260,7 @@ Client::Client(const Options &options):
}
#if defined __APPLE__
- CFBundleRef mainBundle = CFBundleGetMainBundle();
- CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
- char path[PATH_MAX];
- if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path,
- PATH_MAX))
- {
- fprintf(stderr, "Can't find Resources directory\n");
- }
- CFRelease(resourcesURL);
- strncat(path, "/data", PATH_MAX - 1);
- mPackageDir = path;
+ mPackageDir = getResourcesLocation() + "/data";
#else
mPackageDir = PKG_DATADIR "data";
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 68a6b0c3..935f2d89 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,6 +37,10 @@
#include <winnls.h>
#endif
+#ifdef __APPLE__
+#include "utils/specialfolder.h"
+#endif
+
static void printHelp()
{
using std::endl;
@@ -213,7 +217,14 @@ static void initInternationalization()
#endif // _WIN32
setlocale(LC_MESSAGES, "");
+
+#ifdef __APPLE__
+ const auto translationsDir = getResourcesLocation() + "/Translations";
+ bindtextdomain("mana", translationsDir.c_str());
+#else
bindtextdomain("mana", LOCALEDIR);
+#endif
+
bind_textdomain_codeset("mana", "UTF-8");
textdomain("mana");
#endif // ENABLE_NLS
diff --git a/src/utils/specialfolder.cpp b/src/utils/specialfolder.cpp
index c351ba1a..c882534d 100644
--- a/src/utils/specialfolder.cpp
+++ b/src/utils/specialfolder.cpp
@@ -18,8 +18,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef _WIN32
#include "specialfolder.h"
+
+#ifdef _WIN32
#include <windows.h>
#include <stdlib.h>
@@ -74,4 +75,22 @@ int main()
<< std::endl;
}
#endif
-#endif
+#endif // _WIN32
+
+#ifdef __APPLE__
+#include <CoreFoundation/CFBundle.h>
+
+std::string getResourcesLocation()
+{
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
+ char path[PATH_MAX];
+ if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path,
+ PATH_MAX))
+ {
+ fprintf(stderr, "Can't find Resources directory\n");
+ }
+ CFRelease(resourcesURL);
+ return path;
+}
+#endif // __APPLE__
diff --git a/src/utils/specialfolder.h b/src/utils/specialfolder.h
index 8570d009..36a4e0c1 100644
--- a/src/utils/specialfolder.h
+++ b/src/utils/specialfolder.h
@@ -27,4 +27,9 @@
std::string getSpecialFolderLocation(const KNOWNFOLDERID &folderId);
#endif
+#ifdef __APPLE__
+#include <string>
+std::string getResourcesLocation();
+#endif
+
#endif