diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b40c90..82512de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) set(CMAKE_OSX_DEPLOYMENT_TARGET "13.6" CACHE STRING "Minimum MacOS version" FORCE) set(CMAKE_Swift_LANGUAGE_VERSION 5) -project(voxelotl LANGUAGES C Swift VERSION "0.1.0") +project(voxelotl LANGUAGES C OBJC Swift VERSION "0.1.0") find_library(SDL3 SDL3 REQUIRED PATHS "${CMAKE_SOURCE_DIR}/Frameworks" NO_DEFAULT_PATH) diff --git a/Sources/Voxelotl/CMakeLists.txt b/Sources/Voxelotl/CMakeLists.txt index d2ffd3d..5d3845a 100644 --- a/Sources/Voxelotl/CMakeLists.txt +++ b/Sources/Voxelotl/CMakeLists.txt @@ -66,7 +66,10 @@ add_executable(Voxelotl MACOSX_BUNDLE GameDelegate.swift Application.swift - main.swift) + # Entry point + Program.swift + main.m +) set_source_files_properties( shader.metal PROPERTIES @@ -103,7 +106,7 @@ set_source_files_properties(test.png PROPERTIES MACOSX_PACKAGE_LOCATION Resource #TODO: should use TREE mode as documented in https://cmake.org/cmake/help/latest/command/source_group.html source_group("Resources" FILES Assets.xcassets test.png) -source_group("Source Files" REGULAR_EXPRESSION "\\.(swift|metal)$") +source_group("Source Files" REGULAR_EXPRESSION "\\.(swift|metal|m)$") source_group("Source Files\\Common" REGULAR_EXPRESSION "Common/") source_group("Source Files\\Random" REGULAR_EXPRESSION "Random/") source_group("Source Files\\Noise" REGULAR_EXPRESSION "Noise/") diff --git a/Sources/Voxelotl/Program.swift b/Sources/Voxelotl/Program.swift new file mode 100644 index 0000000..576e156 --- /dev/null +++ b/Sources/Voxelotl/Program.swift @@ -0,0 +1,17 @@ +import Foundation + +@objc public class Program: NSObject { + @objc public static func run() -> Int32 { + Thread.current.qualityOfService = .userInteractive + + let app = Application( + delegate: Game(), + configuration: ApplicationConfiguration( + frame: Size(1280, 720), + title: "Voxelotl Demo", + flags: [ .resizable, .highDPI ], + vsyncMode: .on(interval: 1))) + + return app.run() + } +} diff --git a/Sources/Voxelotl/main.m b/Sources/Voxelotl/main.m new file mode 100644 index 0000000..55a5644 --- /dev/null +++ b/Sources/Voxelotl/main.m @@ -0,0 +1,6 @@ +#include +#include + +int main(int argc, char** argv) { + return [Program run]; +} diff --git a/Sources/Voxelotl/main.swift b/Sources/Voxelotl/main.swift deleted file mode 100644 index 0f20905..0000000 --- a/Sources/Voxelotl/main.swift +++ /dev/null @@ -1,13 +0,0 @@ -import Foundation - -Thread.current.qualityOfService = .userInteractive - -let app = Application( - delegate: Game(), - configuration: ApplicationConfiguration( - frame: Size(1280, 720), - title: "Voxelotl Demo", - flags: [ .resizable, .highDPI ], - vsyncMode: .on(interval: 1))) - -exit(app.run())