cigui/examples/CMakeLists.txt
2025-04-13 20:24:19 +02:00

48 lines
No EOL
1.6 KiB
CMake

# Examples CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
# Function to easily add examples
function(add_cigui_example NAME)
find_files(EXAMPLE_${NAME}_SOURCES "${NAME}/src" cpp c cxx hpp h hxx inl)
add_executable(EXAMPLE_${NAME} ${EXAMPLE_${NAME}_SOURCES})
target_link_libraries(EXAMPLE_${NAME} PRIVATE cigui)
link_libraries_in_directory(EXAMPLE_${NAME} ${LLGL_LIB_PATH})
target_include_directories(EXAMPLE_${NAME} PRIVATE ${LLGL_INCLUDE_PATH})
set_target_properties(EXAMPLE_${NAME} PROPERTIES OUTPUT_NAME "${NAME}")
if (WIN32)
add_custom_command(TARGET EXAMPLE_${NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${LLGL_BIN_PATH}
$<TARGET_FILE_DIR:EXAMPLE_${NAME}>
COMMENT "Coppied LLGL binaries to example directory"
)
else()
add_custom_command(TARGET EXAMPLE_${NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${LLGL_LIB_PATH}
$<TARGET_FILE_DIR:EXAMPLE_${NAME}>
COMMENT "Coppied LLGL binaries to example directory"
)
endif()
add_custom_command(TARGET EXAMPLE_${NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/${NAME}/src/shader
$<TARGET_FILE_DIR:EXAMPLE_${NAME}>/shader
COMMENT "Coppied shaders to example directory"
)
# Copy DLLs to output directory on Windows when building shared
if(WIN32 AND CIGUI_BUILD_SHARED)
add_custom_command(TARGET EXAMPLE_${NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:cigui>
$<TARGET_FILE_DIR:EXAMPLE_${NAME}>
)
endif()
endfunction()
# Basic example
add_subdirectory(Full)