Skip to content

Commit c59e2ab

Browse files
committed
Add SDL2 cubescape example
1 parent 9d32c2e commit c59e2ab

File tree

12 files changed

+1058
-0
lines changed

12 files changed

+1058
-0
lines changed

source/examples/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ add_subdirectory("cubescape-gles")
1111
add_subdirectory("cubescape-log")
1212
add_subdirectory("cubescape-wgl")
1313
add_subdirectory("cubescape-qt")
14+
add_subdirectory("cubescape-sdl")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
2+
#
3+
# External dependencies
4+
#
5+
6+
find_package(SDL2 QUIET)
7+
find_package(cpplocate QUIET)
8+
9+
10+
#
11+
# Executable name and options
12+
#
13+
14+
# Target name
15+
set(target cubescape-sdl)
16+
17+
# Exit here if required dependencies are not met
18+
if (NOT SDL2_FOUND)
19+
message("Example ${target} skipped: SDL2 not found")
20+
return()
21+
endif()
22+
23+
if (NOT cpplocate_FOUND)
24+
message(STATUS "Example ${target}: using static data path (cpplocate not found)")
25+
else()
26+
message(STATUS "Example ${target}")
27+
endif()
28+
29+
30+
#
31+
# Sources
32+
#
33+
34+
set(sources
35+
main.cpp
36+
CubeScape.cpp
37+
CubeScape.h
38+
glutils.cpp
39+
glutils.h
40+
RawFile.cpp
41+
RawFile.h
42+
)
43+
44+
45+
#
46+
# Create executable
47+
#
48+
49+
# Build executable
50+
add_executable(${target}
51+
MACOSX_BUNDLE
52+
${sources}
53+
)
54+
55+
# Create namespaced alias
56+
add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target})
57+
58+
59+
#
60+
# Project options
61+
#
62+
63+
set_target_properties(${target}
64+
PROPERTIES
65+
${DEFAULT_PROJECT_OPTIONS}
66+
INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
67+
FOLDER "${IDE_FOLDER}"
68+
)
69+
70+
71+
#
72+
# Include directories
73+
#
74+
75+
target_include_directories(${target}
76+
PRIVATE
77+
${DEFAULT_INCLUDE_DIRECTORIES}
78+
${PROJECT_BINARY_DIR}/source/include
79+
SYSTEM
80+
)
81+
82+
83+
#
84+
# Libraries
85+
#
86+
87+
target_link_libraries(${target}
88+
PRIVATE
89+
${DEFAULT_LIBRARIES}
90+
SDL2::SDL2
91+
SDL2::SDL2main
92+
${META_PROJECT_NAME}::glbinding
93+
${META_PROJECT_NAME}::glbinding-aux
94+
$<$<BOOL:${cpplocate_FOUND}>:cpplocate::cpplocate>
95+
)
96+
97+
98+
#
99+
# Compile definitions
100+
#
101+
102+
target_compile_definitions(${target}
103+
PRIVATE
104+
${DEFAULT_COMPILE_DEFINITIONS}
105+
$<$<BOOL:${cpplocate_FOUND}>:cpplocate_FOUND>
106+
)
107+
108+
109+
#
110+
# Compile options
111+
#
112+
113+
target_compile_options(${target}
114+
PRIVATE
115+
${DEFAULT_COMPILE_OPTIONS_PRIVATE}
116+
PUBLIC
117+
${DEFAULT_COMPILE_OPTIONS_PUBLIC}
118+
)
119+
120+
121+
#
122+
# Linker options
123+
#
124+
125+
target_link_libraries(${target}
126+
PRIVATE
127+
${DEFAULT_LINKER_OPTIONS}
128+
)
129+
130+
131+
#
132+
# Target Health
133+
#
134+
135+
perform_health_checks(
136+
${target}
137+
${sources}
138+
)
139+
140+
141+
#
142+
# Deployment
143+
#
144+
145+
# Executable
146+
install(TARGETS ${target}
147+
RUNTIME DESTINATION ${INSTALL_EXAMPLES} COMPONENT examples_sdl
148+
BUNDLE DESTINATION ${INSTALL_EXAMPLES} COMPONENT examples_sdl
149+
)

0 commit comments

Comments
 (0)