1 Star 0 Fork 0

褚旭 / DiligentSamples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CMakeLists.txt 4.04 KB
一键复制 编辑 原始数据 按行查看 历史
if(PLATFORM_WIN32 OR PLATFORM_LINUX)
cmake_minimum_required (VERSION 3.13)
option(DILIGENT_INSTALL_SAMPLES "Enable installation of samples and tutorials" ON)
else()
cmake_minimum_required (VERSION 3.6)
set(DILIGENT_INSTALL_SAMPLES OFF)
endif()
option(DILIGENT_BUILD_SAMPLE_BASE_ONLY "Build only SampleBase project" OFF)
function(add_sample_app APP_NAME IDE_FOLDER SOURCE INCLUDE SHADERS ASSETS)
set_source_files_properties(${SHADERS} PROPERTIES VS_TOOL_OVERRIDE "None")
set(ALL_ASSETS ${ASSETS} ${SHADERS})
add_target_platform_app(${APP_NAME} "${SOURCE}" "${INCLUDE}" "${ALL_ASSETS}")
set_source_files_properties(${ALL_ASSETS} PROPERTIES
VS_DEPLOYMENT_LOCATION "."
MACOSX_PACKAGE_LOCATION "Resources"
)
if(PLATFORM_WIN32)
set_target_properties(${APP_NAME} PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets"
)
copy_required_dlls(${APP_NAME})
append_sample_base_win32_source(${APP_NAME})
elseif(PLATFORM_UNIVERSAL_WINDOWS)
append_sample_base_uwp_source(${APP_NAME})
endif()
target_include_directories(${APP_NAME}
PRIVATE
src
)
target_link_libraries(${APP_NAME}
PRIVATE
# On Linux we must have Diligent-NativeAppBase go first, otherwise the linker
# will fail to resolve Diligent::CreateApplication() function.
Diligent-NativeAppBase
Diligent-BuildSettings
Diligent-SampleBase
)
set_common_target_properties(${APP_NAME})
if(MSVC)
# Disable MSVC-specific warnings
# - w4201: nonstandard extension used: nameless struct/union
target_compile_options(${APP_NAME} PRIVATE /wd4201)
endif()
set_target_properties(${APP_NAME} PROPERTIES
FOLDER ${IDE_FOLDER}
)
source_group("src" FILES ${SOURCE} ${INCLUDE})
source_group("assets" FILES ${ALL_ASSETS})
target_sources(${APP_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/readme.md")
set_source_files_properties(
"${CMAKE_CURRENT_SOURCE_DIR}/readme.md" PROPERTIES HEADER_FILE_ONLY TRUE
)
if(PLATFORM_WIN32 OR PLATFORM_LINUX)
# Copy assets to target folder
add_custom_command(TARGET ${APP_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/assets"
"\"$<TARGET_FILE_DIR:${APP_NAME}>\"")
endif()
if(DILIGENT_INSTALL_SAMPLES)
# Install instructions
file(RELATIVE_PATH TUTORIAL_REL_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
install(TARGETS ${APP_NAME}
DESTINATION "${CMAKE_INSTALL_BINDIR}/${TUTORIAL_REL_PATH}/$<CONFIG>")
if(PLATFORM_LINUX OR PLATFORM_WIN32)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets/"
DESTINATION "${CMAKE_INSTALL_BINDIR}/${TUTORIAL_REL_PATH}/$<CONFIG>")
endif()
if(PLATFORM_WIN32)
get_supported_backends(BACKEND_LIBRARIES)
install(TARGETS ${BACKEND_LIBRARIES}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${TUTORIAL_REL_PATH}/$<CONFIG>"
LIBRARY DESTINATION "${CMAKE_INSTALL_BINDIR}/${TUTORIAL_REL_PATH}/$<CONFIG>"
ARCHIVE DESTINATION "${CMAKE_INSTALL_BINDIR}/${TUTORIAL_REL_PATH}/$<CONFIG>")
endif()
if(PLATFORM_LINUX)
set_target_properties(${APP_NAME} PROPERTIES
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${DILIGENT_CORE_DIR}/${CMAKE_BUILD_TYPE}"
)
endif()
endif()
endfunction()
add_subdirectory(ThirdParty)
if(TARGET Diligent-NativeAppBase AND TARGET Diligent-TextureLoader AND TARGET Diligent-Imgui)
add_subdirectory(SampleBase)
endif()
if(NOT ${DILIGENT_BUILD_SAMPLE_BASE_ONLY} AND TARGET Diligent-SampleBase)
add_subdirectory(Samples)
add_subdirectory(Tutorials)
endif()
# Create a custom target to run source code formatting validation command
add_format_validation_target(DiligentSamples "${CMAKE_CURRENT_SOURCE_DIR}" DiligentSamples)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chuxu1793/DiligentSamples.git
git@gitee.com:chuxu1793/DiligentSamples.git
chuxu1793
DiligentSamples
DiligentSamples
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891