mirror of
				https://github.com/GayPizzaSpecifications/cxx-swift-interop.git
				synced 2025-11-04 04:09:37 +00:00 
			
		
		
		
	SDL3 support
This commit is contained in:
		@ -5,4 +5,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
 | 
				
			|||||||
include(InitializeSwift)
 | 
					include(InitializeSwift)
 | 
				
			||||||
include(AddSwift)
 | 
					include(AddSwift)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					find_package(SDL3 CONFIG REQUIRED)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_subdirectory(Sources)
 | 
					add_subdirectory(Sources)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,2 +1,3 @@
 | 
				
			|||||||
add_subdirectory(SwiftFrontend)
 | 
					add_subdirectory(SwiftFrontend)
 | 
				
			||||||
 | 
					add_subdirectory(SDL3)
 | 
				
			||||||
add_subdirectory(CppBackend)
 | 
					add_subdirectory(CppBackend)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								Sources/SDL3/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Sources/SDL3/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					add_library(SDL3 STATIC SDL3.h SDL3.cpp)
 | 
				
			||||||
 | 
					set_property(TARGET SDL3 PROPERTY Swift_MODULE_NAME "SDL3")
 | 
				
			||||||
 | 
					set_property(TARGET SDL3 PROPERTY CXX_STANDARD 20)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					target_compile_options(SDL3 PUBLIC "$<$<COMPILE_LANGUAGE:Swift>:-cxx-interoperability-mode=default>")
 | 
				
			||||||
 | 
					target_include_directories(SDL3 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
 | 
				
			||||||
 | 
					target_link_libraries(SDL3 PUBLIC SDL3::SDL3)
 | 
				
			||||||
							
								
								
									
										1
									
								
								Sources/SDL3/SDL3.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								Sources/SDL3/SDL3.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					#include "SDL3.h"
 | 
				
			||||||
							
								
								
									
										3
									
								
								Sources/SDL3/SDL3.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								Sources/SDL3/SDL3.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <SDL3/SDL.h>
 | 
				
			||||||
							
								
								
									
										3
									
								
								Sources/SDL3/module.modulemap
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								Sources/SDL3/module.modulemap
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					module SDL3 {
 | 
				
			||||||
 | 
					  header "SDL3.h"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,2 +1,2 @@
 | 
				
			|||||||
add_executable(SwiftFrontend main.swift)
 | 
					add_executable(SwiftFrontend main.swift)
 | 
				
			||||||
target_link_libraries(SwiftFrontend PRIVATE CppBackend)
 | 
					target_link_libraries(SwiftFrontend PRIVATE CppBackend SDL3)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,9 @@
 | 
				
			|||||||
import CppBackend
 | 
					import Foundation
 | 
				
			||||||
 | 
					import SDL3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
backend_init()
 | 
					guard SDL_Init(SDL_INIT_VIDEO) >= 0 else {
 | 
				
			||||||
print("Hello World")
 | 
					    print("SDL init failed.")
 | 
				
			||||||
 | 
					    exit(0)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					print("SDL init success.")
 | 
				
			||||||
 | 
					SDL_Quit()
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user