glerminal/examples/CMakeLists.txt
2024-05-19 21:46:56 -05:00

38 lines
994 B
CMake

cmake_minimum_required(VERSION 3.28)
set(CMAKE_FOLDER examples)
file(GLOB_RECURSE
EXAMPLE_RESOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/resources/**.png
)
foreach(RESOURCE_FILE ${EXAMPLE_RESOURCES})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_FILE}
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_FILE}
${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_FILE}
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_FILE}
)
endforeach()
file(GLOB_RECURSE
EXAMPLE_SOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
)
list(TRANSFORM EXAMPLE_RESOURCES PREPEND ${CMAKE_CURRENT_BINARY_DIR}/)
foreach(SOURCE_FILE ${EXAMPLE_SOURCES})
get_filename_component(SOURCE_FILENAME ${SOURCE_FILE} NAME_WLE)
add_executable(${SOURCE_FILENAME} WIN32 ${SOURCE_FILE} ${EXAMPLE_RESOURCES})
target_link_libraries(${SOURCE_FILENAME} PRIVATE glerminal)
endforeach()