File: CMakeLists.txt

package info (click to toggle)
openmohaa 0.81.1%2Bdfsg-2
  • links: PTS, VCS
  • area: contrib
  • in suites: trixie
  • size: 29,124 kB
  • sloc: ansic: 270,865; cpp: 250,173; sh: 234; asm: 141; xml: 64; makefile: 7
file content (85 lines) | stat: -rw-r--r-- 2,275 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
cmake_minimum_required(VERSION 3.12)

project(omohsdl)

set(SOURCES_SDL_CLIENT
"./sdl_input.c"
)

set(SOURCES_SDL_GL
"./sdl_gamma.c"
"./sdl_glimp.c"
)

if (NO_MODERN_DMA)
	list(APPEND SOURCES_SDL "./sdl_snd.c")
endif()

add_library(omohsdl_client STATIC ${SOURCES_SDL_CLIENT})
target_compile_features(omohsdl_client PUBLIC c_variadic_macros)
target_link_libraries(omohsdl_client PRIVATE qcommon qcommon_standalone)

if (NO_MODERN_DMA)
	target_compile_definitions(omohsdl_client PRIVATE NO_MODERN_DMA=1)
endif()

add_library(omohsdl_gl STATIC ${SOURCES_SDL_GL})
target_link_libraries(omohsdl_gl PRIVATE qcommon)

if(${CMAKE_VERSION} VERSION_GREATER "3.11")
	cmake_policy(SET CMP0074 NEW)
endif()

add_library(sdllib INTERFACE)

if(WIN32)
	find_package(SDL2)

	if (SDL2_FOUND)
		string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
		target_include_directories(sdllib INTERFACE ${SDL2_INCLUDE_DIRS})
		target_link_libraries(sdllib INTERFACE ${SDL2_LIBRARIES})
	else()
		message(WARNING "SDL2 not found, falling back to using SDL2 from the source tree")

		target_include_directories(sdllib INTERFACE "../SDL2/include-2.0.22")

		if (MSVC)
			if(CMAKE_SIZEOF_VOID_P EQUAL 8)
				add_library(sdl2 SHARED IMPORTED)
				set_target_properties(sdl2 PROPERTIES
				  IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/libs/win64/SDL264.lib"
				)

				add_library(sdl2main SHARED IMPORTED)
				set_target_properties(sdl2main PROPERTIES
				  IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/libs/win64/SDL264main.lib"
				)
			else()
				add_library(sdl2 SHARED IMPORTED)
				set_target_properties(sdl2 PROPERTIES
				  IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/libs/win32/SDL2.lib"
				)

				add_library(sdl2main SHARED IMPORTED)
				set_target_properties(sdl2main PROPERTIES
				  IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/libs/win32/SDL2main.lib"
				)
			endif()

			target_link_libraries(sdllib INTERFACE sdl2 sdl2main)
		endif()
	endif()

elseif(UNIX)
	find_package(SDL2 REQUIRED)
	
	if (SDL2_FOUND)
		string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
		target_include_directories(sdllib INTERFACE ${SDL2_INCLUDE_DIRS})
		target_link_libraries(sdllib INTERFACE ${SDL2_LIBRARIES})
	endif()
endif()

target_link_libraries(omohsdl_client PUBLIC sdllib)
target_link_libraries(omohsdl_gl PUBLIC sdllib)