Skip to content

Commit fb11ada

Browse files
committed
iOS initial
1 parent afe3cfe commit fb11ada

7 files changed

+31
-12
lines changed

CMakeLists.txt

+11-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ if(WIN32)
4040
else()
4141
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows -lstdc++fs")
4242
endif()
43+
elseif(APPLE OR IOS)
44+
enable_language(OBJCXX)
45+
set(MACOSX_BUNDLE_GUI_IDENTIFIER "opengothic.gothic2")
46+
set(MACOSX_BUNDLE_INFO_PLIST, "${MACOSX_BUNDLE_GUI_IDENTIFIER}")
47+
set(MACOSX_BUNDLE_BUNDLE_VERSION 1)
48+
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.0")
49+
set(CMAKE_OSX_DEPLOYMENT_TARGET 15.0)
50+
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY XCODE_STARTUP_PROJECT ${PROJECT_NAME})
4351
endif()
4452

45-
if(APPLE)
46-
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)
47-
enable_language(OBJCXX)
53+
if(IOS)
54+
file(GLOB_RECURSE ObjCSOURCES "game/*.mm")
55+
elseif(APPLE)
4856
target_link_libraries(${PROJECT_NAME} "-framework AppKit")
4957
file(GLOB_RECURSE ObjCSOURCES "game/*.mm")
5058
endif()

game/commandline.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ CommandLine::CommandLine(int argc, const char** argv) {
9292
if(gpath.empty()) {
9393
InstallDetect inst;
9494
gpath = inst.detectG2();
95-
#ifdef __OSX__
95+
#if defined(__OSX__) || defined(__IOS__)
9696
if(!gpath.empty() && gpath==inst.applicationSupportDirectory()) {
9797
std::filesystem::current_path(gpath);
9898
}

game/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <Tempest/DirectX12Api>
1111
#endif
1212

13-
#if defined(__OSX__)
13+
#if defined(__OSX__) || defined(__IOS__)
1414
#include <Tempest/MetalApi>
1515
#endif
1616

@@ -47,14 +47,14 @@ std::unique_ptr<Tempest::AbstractGraphicsApi> mkApi(const CommandLine& g) {
4747
break;
4848
#endif
4949
case CommandLine::Vulkan:
50-
#if !defined(__OSX__)
50+
#if !defined(__OSX__) && !defined(__IOS__)
5151
return std::make_unique<Tempest::VulkanApi>(flg);
5252
#else
5353
break;
5454
#endif
5555
}
5656

57-
#if defined(__OSX__)
57+
#if defined(__OSX__) || defined(__IOS__)
5858
return std::make_unique<Tempest::MetalApi>(flg);
5959
#else
6060
return std::make_unique<Tempest::VulkanApi>(flg);

game/utils/installdetect.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ InstallDetect::InstallDetect() {
1616
pfiles = programFiles(false);
1717
pfilesX86 = programFiles(true);
1818
#endif
19-
#ifdef __OSX__
19+
#if defined(__OSX__) || defined(__IOS__)
2020
appDir = applicationSupportDirectory();
2121
#endif
2222
}
@@ -27,7 +27,7 @@ std::u16string InstallDetect::detectG2() {
2727
if(ret.empty())
2828
ret = detectG2(pfilesX86);
2929
return ret;
30-
#elif defined(__OSX__)
30+
#elif defined(__OSX__) || defined(__IOS__)
3131
if(FileUtil::exists(appDir))
3232
return appDir;
3333
return u"";

game/utils/installdetect.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class InstallDetect final {
88
InstallDetect();
99

1010
std::u16string detectG2();
11-
#ifdef __OSX__
11+
#if defined(__OSX__) || defined(__IOS__)
1212
static std::u16string applicationSupportDirectory();
1313
#endif
1414

@@ -20,7 +20,7 @@ class InstallDetect final {
2020
std::u16string pfiles, pfilesX86;
2121
#endif
2222

23-
#ifdef __OSX__
23+
#if defined(__OSX__) || defined(__IOS__)
2424
std::u16string appDir;
2525
#endif
2626
};

game/utils/installdetect.mm

+11
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,25 @@
77
#include <Tempest/TextCodec>
88

99
#import <Foundation/Foundation.h>
10+
11+
#if defined(OSX)
1012
#import <Cocoa/Cocoa.h>
13+
#endif
1114

1215
std::u16string InstallDetect::applicationSupportDirectory() {
1316
std::string ret;
1417

18+
#if defined(__OSX__)
1519
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
20+
#else
21+
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
22+
#endif
1623
if(paths!=nil && [paths count]>0) {
24+
#if defined(__OSX__)
1725
NSString* app = [[paths firstObject] stringByAppendingPathComponent:@"OpenGothic"];
26+
#else
27+
NSString* app = [[paths firstObject] stringByAppendingPathComponent:@""];
28+
#endif
1829
if(app!=nil) {
1930
ret = [app cStringUsingEncoding:NSUTF8StringEncoding];
2031
[app release];

0 commit comments

Comments
 (0)