-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
92 lines (73 loc) · 2.08 KB
/
CMakeLists.txt
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
86
87
88
89
90
91
92
#[[
SDL2W - CMake wrapper for SDL2.
Test program.
Copyright (c) 2018-2024 Boris I. Bendovsky ([email protected]) and Contributors.
SPDX-License-Identifier: MIT
]]
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
project(test_cmake_sdl2w VERSION 1.0.7 LANGUAGES C)
# Options.
#
option(TEST_CMAKE_SDL2W_USE_STATIC_LINKING "Use static linking." OFF)
option(TEST_CMAKE_SDL2W_NET "Use SDL_net." ON)
# Setup components.
#
set(TEST_CMAKE_SDL2W_COMPONENTS "")
set(TEST_CMAKE_SDL2W_NET_COMPONENTS "")
if (TEST_CMAKE_SDL2W_USE_STATIC_LINKING)
set(TEST_CMAKE_SDL2W_COMPONENTS "${TEST_CMAKE_SDL2W_COMPONENTS};static")
if (TEST_CMAKE_SDL2W_NET)
set(TEST_CMAKE_SDL2W_NET_COMPONENTS "${TEST_CMAKE_SDL2W_NET_COMPONENTS};static")
endif ()
endif ()
# Find packages.
#
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
find_package(SDL2W 2.0.0 REQUIRED COMPONENTS ${TEST_CMAKE_SDL2W_COMPONENTS})
if (TEST_CMAKE_SDL2W_NET)
find_package(SDL2W_net 2.0.0 REQUIRED COMPONENTS ${TEST_CMAKE_SDL2W_NET_COMPONENTS})
endif ()
# Target.
#
add_executable(test_cmake_sdl2w "")
# Target properties.
#
if (WIN32)
set_target_properties(test_cmake_sdl2w PROPERTIES WIN32_EXECUTABLE TRUE)
endif ()
# Compile definitions.
#
if (TEST_CMAKE_SDL2W_NET)
target_compile_definitions(test_cmake_sdl2w PRIVATE TEST_CMAKE_SDL2W_NET)
endif ()
# Dependencies.
#
if (MINGW)
target_link_libraries(test_cmake_sdl2w PRIVATE -mconsole)
endif ()
if (TEST_CMAKE_SDL2W_USE_STATIC_LINKING)
if (NOT WIN32 OR MINGW)
target_link_libraries(test_cmake_sdl2w PRIVATE -static)
endif ()
endif ()
if (TEST_CMAKE_SDL2W_NET)
target_link_libraries(test_cmake_sdl2w PRIVATE SDL2W_net::SDL2W_net)
endif ()
target_link_libraries(test_cmake_sdl2w
PRIVATE
SDL2W::SDL2Wmain
SDL2W::SDL2W
)
# Linking options.
#
if (MSVC)
set_target_properties(test_cmake_sdl2w PROPERTIES
LINK_FLAGS "/SUBSYSTEM:CONSOLE"
)
endif ()
# Source files.
#
target_sources(test_cmake_sdl2w PRIVATE src/test_cmake_sdl2w.c)
# Install.
#
install(TARGETS test_cmake_sdl2w RUNTIME DESTINATION ".")