mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-27 19:50:51 +00:00
cmake: on mac, check Resources in bundle first.
on non debug, check assets folder in src as well
This commit is contained in:
parent
e54338ef01
commit
70f046a320
6 changed files with 80 additions and 12 deletions
|
@ -81,18 +81,6 @@ include(GitUtilities)
|
||||||
git_describe(SRB2_COMP_REVISION "${CMAKE_CURRENT_SOURCE_DIR}")
|
git_describe(SRB2_COMP_REVISION "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
|
||||||
|
|
||||||
|
|
||||||
# Mac bundle fixup
|
|
||||||
if(CLANG)
|
|
||||||
install(CODE "
|
|
||||||
include(BundleUtilities)
|
|
||||||
fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/Sonic Robo Blast 2.app\"
|
|
||||||
\"\"
|
|
||||||
/Library/Frameworks
|
|
||||||
)"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
##### PACKAGE CONFIGURATION #####
|
##### PACKAGE CONFIGURATION #####
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM} MATCHES "Windows")
|
if(${CMAKE_SYSTEM} MATCHES "Windows")
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
|
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
|
||||||
|
|
||||||
|
#define CMAKE_ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
|
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
|
||||||
|
|
|
@ -89,6 +89,8 @@ if(${SDL2_FOUND})
|
||||||
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
||||||
macosx/mac_alert.c
|
macosx/mac_alert.c
|
||||||
macosx/mac_alert.h
|
macosx/mac_alert.h
|
||||||
|
macosx/mac_resources.c
|
||||||
|
macosx/mac_resources.h
|
||||||
macosx/Srb2mac.icns
|
macosx/Srb2mac.icns
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@ -205,6 +207,18 @@ if(${SDL2_FOUND})
|
||||||
DESTINATION .
|
DESTINATION .
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# Mac bundle fixup
|
||||||
|
if(CLANG)
|
||||||
|
install(CODE "
|
||||||
|
include(BundleUtilities)
|
||||||
|
fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/Sonic Robo Blast 2.app\"
|
||||||
|
\"\"
|
||||||
|
/Library/Frameworks
|
||||||
|
)"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
message(WARNING "SDL2 wasn't found, so ${SRB2_SDL2_EXE_NAME} won't be available")
|
message(WARNING "SDL2 wasn't found, so ${SRB2_SDL2_EXE_NAME} won't be available")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
/// \file
|
/// \file
|
||||||
/// \brief SRB2 system stuff for SDL
|
/// \brief SRB2 system stuff for SDL
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
#ifndef _WIN32_WCE
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -145,6 +147,10 @@ void __set_fpscr(long); // in libgcc / kernel's startup.s?
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include "macosx/mac_resources.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Locations for searching the srb2.srb
|
// Locations for searching the srb2.srb
|
||||||
#ifdef _arch_dreamcast
|
#ifdef _arch_dreamcast
|
||||||
#define DEFAULTWADLOCATION1 "/cd"
|
#define DEFAULTWADLOCATION1 "/cd"
|
||||||
|
@ -2758,6 +2764,28 @@ static const char *locateWad(void)
|
||||||
if (isWadPathOk(returnWadPath))
|
if (isWadPathOk(returnWadPath))
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CMAKECONFIG
|
||||||
|
#ifndef NDEBUG
|
||||||
|
I_OutputMsg(","CMAKE_ASSETS_DIR);
|
||||||
|
strcpy(returnWadPath, CMAKE_ASSETS_DIR);
|
||||||
|
if (isWadPathOk(returnWadPath))
|
||||||
|
{
|
||||||
|
return returnWadPath;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
OSX_GetResourcesPath(returnWadPath);
|
||||||
|
I_OutputMsg(",%s", returnWadPath);
|
||||||
|
if (isWadPathOk(returnWadPath))
|
||||||
|
{
|
||||||
|
return returnWadPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// examine default dirs
|
// examine default dirs
|
||||||
#ifdef DEFAULTWADLOCATION1
|
#ifdef DEFAULTWADLOCATION1
|
||||||
|
|
31
src/sdl/macosx/mac_resources.c
Normal file
31
src/sdl/macosx/mac_resources.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include "mac_resources.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
|
||||||
|
void OSX_GetResourcesPath(char * buffer)
|
||||||
|
{
|
||||||
|
CFBundleRef mainBundle;
|
||||||
|
mainBundle = CFBundleGetMainBundle();
|
||||||
|
if (mainBundle)
|
||||||
|
{
|
||||||
|
CFURLRef appUrlRef = CFBundleCopyBundleURL(mainBundle);
|
||||||
|
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
|
||||||
|
CFStringRef resources = CFStringCreateWithCString(kCFAllocatorMalloc, "/Contents/Resources", kCFStringEncodingASCII);
|
||||||
|
const void* rawarray[2] = {macPath, resources};
|
||||||
|
CFArrayRef array = CFArrayCreate(kCFAllocatorMalloc, rawarray, 2, NULL);
|
||||||
|
CFStringRef separator = CFStringCreateWithCString(kCFAllocatorMalloc, "", kCFStringEncodingASCII);
|
||||||
|
CFStringRef fullPath = CFStringCreateByCombiningStrings(kCFAllocatorMalloc, array, separator);
|
||||||
|
const char * path = CFStringGetCStringPtr(fullPath, kCFStringEncodingASCII);
|
||||||
|
strcpy(buffer, path);
|
||||||
|
CFRelease(fullPath);
|
||||||
|
path = NULL;
|
||||||
|
CFRelease(array);
|
||||||
|
CFRelease(resources);
|
||||||
|
CFRelease(macPath);
|
||||||
|
CFRelease(appUrlRef);
|
||||||
|
//CFRelease(mainBundle);
|
||||||
|
CFRelease(separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
5
src/sdl/macosx/mac_resources.h
Normal file
5
src/sdl/macosx/mac_resources.h
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#ifndef __MAC_RESOURCES_H__
|
||||||
|
#define __MAC_RESOURCES_H__
|
||||||
|
|
||||||
|
void OSX_GetResourcesPath(char * buffer);
|
||||||
|
#endif
|
Loading…
Reference in a new issue