2021-02-27 10:01:15 +03:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2019-05-25 02:36:18 +03:00
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
2020-03-30 01:16:00 +03:00
|
|
|
cmake_minimum_required (VERSION 3.11)
|
2019-11-15 11:39:27 +03:00
|
|
|
|
2021-10-19 08:56:14 +03:00
|
|
|
set(DIRECTXTK12_VERSION 1.4.8)
|
2020-12-19 02:31:14 +03:00
|
|
|
|
|
|
|
project (DirectXTK12
|
|
|
|
VERSION ${DIRECTXTK12_VERSION}
|
|
|
|
DESCRIPTION "DirectX Tool Kit for DirectX 12"
|
|
|
|
HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkID=615561"
|
|
|
|
LANGUAGES CXX)
|
2019-05-25 02:36:18 +03:00
|
|
|
|
2019-12-14 04:54:51 +03:00
|
|
|
option(BUILD_XAUDIO_WIN10 "Build for XAudio 2.9" ON)
|
|
|
|
|
2020-06-06 01:14:35 +03:00
|
|
|
option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)
|
|
|
|
|
2021-10-07 09:14:13 +03:00
|
|
|
option(USE_PREBUILT_SHADERS "Use externally built HLSL shaders" OFF)
|
|
|
|
|
2021-06-02 23:06:53 +03:00
|
|
|
option(BUILD_DXIL_SHADERS "Use DXC Shader Model 6 for shaders" ON)
|
|
|
|
|
2021-01-05 02:00:43 +03:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-05-25 02:36:18 +03:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2020-08-11 06:14:13 +03:00
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake")
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake")
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake")
|
2019-05-25 02:36:18 +03:00
|
|
|
|
2020-12-19 02:31:14 +03:00
|
|
|
#--- Library
|
2021-01-05 02:00:43 +03:00
|
|
|
set(LIBRARY_HEADERS
|
2020-05-27 02:32:51 +03:00
|
|
|
Inc/BufferHelpers.h
|
2019-05-25 02:36:18 +03:00
|
|
|
Inc/CommonStates.h
|
|
|
|
Inc/DDSTextureLoader.h
|
|
|
|
Inc/DescriptorHeap.h
|
|
|
|
Inc/DirectXHelpers.h
|
|
|
|
Inc/Effects.h
|
|
|
|
Inc/EffectPipelineStateDescription.h
|
|
|
|
Inc/GamePad.h
|
|
|
|
Inc/GeometricPrimitive.h
|
|
|
|
Inc/GraphicsMemory.h
|
|
|
|
Inc/Keyboard.h
|
|
|
|
Inc/Model.h
|
|
|
|
Inc/Mouse.h
|
|
|
|
Inc/PostProcess.h
|
|
|
|
Inc/PrimitiveBatch.h
|
|
|
|
Inc/RenderTargetState.h
|
|
|
|
Inc/ResourceUploadBatch.h
|
|
|
|
Inc/ScreenGrab.h
|
|
|
|
Inc/SimpleMath.h
|
|
|
|
Inc/SimpleMath.inl
|
|
|
|
Inc/SpriteBatch.h
|
|
|
|
Inc/SpriteFont.h
|
|
|
|
Inc/VertexTypes.h
|
2021-01-05 02:00:43 +03:00
|
|
|
Inc/WICTextureLoader.h)
|
|
|
|
|
|
|
|
set(LIBRARY_SOURCES
|
2019-05-25 02:36:18 +03:00
|
|
|
Src/AlignedNew.h
|
|
|
|
Src/AlphaTestEffect.cpp
|
|
|
|
Src/BasicEffect.cpp
|
|
|
|
Src/BasicPostProcess.cpp
|
|
|
|
Src/Bezier.h
|
|
|
|
Src/BinaryReader.cpp
|
|
|
|
Src/BinaryReader.h
|
2020-05-27 02:32:51 +03:00
|
|
|
Src/BufferHelpers.cpp
|
2019-05-25 02:36:18 +03:00
|
|
|
Src/CommonStates.cpp
|
|
|
|
Src/d3dx12.h
|
2021-01-05 12:54:28 +03:00
|
|
|
Src/DDS.h
|
2019-05-25 02:36:18 +03:00
|
|
|
Src/DDSTextureLoader.cpp
|
|
|
|
Src/DebugEffect.cpp
|
|
|
|
Src/DemandCreate.h
|
|
|
|
Src/DescriptorHeap.cpp
|
|
|
|
Src/DirectXHelpers.cpp
|
|
|
|
Src/DualPostProcess.cpp
|
|
|
|
Src/DualTextureEffect.cpp
|
|
|
|
Src/EffectCommon.cpp
|
|
|
|
Src/EffectCommon.h
|
|
|
|
Src/EffectFactory.cpp
|
|
|
|
Src/EffectPipelineStateDescription.cpp
|
|
|
|
Src/EffectTextureFactory.cpp
|
|
|
|
Src/EnvironmentMapEffect.cpp
|
|
|
|
Src/GamePad.cpp
|
|
|
|
Src/GeometricPrimitive.cpp
|
|
|
|
Src/Geometry.h
|
|
|
|
Src/Geometry.cpp
|
|
|
|
Src/GraphicsMemory.cpp
|
|
|
|
Src/Keyboard.cpp
|
|
|
|
Src/LinearAllocator.cpp
|
|
|
|
Src/LinearAllocator.h
|
|
|
|
Src/LoaderHelpers.h
|
|
|
|
Src/Model.cpp
|
2021-09-30 23:23:15 +03:00
|
|
|
Src/ModelLoadCMO.cpp
|
2019-05-25 02:36:18 +03:00
|
|
|
Src/ModelLoadSDKMESH.cpp
|
|
|
|
Src/ModelLoadVBO.cpp
|
|
|
|
Src/Mouse.cpp
|
|
|
|
Src/NormalMapEffect.cpp
|
|
|
|
Src/PBREffect.cpp
|
|
|
|
Src/PBREffectFactory.cpp
|
|
|
|
Src/pch.h
|
|
|
|
Src/PlatformHelpers.h
|
|
|
|
Src/PrimitiveBatch.cpp
|
|
|
|
Src/ResourceUploadBatch.cpp
|
|
|
|
Src/ScreenGrab.cpp
|
|
|
|
Src/SDKMesh.h
|
|
|
|
Src/SharedResourcePool.h
|
|
|
|
Src/SimpleMath.cpp
|
|
|
|
Src/SkinnedEffect.cpp
|
|
|
|
Src/SpriteBatch.cpp
|
|
|
|
Src/SpriteFont.cpp
|
|
|
|
Src/TeapotData.inc
|
|
|
|
Src/ToneMapPostProcess.cpp
|
|
|
|
Src/vbo.h
|
|
|
|
Src/VertexTypes.cpp
|
2019-12-14 04:54:51 +03:00
|
|
|
Src/WICTextureLoader.cpp)
|
|
|
|
|
2019-12-17 22:06:32 +03:00
|
|
|
set(SHADER_SOURCES
|
|
|
|
Src/Shaders/AlphaTestEffect.fx
|
|
|
|
Src/Shaders/BasicEffect.fx
|
|
|
|
Src/Shaders/Common.fxh
|
|
|
|
Src/Shaders/DebugEffect.fx
|
|
|
|
Src/Shaders/DualTextureEffect.fx
|
|
|
|
Src/Shaders/EnvironmentMapEffect.fx
|
|
|
|
Src/Shaders/GenerateMips.hlsl
|
|
|
|
Src/Shaders/Lighting.fxh
|
|
|
|
Src/Shaders/NormalMapEffect.fx
|
|
|
|
Src/Shaders/PBRCommon.fxh
|
|
|
|
Src/Shaders/PBREffect.fx
|
|
|
|
Src/Shaders/PixelPacking_Velocity.hlsli
|
|
|
|
Src/Shaders/PostProcess.fx
|
|
|
|
Src/Shaders/RootSig.fxh
|
|
|
|
Src/Shaders/SkinnedEffect.fx
|
2021-10-11 09:48:02 +03:00
|
|
|
Src/Shaders/Skinning.fxh
|
2019-12-17 22:06:32 +03:00
|
|
|
Src/Shaders/SpriteEffect.fx
|
|
|
|
Src/Shaders/Structures.fxh
|
|
|
|
Src/Shaders/ToneMap.fx
|
|
|
|
Src/Shaders/Utilities.fxh)
|
|
|
|
|
2020-06-06 01:14:35 +03:00
|
|
|
if(BUILD_XAUDIO_WIN10)
|
2021-01-05 02:00:43 +03:00
|
|
|
set(LIBRARY_HEADERS ${LIBRARY_HEADERS}
|
|
|
|
Inc/Audio.h)
|
|
|
|
|
2019-12-14 04:54:51 +03:00
|
|
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
|
|
|
Audio/AudioEngine.cpp
|
|
|
|
Audio/DynamicSoundEffectInstance.cpp
|
|
|
|
Audio/SoundCommon.cpp
|
|
|
|
Audio/SoundCommon.h
|
|
|
|
Audio/SoundEffect.cpp
|
|
|
|
Audio/SoundEffectInstance.cpp
|
2020-04-27 06:17:50 +03:00
|
|
|
Audio/SoundStreamInstance.cpp
|
2019-12-14 04:54:51 +03:00
|
|
|
Audio/WaveBank.cpp
|
|
|
|
Audio/WaveBankReader.cpp
|
|
|
|
Audio/WaveBankReader.h
|
|
|
|
Audio/WAVFileReader.cpp
|
|
|
|
Audio/WAVFileReader.h)
|
|
|
|
endif()
|
|
|
|
|
2021-10-07 09:14:13 +03:00
|
|
|
if (NOT COMPILED_SHADERS)
|
|
|
|
if (USE_PREBUILT_SHADERS)
|
|
|
|
message(FATAL_ERROR "ERROR: Using prebuilt shaders requires the COMPILED_SHADERS variable is set")
|
|
|
|
endif()
|
|
|
|
set(COMPILED_SHADERS ${CMAKE_CURRENT_BINARY_DIR}/Shaders/Compiled)
|
|
|
|
file(MAKE_DIRECTORY ${COMPILED_SHADERS})
|
|
|
|
endif()
|
|
|
|
|
2021-01-05 02:00:43 +03:00
|
|
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
2021-10-07 09:14:13 +03:00
|
|
|
${COMPILED_SHADERS}/SpriteEffect_SpriteVertexShader.inc)
|
2020-03-29 22:51:23 +03:00
|
|
|
|
2021-06-02 23:06:53 +03:00
|
|
|
if(BUILD_DXIL_SHADERS)
|
|
|
|
message("INFO: Using Shader Model 6.0 (DXC.EXE) for shaders.")
|
|
|
|
set(ShaderOpts "dxil")
|
|
|
|
else()
|
|
|
|
message("INFO: Using Shader Model 5.1 (FXC.EXE) for shaders.")
|
|
|
|
endif()
|
|
|
|
|
2021-10-07 09:14:13 +03:00
|
|
|
if (NOT USE_PREBUILT_SHADERS)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${COMPILED_SHADERS}/SpriteEffect_SpriteVertexShader.inc"
|
|
|
|
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/Src/Shaders/CompileShaders.cmd"
|
|
|
|
DEPENDS ${SHADER_SOURCES}
|
|
|
|
COMMENT "Generating HLSL shaders..."
|
|
|
|
COMMAND set CompileShadersOutput=${COMPILED_SHADERS}
|
|
|
|
COMMAND CompileShaders.cmd ARGS ${ShaderOpts}
|
|
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/Src/Shaders"
|
|
|
|
USES_TERMINAL)
|
|
|
|
endif()
|
2019-05-25 02:36:18 +03:00
|
|
|
|
2021-01-05 02:00:43 +03:00
|
|
|
add_library(${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
|
|
|
|
|
2021-10-07 09:14:13 +03:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${COMPILED_SHADERS})
|
|
|
|
|
2021-01-05 02:00:43 +03:00
|
|
|
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
|
|
|
|
target_precompile_headers(${PROJECT_NAME} PRIVATE Src/pch.h)
|
|
|
|
endif()
|
|
|
|
|
2019-05-25 02:36:18 +03:00
|
|
|
source_group(Audio REGULAR_EXPRESSION Audio/*.*)
|
|
|
|
source_group(Inc REGULAR_EXPRESSION Inc/*.*)
|
|
|
|
source_group(Src REGULAR_EXPRESSION Src/*.*)
|
|
|
|
|
2020-12-19 02:31:14 +03:00
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Inc>
|
|
|
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
|
2019-12-14 04:54:51 +03:00
|
|
|
|
2020-06-06 01:14:35 +03:00
|
|
|
if(BUILD_XAUDIO_WIN10)
|
2021-06-02 23:06:53 +03:00
|
|
|
message("INFO: Using DirectX Tool Kit for Audio on XAudio 2.9.")
|
2020-12-19 02:31:14 +03:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE Src Audio)
|
2019-12-14 04:54:51 +03:00
|
|
|
endif()
|
2019-11-15 11:39:27 +03:00
|
|
|
|
2019-12-02 21:53:23 +03:00
|
|
|
if(MSVC)
|
2020-05-27 02:32:51 +03:00
|
|
|
# Use max Warning Level
|
2019-12-02 21:53:23 +03:00
|
|
|
string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
|
|
string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
|
|
|
string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
2019-05-25 02:36:18 +03:00
|
|
|
|
2019-12-02 21:53:23 +03:00
|
|
|
# Model uses dynamic_cast, so we need /GR (Enable RTTI)
|
2019-11-18 05:25:21 +03:00
|
|
|
|
2019-12-02 21:53:23 +03:00
|
|
|
# Library needs /EHsc (Enable C++ exceptions)
|
|
|
|
endif()
|
|
|
|
|
2021-02-04 20:55:50 +03:00
|
|
|
if (VCPKG_TOOLCHAIN)
|
2021-05-12 08:45:39 +03:00
|
|
|
message("INFO: Using VCPKG for DirectX-Headers and DirectXMath.")
|
|
|
|
find_package(directx-headers CONFIG REQUIRED)
|
2021-02-04 20:55:50 +03:00
|
|
|
find_package(directxmath CONFIG REQUIRED)
|
2021-05-12 08:45:39 +03:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectX-Headers Microsoft::DirectXMath)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS)
|
2021-02-04 20:55:50 +03:00
|
|
|
endif()
|
|
|
|
|
2020-12-19 02:31:14 +03:00
|
|
|
#--- Package
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
2020-12-29 13:51:46 +03:00
|
|
|
string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME)
|
|
|
|
|
2020-12-19 02:31:14 +03:00
|
|
|
write_basic_package_version_file(
|
2020-12-29 13:51:46 +03:00
|
|
|
${PROJECT_BINARY_DIR}/cmake/${PACKAGE_NAME}-config-version.cmake
|
2020-12-19 02:31:14 +03:00
|
|
|
VERSION ${DIRECTXTK12_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion)
|
|
|
|
|
|
|
|
install(TARGETS ${PROJECT_NAME}
|
|
|
|
EXPORT ${PROJECT_NAME}-targets
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
RUNTIME DESTINATION bin)
|
|
|
|
|
|
|
|
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/.nuget/${PROJECT_NAME}-config.cmake.in
|
2020-12-29 13:51:46 +03:00
|
|
|
${PROJECT_BINARY_DIR}/cmake/${PACKAGE_NAME}-config.cmake
|
2020-12-19 02:31:14 +03:00
|
|
|
INSTALL_DESTINATION cmake/})
|
|
|
|
|
|
|
|
install(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
FILE ${PROJECT_NAME}-targets.cmake
|
|
|
|
NAMESPACE Microsoft::
|
|
|
|
DESTINATION cmake/)
|
|
|
|
|
2021-01-05 02:00:43 +03:00
|
|
|
install(FILES ${LIBRARY_HEADERS}
|
|
|
|
DESTINATION include/${PROJECT_NAME})
|
2020-12-19 02:31:14 +03:00
|
|
|
|
2021-01-05 02:00:43 +03:00
|
|
|
install(FILES
|
2020-12-29 13:51:46 +03:00
|
|
|
${PROJECT_BINARY_DIR}/cmake/${PACKAGE_NAME}-config.cmake
|
|
|
|
${PROJECT_BINARY_DIR}/cmake/${PACKAGE_NAME}-config-version.cmake
|
2020-12-19 02:31:14 +03:00
|
|
|
DESTINATION cmake/)
|
|
|
|
|
2019-12-02 21:53:23 +03:00
|
|
|
if(MSVC)
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast)
|
2019-11-15 11:39:27 +03:00
|
|
|
|
2021-01-14 11:12:09 +03:00
|
|
|
if (${CMAKE_SIZEOF_VOID_P} EQUAL "4" AND (NOT ${CMAKE_VS_PLATFORM_NAME} MATCHES "arm"))
|
2019-12-02 21:53:23 +03:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE /arch:SSE2)
|
|
|
|
endif()
|
2019-11-15 11:39:27 +03:00
|
|
|
endif()
|
2019-05-25 02:36:18 +03:00
|
|
|
|
2021-01-05 02:00:43 +03:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2019-11-15 11:39:27 +03:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE -Wpedantic -Wextra)
|
2019-05-25 02:36:18 +03:00
|
|
|
endif()
|
2021-01-05 02:00:43 +03:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
2019-11-15 11:39:27 +03:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE /permissive- /JMC- /Zc:__cplusplus)
|
2020-05-20 06:16:23 +03:00
|
|
|
|
2020-06-06 01:14:35 +03:00
|
|
|
if(ENABLE_CODE_ANALYSIS)
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE /analyze)
|
|
|
|
endif()
|
|
|
|
|
2020-05-20 06:16:23 +03:00
|
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
|
2020-05-21 05:53:46 +03:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE /Zc:preprocessor /wd5104 /wd5105)
|
2020-05-20 06:16:23 +03:00
|
|
|
endif()
|
2019-05-25 02:36:18 +03:00
|
|
|
endif()
|
|
|
|
|
2019-12-12 03:27:40 +03:00
|
|
|
if(WIN32)
|
|
|
|
# Windows 10 is used here
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE _UNICODE UNICODE _WIN32_WINNT=0x0A00)
|
|
|
|
endif()
|
2020-08-11 06:14:13 +03:00
|
|
|
|
|
|
|
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
|