tangled
alpha
login
or
join now
keii.dev
/
SDL
0
fork
atom
Simple Directmedia Layer
0
fork
atom
overview
issues
pulls
pipelines
cmake: add swift test
Anonymous Maarten
2 years ago
8a5d1fc1
37881b31
+45
4 changed files
expand all
collapse all
unified
split
cmake
test
CMakeLists.txt
main.swift
swift
module.modulemap
shim.h
+25
cmake/test/CMakeLists.txt
reviewed
···
3
3
cmake_minimum_required(VERSION 3.12)
4
4
project(sdl_test LANGUAGES C)
5
5
6
6
+
include(CheckLanguage)
7
7
+
8
8
+
if(APPLE)
9
9
+
# multiple values for CMAKE_OSX_ARCHITECTURES not supported with Swift
10
10
+
list(LENGTH CMAKE_OSX_ARCHITECTURES count_osx_archs)
11
11
+
if(count_osx_archs LESS_EQUAL 1)
12
12
+
check_language(Swift)
13
13
+
if(CMAKE_Swift_COMPILER)
14
14
+
enable_language(Swift)
15
15
+
endif()
16
16
+
endif()
17
17
+
endif()
18
18
+
6
19
message(STATUS "CMAKE_SYSTEM_NAME= ${CMAKE_SYSTEM_NAME}")
7
20
message(STATUS "CMAKE_SYSTEM_PROCESSOR= ${CMAKE_SYSTEM_PROCESSOR}")
8
21
···
74
87
add_executable(sdltest-shared sdltest.c)
75
88
target_link_libraries(sdltest-shared PRIVATE SDL3::SDL3_test SDL3::SDL3-shared)
76
89
endif()
90
90
+
91
91
+
if(CMAKE_Swift_COMPILER)
92
92
+
add_executable(swift-shared main.swift)
93
93
+
target_include_directories(swift-shared PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
94
94
+
target_link_libraries(swift-shared PRIVATE SDL3::SDL3-shared)
95
95
+
endif()
77
96
endif()
78
97
79
98
if(TEST_STATIC)
···
91
110
if(TEST_TEST)
92
111
add_executable(sdltest-static sdltest.c)
93
112
target_link_libraries(sdltest-static PRIVATE SDL3::SDL3_test SDL3::SDL3-static)
113
113
+
endif()
114
114
+
115
115
+
if(CMAKE_Swift_COMPILER)
116
116
+
add_executable(swift-static main.swift)
117
117
+
target_include_directories(swift-static PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
118
118
+
target_link_libraries(swift-static PRIVATE SDL3::SDL3-static)
94
119
endif()
95
120
endif()
96
121
+13
cmake/test/main.swift
reviewed
···
1
1
+
/* Contributed by Piotr Usewicz (https://github.com/pusewicz) */
2
2
+
3
3
+
import SDL3
4
4
+
5
5
+
guard SDL_Init(Uint32(SDL_INIT_VIDEO)) == 0 else {
6
6
+
fatalError("SDL_Init error: \(String(cString: SDL_GetError()))")
7
7
+
}
8
8
+
9
9
+
var sdlVersion = SDL_GetVersion()
10
10
+
11
11
+
print("SDL version: \(sdlVersion)")
12
12
+
13
13
+
SDL_Quit()
+4
cmake/test/swift/module.modulemap
reviewed
···
1
1
+
module SDL3 [extern_c] {
2
2
+
header "shim.h"
3
3
+
export *
4
4
+
}
+3
cmake/test/swift/shim.h
reviewed
···
1
1
+
/* Contributed by Piotr Usewicz (https://github.com/pusewicz) */
2
2
+
3
3
+
#include <SDL3/SDL.h>