Skip to content

Commit

Permalink
Add SDL2 cubescape example
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibel committed Feb 25, 2024
1 parent 9d32c2e commit c59e2ab
Show file tree
Hide file tree
Showing 12 changed files with 1,058 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ add_subdirectory("cubescape-gles")
add_subdirectory("cubescape-log")
add_subdirectory("cubescape-wgl")
add_subdirectory("cubescape-qt")
add_subdirectory("cubescape-sdl")
149 changes: 149 additions & 0 deletions source/examples/cubescape-sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@

#
# External dependencies
#

find_package(SDL2 QUIET)
find_package(cpplocate QUIET)


#
# Executable name and options
#

# Target name
set(target cubescape-sdl)

# Exit here if required dependencies are not met
if (NOT SDL2_FOUND)
message("Example ${target} skipped: SDL2 not found")
return()
endif()

if (NOT cpplocate_FOUND)
message(STATUS "Example ${target}: using static data path (cpplocate not found)")
else()
message(STATUS "Example ${target}")
endif()


#
# Sources
#

set(sources
main.cpp
CubeScape.cpp
CubeScape.h
glutils.cpp
glutils.h
RawFile.cpp
RawFile.h
)


#
# Create executable
#

# Build executable
add_executable(${target}
MACOSX_BUNDLE
${sources}
)

# Create namespaced alias
add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target})


#
# Project options
#

set_target_properties(${target}
PROPERTIES
${DEFAULT_PROJECT_OPTIONS}
INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
FOLDER "${IDE_FOLDER}"
)


#
# Include directories
#

target_include_directories(${target}
PRIVATE
${DEFAULT_INCLUDE_DIRECTORIES}
${PROJECT_BINARY_DIR}/source/include
SYSTEM
)


#
# Libraries
#

target_link_libraries(${target}
PRIVATE
${DEFAULT_LIBRARIES}
SDL2::SDL2
SDL2::SDL2main
${META_PROJECT_NAME}::glbinding
${META_PROJECT_NAME}::glbinding-aux
$<$<BOOL:${cpplocate_FOUND}>:cpplocate::cpplocate>
)


#
# Compile definitions
#

target_compile_definitions(${target}
PRIVATE
${DEFAULT_COMPILE_DEFINITIONS}
$<$<BOOL:${cpplocate_FOUND}>:cpplocate_FOUND>
)


#
# Compile options
#

target_compile_options(${target}
PRIVATE
${DEFAULT_COMPILE_OPTIONS_PRIVATE}
PUBLIC
${DEFAULT_COMPILE_OPTIONS_PUBLIC}
)


#
# Linker options
#

target_link_libraries(${target}
PRIVATE
${DEFAULT_LINKER_OPTIONS}
)


#
# Target Health
#

perform_health_checks(
${target}
${sources}
)


#
# Deployment
#

# Executable
install(TARGETS ${target}
RUNTIME DESTINATION ${INSTALL_EXAMPLES} COMPONENT examples_sdl
BUNDLE DESTINATION ${INSTALL_EXAMPLES} COMPONENT examples_sdl
)
Loading

0 comments on commit c59e2ab

Please sign in to comment.