2021-02-27 10:00:12 +03:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2019-05-25 00:26:52 +03:00
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
2022-11-15 23:21:20 +03:00
|
|
|
cmake_minimum_required (VERSION 3.20)
|
2019-11-15 11:39:38 +03:00
|
|
|
|
2022-07-30 05:08:28 +03:00
|
|
|
set(DIRECTXTK_VERSION 1.8.2)
|
2019-05-25 00:26:52 +03:00
|
|
|
|
2020-12-19 02:29:45 +03:00
|
|
|
project (DirectXTK
|
|
|
|
VERSION ${DIRECTXTK_VERSION}
|
|
|
|
DESCRIPTION "DirectX Tool Kit for DirectX 11"
|
|
|
|
HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkId=248929"
|
|
|
|
LANGUAGES CXX)
|
|
|
|
|
2020-12-19 04:41:46 +03:00
|
|
|
option(BUILD_TOOLS "Build XWBTool" ON)
|
|
|
|
|
2019-12-14 04:49:12 +03:00
|
|
|
option(BUILD_XAUDIO_WIN10 "Build for XAudio 2.9" OFF)
|
|
|
|
option(BUILD_XAUDIO_WIN8 "Build for XAudio 2.8" ON)
|
2021-06-01 03:25:03 +03:00
|
|
|
option(BUILD_XAUDIO_WIN7 "Build for XAudio2Redist" OFF)
|
2019-12-14 04:49:12 +03:00
|
|
|
|
2020-06-06 01:11:42 +03:00
|
|
|
option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)
|
|
|
|
|
2021-10-07 09:13:47 +03:00
|
|
|
option(USE_PREBUILT_SHADERS "Use externally built HLSL shaders" OFF)
|
|
|
|
|
2021-01-05 01:53:18 +03:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-05-25 00:26:52 +03:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2020-08-11 06:13:24 +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 00:26:52 +03:00
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if(DEFINED VCPKG_TARGET_ARCHITECTURE)
|
2022-03-19 11:10:49 +03:00
|
|
|
set(DIRECTX_ARCH ${VCPKG_TARGET_ARCHITECTURE})
|
2022-03-24 02:57:17 +03:00
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
|
|
|
|
set(DIRECTX_ARCH x86)
|
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$")
|
|
|
|
set(DIRECTX_ARCH x64)
|
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$")
|
|
|
|
set(DIRECTX_ARCH arm)
|
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$")
|
|
|
|
set(DIRECTX_ARCH arm64)
|
2022-03-19 11:10:49 +03:00
|
|
|
endif()
|
|
|
|
|
2022-05-02 13:01:55 +03:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2020-12-19 02:29:45 +03:00
|
|
|
#--- Library
|
2021-01-05 01:53:18 +03:00
|
|
|
set(LIBRARY_HEADERS
|
2020-05-27 02:20:42 +03:00
|
|
|
Inc/BufferHelpers.h
|
2019-05-25 00:26:52 +03:00
|
|
|
Inc/CommonStates.h
|
|
|
|
Inc/DDSTextureLoader.h
|
|
|
|
Inc/DirectXHelpers.h
|
|
|
|
Inc/Effects.h
|
|
|
|
Inc/GeometricPrimitive.h
|
|
|
|
Inc/GraphicsMemory.h
|
|
|
|
Inc/Model.h
|
|
|
|
Inc/PostProcess.h
|
|
|
|
Inc/PrimitiveBatch.h
|
|
|
|
Inc/ScreenGrab.h
|
|
|
|
Inc/SpriteBatch.h
|
|
|
|
Inc/SpriteFont.h
|
|
|
|
Inc/VertexTypes.h
|
2021-01-05 01:53:18 +03:00
|
|
|
Inc/WICTextureLoader.h)
|
|
|
|
|
|
|
|
set(LIBRARY_SOURCES
|
2019-05-25 00:26:52 +03:00
|
|
|
Src/AlphaTestEffect.cpp
|
|
|
|
Src/BasicEffect.cpp
|
|
|
|
Src/BasicPostProcess.cpp
|
2020-05-27 02:20:42 +03:00
|
|
|
Src/BufferHelpers.cpp
|
2019-05-25 00:26:52 +03:00
|
|
|
Src/CommonStates.cpp
|
|
|
|
Src/DDSTextureLoader.cpp
|
|
|
|
Src/DebugEffect.cpp
|
|
|
|
Src/DGSLEffect.cpp
|
|
|
|
Src/DGSLEffectFactory.cpp
|
2020-05-27 02:20:42 +03:00
|
|
|
Src/DirectXHelpers.cpp
|
2019-05-25 00:26:52 +03:00
|
|
|
Src/DualPostProcess.cpp
|
|
|
|
Src/DualTextureEffect.cpp
|
|
|
|
Src/EffectCommon.cpp
|
|
|
|
Src/EffectCommon.h
|
|
|
|
Src/EffectFactory.cpp
|
|
|
|
Src/EnvironmentMapEffect.cpp
|
|
|
|
Src/GeometricPrimitive.cpp
|
|
|
|
Src/GraphicsMemory.cpp
|
|
|
|
Src/Model.cpp
|
|
|
|
Src/ModelLoadCMO.cpp
|
|
|
|
Src/ModelLoadSDKMESH.cpp
|
|
|
|
Src/ModelLoadVBO.cpp
|
|
|
|
Src/NormalMapEffect.cpp
|
|
|
|
Src/PBREffect.cpp
|
|
|
|
Src/PBREffectFactory.cpp
|
|
|
|
Src/pch.h
|
|
|
|
Src/PrimitiveBatch.cpp
|
|
|
|
Src/ScreenGrab.cpp
|
|
|
|
Src/SkinnedEffect.cpp
|
|
|
|
Src/SpriteBatch.cpp
|
|
|
|
Src/SpriteFont.cpp
|
|
|
|
Src/ToneMapPostProcess.cpp
|
|
|
|
Src/VertexTypes.cpp
|
2019-12-14 04:49:12 +03:00
|
|
|
Src/WICTextureLoader.cpp)
|
|
|
|
|
2019-12-17 22:14:09 +03:00
|
|
|
set(SHADER_SOURCES
|
|
|
|
Src/Shaders/AlphaTestEffect.fx
|
|
|
|
Src/Shaders/BasicEffect.fx
|
|
|
|
Src/Shaders/DebugEffect.fx
|
|
|
|
Src/Shaders/DGSLEffect.fx
|
|
|
|
Src/Shaders/DGSLLambert.hlsl
|
|
|
|
Src/Shaders/DGSLPhong.hlsl
|
|
|
|
Src/Shaders/DGSLUnlit.hlsl
|
|
|
|
Src/Shaders/DualTextureEffect.fx
|
|
|
|
Src/Shaders/EnvironmentMapEffect.fx
|
|
|
|
Src/Shaders/NormalMapEffect.fx
|
|
|
|
Src/Shaders/PBREffect.fx
|
|
|
|
Src/Shaders/PostProcess.fx
|
|
|
|
Src/Shaders/SkinnedEffect.fx
|
|
|
|
Src/Shaders/SpriteEffect.fx
|
2022-08-30 01:50:05 +03:00
|
|
|
Src/Shaders/ToneMap.fx)
|
|
|
|
|
|
|
|
# These source files are identical in both DX11 and DX12 version.
|
|
|
|
set(LIBRARY_HEADERS ${LIBRARY_HEADERS}
|
|
|
|
Inc/GamePad.h
|
|
|
|
Inc/Keyboard.h
|
|
|
|
Inc/Mouse.h
|
|
|
|
Inc/SimpleMath.h
|
|
|
|
Inc/SimpleMath.inl)
|
|
|
|
|
|
|
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
|
|
|
Src/AlignedNew.h
|
|
|
|
Src/Bezier.h
|
|
|
|
Src/BinaryReader.h
|
|
|
|
Src/DDS.h
|
|
|
|
Src/DemandCreate.h
|
|
|
|
Src/Geometry.h
|
|
|
|
Src/LoaderHelpers.h
|
|
|
|
Src/PlatformHelpers.h
|
|
|
|
Src/SDKMesh.h
|
|
|
|
Src/SharedResourcePool.h
|
|
|
|
Src/vbo.h
|
|
|
|
Src/TeapotData.inc
|
|
|
|
Src/BinaryReader.cpp
|
|
|
|
Src/GamePad.cpp
|
|
|
|
Src/Geometry.cpp
|
|
|
|
Src/Keyboard.cpp
|
|
|
|
Src/Mouse.cpp
|
|
|
|
Src/SimpleMath.cpp)
|
|
|
|
|
|
|
|
set(SHADER_SOURCES ${SHADER_SOURCES}
|
|
|
|
Src/Shaders/Common.fxh
|
|
|
|
Src/Shaders/Lighting.fxh
|
|
|
|
Src/Shaders/PBRCommon.fxh
|
|
|
|
Src/Shaders/PixelPacking_Velocity.hlsli
|
|
|
|
Src/Shaders/Skinning.fxh
|
2019-12-17 22:14:09 +03:00
|
|
|
Src/Shaders/Structures.fxh
|
|
|
|
Src/Shaders/Utilities.fxh)
|
|
|
|
|
2022-05-06 00:20:57 +03:00
|
|
|
if(MINGW)
|
|
|
|
set(BUILD_XAUDIO_WIN10 OFF)
|
|
|
|
set(BUILD_XAUDIO_WIN8 OFF)
|
|
|
|
endif()
|
|
|
|
|
2022-04-12 23:44:50 +03:00
|
|
|
if(WINDOWS_STORE OR BUILD_XAUDIO_WIN10 OR BUILD_XAUDIO_WIN8 OR BUILD_XAUDIO_WIN7)
|
2021-01-05 01:53:18 +03:00
|
|
|
set(LIBRARY_HEADERS ${LIBRARY_HEADERS}
|
|
|
|
Inc/Audio.h)
|
|
|
|
|
2019-12-14 04:49:12 +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-26 11:55:29 +03:00
|
|
|
Audio/SoundStreamInstance.cpp
|
2019-12-14 04:49:12 +03:00
|
|
|
Audio/WaveBank.cpp
|
|
|
|
Audio/WaveBankReader.cpp
|
|
|
|
Audio/WaveBankReader.h
|
|
|
|
Audio/WAVFileReader.cpp
|
|
|
|
Audio/WAVFileReader.h)
|
|
|
|
endif()
|
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if(NOT COMPILED_SHADERS)
|
|
|
|
if(USE_PREBUILT_SHADERS)
|
2021-10-07 09:13:47 +03:00
|
|
|
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})
|
2022-05-06 10:29:12 +03:00
|
|
|
else()
|
|
|
|
file(TO_CMAKE_PATH ${COMPILED_SHADERS} COMPILED_SHADERS)
|
2021-10-07 09:13:47 +03:00
|
|
|
endif()
|
2020-03-29 22:42:24 +03:00
|
|
|
|
2021-10-07 09:13:47 +03:00
|
|
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
|
|
|
${COMPILED_SHADERS}/SpriteEffect_SpriteVertexShader.inc)
|
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if(NOT USE_PREBUILT_SHADERS)
|
2021-10-07 09:13:47 +03:00
|
|
|
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..."
|
2022-05-07 00:03:16 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" CompileShaders.cmd > "${COMPILED_SHADERS}/compileshaders.log"
|
2021-10-07 09:13:47 +03:00
|
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/Src/Shaders"
|
|
|
|
USES_TERMINAL)
|
|
|
|
endif()
|
2019-05-25 00:26:52 +03:00
|
|
|
|
2021-01-05 01:53:18 +03:00
|
|
|
add_library(${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
|
|
|
|
|
2022-05-10 10:34:23 +03:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${COMPILED_SHADERS} Src)
|
2021-10-07 09:13:47 +03:00
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if(NOT MINGW)
|
2021-01-05 01:53:18 +03:00
|
|
|
target_precompile_headers(${PROJECT_NAME} PRIVATE Src/pch.h)
|
|
|
|
endif()
|
|
|
|
|
2019-11-15 11:39:38 +03:00
|
|
|
source_group(Audio REGULAR_EXPRESSION Audio/*.*)
|
|
|
|
source_group(Inc REGULAR_EXPRESSION Inc/*.*)
|
|
|
|
source_group(Src REGULAR_EXPRESSION Src/*.*)
|
|
|
|
|
2020-12-19 02:29:45 +03:00
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Inc>
|
2022-06-03 10:38:54 +03:00
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/directxtk>)
|
2019-12-14 04:49:12 +03:00
|
|
|
|
2022-05-28 03:17:51 +03:00
|
|
|
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
|
|
|
|
|
2022-04-12 23:44:50 +03:00
|
|
|
if(WINDOWS_STORE OR BUILD_XAUDIO_WIN10 OR BUILD_XAUDIO_WIN8 OR BUILD_XAUDIO_WIN7)
|
2022-05-10 10:34:23 +03:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE Audio)
|
2019-12-14 04:49:12 +03:00
|
|
|
endif()
|
2019-11-15 11:39:38 +03:00
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if(MINGW OR VCPKG_TOOLCHAIN)
|
2021-02-04 20:49:45 +03:00
|
|
|
message("INFO: Using VCPKG for DirectXMath.")
|
|
|
|
find_package(directxmath CONFIG REQUIRED)
|
2022-11-27 05:22:47 +03:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectXMath)
|
2021-06-01 03:25:03 +03:00
|
|
|
endif()
|
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if(BUILD_XAUDIO_WIN7 AND (NOT BUILD_XAUDIO_WIN10) AND (NOT BUILD_XAUDIO_WIN8) AND (NOT WINDOWS_STORE))
|
2021-06-01 03:25:03 +03:00
|
|
|
message("INFO: Using XAudio2Redist for DirectX Tool Kit for Audio on Windows 7.")
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_XAUDIO2_REDIST)
|
2021-10-16 11:55:02 +03:00
|
|
|
|
|
|
|
find_package(xaudio2redist CONFIG REQUIRED)
|
2022-11-27 05:22:47 +03:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::XAudio2Redist)
|
2021-02-04 20:49:45 +03:00
|
|
|
endif()
|
|
|
|
|
2020-12-19 02:29:45 +03:00
|
|
|
#--- Package
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
2020-12-29 13:50:38 +03:00
|
|
|
string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME)
|
|
|
|
|
2020-12-19 02:29:45 +03:00
|
|
|
write_basic_package_version_file(
|
2022-05-02 13:01:55 +03:00
|
|
|
${PACKAGE_NAME}-config-version.cmake
|
2020-12-19 02:29:45 +03:00
|
|
|
VERSION ${DIRECTXTK_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion)
|
|
|
|
|
|
|
|
install(TARGETS ${PROJECT_NAME}
|
|
|
|
EXPORT ${PROJECT_NAME}-targets
|
2022-05-02 13:01:55 +03:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2020-12-19 02:29:45 +03:00
|
|
|
|
2022-12-04 04:49:52 +03:00
|
|
|
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/build/${PROJECT_NAME}-config.cmake.in
|
2022-05-02 13:01:55 +03:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
|
2022-06-03 10:38:54 +03:00
|
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
|
2020-12-19 02:29:45 +03:00
|
|
|
|
|
|
|
install(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
FILE ${PROJECT_NAME}-targets.cmake
|
|
|
|
NAMESPACE Microsoft::
|
2022-06-03 10:38:54 +03:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
|
2020-12-19 02:29:45 +03:00
|
|
|
|
2021-01-05 01:53:18 +03:00
|
|
|
install(FILES ${LIBRARY_HEADERS}
|
2022-06-03 10:38:54 +03:00
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/directxtk)
|
2020-12-19 02:29:45 +03:00
|
|
|
|
2021-01-05 01:53:18 +03:00
|
|
|
install(FILES
|
2022-05-02 13:01:55 +03:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake
|
2022-06-03 10:38:54 +03:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
|
2020-12-19 02:29:45 +03:00
|
|
|
|
|
|
|
#--- Command-line tools
|
2021-01-14 10:59:04 +03:00
|
|
|
if(BUILD_TOOLS AND (NOT WINDOWS_STORE))
|
2022-05-04 11:09:25 +03:00
|
|
|
set(TOOL_EXES xwbtool)
|
|
|
|
|
2020-12-19 04:41:46 +03:00
|
|
|
add_executable(xwbtool
|
2019-07-25 09:19:53 +03:00
|
|
|
xwbtool/xwbtool.cpp
|
2022-08-31 04:23:19 +03:00
|
|
|
xwbtool/xwbtool.rc
|
2019-07-25 09:19:53 +03:00
|
|
|
Audio/WAVFileReader.cpp
|
|
|
|
Audio/WAVFileReader.h)
|
2020-12-19 04:41:46 +03:00
|
|
|
target_include_directories(xwbtool PRIVATE Audio Src)
|
2022-11-27 05:22:47 +03:00
|
|
|
target_link_libraries(xwbtool PRIVATE version.lib)
|
2020-12-19 04:41:46 +03:00
|
|
|
source_group(xwbtool REGULAR_EXPRESSION XWBTool/*.*)
|
2022-05-04 11:09:25 +03:00
|
|
|
endif()
|
2021-02-04 20:49:45 +03:00
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if(MINGW OR VCPKG_TOOLCHAIN)
|
2022-11-27 05:22:47 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_link_libraries(${t} PUBLIC Microsoft::DirectXMath)
|
2022-05-04 11:09:25 +03:00
|
|
|
endforeach()
|
2020-12-19 04:41:46 +03:00
|
|
|
endif()
|
2019-07-25 09:19:53 +03:00
|
|
|
|
2022-11-15 23:21:20 +03:00
|
|
|
# Model uses dynamic_cast, so we need /GR (Enable RTTI)
|
2019-12-02 21:53:08 +03:00
|
|
|
if(MSVC)
|
2022-05-04 11:09:25 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2022-11-15 23:21:20 +03:00
|
|
|
target_compile_options(${t} PRIVATE /Wall /GR /fp:fast "$<$<NOT:$<CONFIG:DEBUG>>:/guard:cf>")
|
2022-05-04 11:09:25 +03:00
|
|
|
target_link_options(${t} PRIVATE /DYNAMICBASE /NXCOMPAT)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "^arm"))
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_link_options(${t} PRIVATE /SAFESEH)
|
|
|
|
endforeach()
|
2019-12-02 21:53:08 +03:00
|
|
|
endif()
|
2022-07-26 01:37:14 +03:00
|
|
|
|
2022-07-26 09:55:46 +03:00
|
|
|
if((MSVC_VERSION GREATER_EQUAL 1928) AND (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
AND ((NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)))
|
2022-07-26 01:37:14 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE "$<$<NOT:$<CONFIG:DEBUG>>:/guard:ehcont>")
|
|
|
|
target_link_options(${t} PRIVATE "$<$<NOT:$<CONFIG:DEBUG>>:/guard:ehcont>")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2022-12-03 09:31:43 +03:00
|
|
|
else()
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_definitions(${t} PRIVATE $<IF:$<CONFIG:DEBUG>,_DEBUG,NDEBUG>)
|
|
|
|
endforeach()
|
2019-11-15 11:39:38 +03:00
|
|
|
endif()
|
2019-05-25 02:35:36 +03:00
|
|
|
|
2022-05-06 00:20:57 +03:00
|
|
|
if(NOT ${DIRECTX_ARCH} MATCHES "^arm")
|
2022-12-03 09:31:43 +03:00
|
|
|
if(${CMAKE_SIZEOF_VOID_P} EQUAL "4")
|
2022-05-06 00:20:57 +03:00
|
|
|
set(ARCH_SSE2 $<$<CXX_COMPILER_ID:MSVC>:/arch:SSE2> $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse2>)
|
|
|
|
else()
|
|
|
|
set(ARCH_SSE2 $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse2>)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE ${ARCH_SSE2})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
2019-11-15 11:39:38 +03:00
|
|
|
set(WarningsLib "-Wpedantic" "-Wextra")
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
|
|
|
|
|
2022-05-04 11:09:25 +03:00
|
|
|
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic"
|
2019-11-15 11:39:38 +03:00
|
|
|
"-Wno-double-promotion" "-Wno-exit-time-destructors" "-Wno-gnu-anonymous-struct"
|
|
|
|
"-Wno-missing-prototypes" "-Wno-nested-anon-types" "-Wno-unused-const-variable")
|
2022-05-04 11:09:25 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_compile_options(${t} PRIVATE ${WarningsEXE})
|
|
|
|
endforeach()
|
2022-11-27 23:24:29 +03:00
|
|
|
elseif(MINGW)
|
2022-05-06 00:20:57 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE -Wno-ignored-attributes)
|
|
|
|
target_link_options(${t} PRIVATE -municode)
|
|
|
|
endforeach()
|
2022-12-03 09:31:43 +03:00
|
|
|
elseif( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
|
2022-05-04 11:09:25 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus)
|
|
|
|
endforeach()
|
2022-03-19 11:10:49 +03:00
|
|
|
|
|
|
|
if(ENABLE_CODE_ANALYSIS)
|
2022-05-04 11:09:25 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /analyze)
|
|
|
|
endforeach()
|
2022-03-19 11:10:49 +03:00
|
|
|
endif()
|
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24)
|
2022-05-04 11:09:25 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /ZH:SHA_256)
|
|
|
|
endforeach()
|
2022-03-19 11:10:49 +03:00
|
|
|
endif()
|
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
|
2022-05-04 11:09:25 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /Zc:preprocessor /wd5105)
|
|
|
|
endforeach()
|
2022-03-19 11:10:49 +03:00
|
|
|
endif()
|
2020-12-19 04:41:46 +03:00
|
|
|
|
2022-12-03 09:31:43 +03:00
|
|
|
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) AND (NOT (${DIRECTX_ARCH} MATCHES "^arm")))
|
2022-05-04 11:09:25 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_link_options(${t} PRIVATE /CETCOMPAT)
|
|
|
|
endforeach()
|
2022-03-19 11:10:49 +03:00
|
|
|
endif()
|
|
|
|
|
2022-05-04 11:09:25 +03:00
|
|
|
set(WarningsEXE "/wd4365" "/wd4514" "/wd4625" "/wd4626" "/wd4627" "/wd4710" "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045")
|
2022-12-03 09:31:43 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.34)
|
2022-10-18 04:57:40 +03:00
|
|
|
list(APPEND WarningsEXE "/wd5262" "/wd5264")
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE "/wd5262")
|
|
|
|
endif()
|
2022-05-06 00:20:57 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
2022-05-04 11:09:25 +03:00
|
|
|
target_compile_options(${t} PRIVATE ${WarningsEXE})
|
|
|
|
endforeach()
|
2019-05-25 00:26:52 +03:00
|
|
|
endif()
|
|
|
|
|
2019-12-12 03:23:25 +03:00
|
|
|
if(WIN32)
|
2022-03-02 13:17:11 +03:00
|
|
|
if(WINDOWS_STORE)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE WINAPI_FAMILY=WINAPI_FAMILY_APP)
|
|
|
|
endif()
|
|
|
|
|
2022-11-15 23:21:20 +03:00
|
|
|
if(WINDOWS_STORE OR BUILD_XAUDIO_WIN10 OR (${DIRECTX_ARCH} MATCHES "^arm64"))
|
2022-04-12 23:44:50 +03:00
|
|
|
message("INFO: Using DirectX Tool Kit for Audio on XAudio 2.9 (Windows 10/Windows 11).")
|
2022-11-15 23:21:20 +03:00
|
|
|
set(WINVER 0x0A00)
|
|
|
|
elseif(BUILD_XAUDIO_WIN8 OR ${DIRECTX_ARCH} MATCHES "^arm")
|
2021-06-01 04:20:42 +03:00
|
|
|
message("INFO: Using DirectX Tool Kit for Audio on XAudio 2.8 (Windows 8).")
|
2022-11-15 23:21:20 +03:00
|
|
|
set(WINVER 0x0602)
|
2019-12-14 04:49:12 +03:00
|
|
|
else()
|
2022-11-15 23:21:20 +03:00
|
|
|
set(WINVER 0x0601)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN7_PLATFORM_UPDATE)
|
2019-12-14 04:49:12 +03:00
|
|
|
endif()
|
2022-11-15 23:21:20 +03:00
|
|
|
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_definitions(${t} PRIVATE _UNICODE UNICODE _WIN32_WINNT=${WINVER})
|
2022-05-04 11:09:25 +03:00
|
|
|
endforeach()
|
2019-12-12 03:23:25 +03:00
|
|
|
endif()
|
2020-08-11 06:13:24 +03:00
|
|
|
|
2021-01-14 10:59:04 +03:00
|
|
|
if(BUILD_TOOLS AND (NOT WINDOWS_STORE))
|
2020-12-19 04:41:46 +03:00
|
|
|
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT xwbtool)
|
|
|
|
endif()
|
2022-11-23 04:17:55 +03:00
|
|
|
|
|
|
|
#--- Test suite
|
|
|
|
include(CTest)
|
|
|
|
if(BUILD_TESTING AND WIN32 AND (NOT WINDOWS_STORE) AND (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Tests/CMakeLists.txt"))
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Tests)
|
|
|
|
endif()
|