2021-02-27 06:59:42 +00:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2019-07-12 07:40:57 +00:00
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
2022-11-15 20:09:51 +00:00
|
|
|
cmake_minimum_required (VERSION 3.20)
|
2019-11-15 08:39:50 +00:00
|
|
|
|
2024-06-05 00:01:20 +00:00
|
|
|
set(DIRECTXTEX_VERSION 2.0.4)
|
2020-12-18 23:28:28 +00:00
|
|
|
|
2023-10-31 05:04:49 +00:00
|
|
|
if(WINDOWS_STORE OR (DEFINED XBOX_CONSOLE_TARGET))
|
2023-04-28 00:03:18 +00:00
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
|
|
|
endif()
|
|
|
|
|
2020-12-18 23:28:28 +00:00
|
|
|
project (DirectXTex
|
|
|
|
VERSION ${DIRECTXTEX_VERSION}
|
|
|
|
DESCRIPTION "DirectX Texture Library"
|
|
|
|
HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkId=248926"
|
|
|
|
LANGUAGES CXX)
|
2019-07-12 07:40:57 +00:00
|
|
|
|
2020-12-19 02:05:07 +00:00
|
|
|
option(BUILD_TOOLS "Build tex command-line tools" ON)
|
|
|
|
|
2024-01-29 21:10:33 +00:00
|
|
|
option(BUILD_SAMPLE "Build DDSView sample (requires fxc.exe)" ON)
|
2022-03-28 00:29:48 +00:00
|
|
|
|
2021-01-01 21:36:40 +00:00
|
|
|
# Includes the functions for Direct3D 11 resources and DirectCompute compression
|
2024-01-29 21:10:33 +00:00
|
|
|
option(BUILD_DX11 "Build with DirectX11 Runtime support (requires fxc.exe)" ON)
|
2019-12-14 01:30:01 +00:00
|
|
|
|
|
|
|
# Includes the functions for creating Direct3D 12 resources at runtime
|
|
|
|
option(BUILD_DX12 "Build with DirectX12 Runtime support" ON)
|
|
|
|
|
2019-12-14 06:26:18 +00:00
|
|
|
# Enable the use of OpenMP for software BC6H/BC7 compression
|
|
|
|
option(BC_USE_OPENMP "Build with OpenMP support" ON)
|
|
|
|
|
2023-11-29 19:00:59 +00:00
|
|
|
# Builds Xbox extensions for Host PC
|
|
|
|
option(BUILD_XBOX_EXTS_XBOXONE "Build Xbox library extensions for Xbox One" OFF)
|
|
|
|
option(BUILD_XBOX_EXTS_SCARLETT "Build Xbox library extensions for Xbox Series X|S" OFF)
|
|
|
|
|
2022-12-06 19:43:45 +00:00
|
|
|
# https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/
|
|
|
|
option(ENABLE_SPECTRE_MITIGATION "Build using /Qspectre for MSVC" OFF)
|
|
|
|
|
2022-12-27 20:03:08 +00:00
|
|
|
option(DISABLE_MSVC_ITERATOR_DEBUGGING "Disable iterator debugging in Debug configurations with the MSVC CRT" OFF)
|
|
|
|
|
2020-06-05 22:01:02 +00:00
|
|
|
option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)
|
|
|
|
|
2021-10-07 06:14:26 +00:00
|
|
|
option(USE_PREBUILT_SHADERS "Use externally built HLSL shaders" OFF)
|
|
|
|
|
2023-08-20 18:01:09 +00:00
|
|
|
option(NO_WCHAR_T "Use legacy wide-character as unsigned short" OFF)
|
|
|
|
|
2023-11-06 07:12:56 +00:00
|
|
|
option(BUILD_FUZZING "Build for fuzz testing" OFF)
|
|
|
|
|
2020-12-19 02:44:47 +00:00
|
|
|
# Includes the functions for loading/saving OpenEXR files at runtime
|
|
|
|
option(ENABLE_OPENEXR_SUPPORT "Build with OpenEXR support" OFF)
|
|
|
|
|
2024-01-20 19:02:19 +00:00
|
|
|
# See https://www.ijg.org/
|
|
|
|
option(ENABLE_LIBJPEG_SUPPORT "Build with libjpeg support" OFF)
|
|
|
|
|
|
|
|
# See http://www.libpng.org/pub/png/libpng.html
|
|
|
|
option(ENABLE_LIBPNG_SUPPORT "Build with libpng support" OFF)
|
|
|
|
|
2021-01-05 07:10:30 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-07-12 07:40:57 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2024-01-11 09:06:56 +00:00
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
2019-07-12 07:40:57 +00:00
|
|
|
|
2023-03-17 22:47:52 +00:00
|
|
|
if(WINDOWS_STORE OR (DEFINED XBOX_CONSOLE_TARGET))
|
|
|
|
set(BUILD_DX12 ON)
|
|
|
|
set(BUILD_TOOLS OFF)
|
|
|
|
set(BUILD_SAMPLE OFF)
|
|
|
|
endif()
|
|
|
|
|
2024-01-29 23:08:07 +00:00
|
|
|
if((DEFINED XBOX_CONSOLE_TARGET) AND (NOT (XBOX_CONSOLE_TARGET STREQUAL "durango")))
|
2023-02-10 05:58:13 +00:00
|
|
|
set(BUILD_DX11 OFF)
|
2023-02-06 23:27:58 +00:00
|
|
|
endif()
|
|
|
|
|
2022-05-02 10:01:40 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2020-12-18 23:28:28 +00:00
|
|
|
#--- Library
|
|
|
|
set(LIBRARY_HEADERS
|
|
|
|
DirectXTex/DirectXTex.h
|
|
|
|
DirectXTex/DirectXTex.inl)
|
|
|
|
|
2019-12-14 01:30:01 +00:00
|
|
|
set(LIBRARY_SOURCES
|
2019-07-12 07:40:57 +00:00
|
|
|
DirectXTex/BC.h
|
|
|
|
DirectXTex/DDS.h
|
|
|
|
DirectXTex/DirectXTexP.h
|
|
|
|
DirectXTex/filters.h
|
|
|
|
DirectXTex/scoped.h
|
|
|
|
DirectXTex/BC.cpp
|
|
|
|
DirectXTex/BC4BC5.cpp
|
|
|
|
DirectXTex/BC6HBC7.cpp
|
|
|
|
DirectXTex/DirectXTexCompress.cpp
|
|
|
|
DirectXTex/DirectXTexConvert.cpp
|
|
|
|
DirectXTex/DirectXTexDDS.cpp
|
|
|
|
DirectXTex/DirectXTexHDR.cpp
|
|
|
|
DirectXTex/DirectXTexImage.cpp
|
|
|
|
DirectXTex/DirectXTexMipmaps.cpp
|
|
|
|
DirectXTex/DirectXTexMisc.cpp
|
|
|
|
DirectXTex/DirectXTexNormalMaps.cpp
|
|
|
|
DirectXTex/DirectXTexPMAlpha.cpp
|
|
|
|
DirectXTex/DirectXTexResize.cpp
|
|
|
|
DirectXTex/DirectXTexTGA.cpp
|
2021-01-08 10:20:55 +00:00
|
|
|
DirectXTex/DirectXTexUtil.cpp)
|
|
|
|
|
|
|
|
if(WIN32)
|
2023-11-29 19:00:59 +00:00
|
|
|
list(APPEND LIBRARY_SOURCES
|
2021-01-08 10:20:55 +00:00
|
|
|
DirectXTex/DirectXTexFlipRotate.cpp
|
|
|
|
DirectXTex/DirectXTexWIC.cpp)
|
|
|
|
endif()
|
2019-12-14 01:30:01 +00:00
|
|
|
|
2023-11-29 19:00:59 +00:00
|
|
|
if(DEFINED XBOX_CONSOLE_TARGET)
|
|
|
|
|
|
|
|
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexXbox.h)
|
|
|
|
|
|
|
|
list(APPEND LIBRARY_SOURCES
|
|
|
|
Auxiliary/DirectXTexXboxDDS.cpp
|
|
|
|
Auxiliary/DirectXTexXboxDetile.cpp
|
|
|
|
Auxiliary/DirectXTexXboxImage.cpp
|
|
|
|
Auxiliary/DirectXTexXboxTile.cpp)
|
|
|
|
|
|
|
|
if((XBOX_CONSOLE_TARGET STREQUAL "durango") AND BUILD_DX11)
|
|
|
|
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexXboxD3D11X.cpp)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BUILD_DX12)
|
|
|
|
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexXboxD3D12X.cpp)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
elseif((BUILD_XBOX_EXTS_XBOXONE OR BUILD_XBOX_EXTS_SCARLETT) AND WIN32)
|
|
|
|
if(DEFINED ENV{GameDKLatest})
|
|
|
|
cmake_path(SET GameDK_DIR "$ENV{GameDKLatest}")
|
|
|
|
endif()
|
|
|
|
if(DEFINED ENV{XboxOneXDKLatest})
|
|
|
|
cmake_path(SET XboxOneXDK_DIR "$ENV{XboxOneXDKLatest}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexXbox.h)
|
|
|
|
|
|
|
|
list(APPEND LIBRARY_SOURCES
|
|
|
|
Auxiliary/DirectXTexXboxDDS.cpp
|
|
|
|
Auxiliary/DirectXTexXboxDetile.cpp
|
|
|
|
Auxiliary/DirectXTexXboxImage.cpp
|
|
|
|
Auxiliary/DirectXTexXboxTile.cpp)
|
|
|
|
endif()
|
|
|
|
|
2019-12-17 19:18:37 +00:00
|
|
|
set(SHADER_SOURCES
|
|
|
|
DirectXTex/Shaders/BC6HEncode.hlsl
|
|
|
|
DirectXTex/Shaders/BC7Encode.hlsl)
|
|
|
|
|
2021-01-08 10:20:55 +00:00
|
|
|
if(BUILD_DX11 AND WIN32)
|
2023-11-29 19:00:59 +00:00
|
|
|
list(APPEND LIBRARY_SOURCES
|
2021-01-01 21:36:40 +00:00
|
|
|
DirectXTex/BCDirectCompute.h
|
|
|
|
DirectXTex/BCDirectCompute.cpp
|
|
|
|
DirectXTex/DirectXTexCompressGPU.cpp
|
2021-01-05 07:10:30 +00:00
|
|
|
DirectXTex/DirectXTexD3D11.cpp)
|
2019-12-14 01:30:01 +00:00
|
|
|
endif()
|
2021-01-08 10:20:55 +00:00
|
|
|
|
2020-06-05 22:01:02 +00:00
|
|
|
if(BUILD_DX12)
|
2023-11-29 19:00:59 +00:00
|
|
|
list(APPEND LIBRARY_SOURCES DirectXTex/DirectXTexD3D12.cpp)
|
|
|
|
|
|
|
|
if(NOT (DEFINED XBOX_CONSOLE_TARGET))
|
|
|
|
list(APPEND LIBRARY_SOURCES DirectXTex/d3dx12.h)
|
|
|
|
endif()
|
2019-12-14 01:30:01 +00:00
|
|
|
endif()
|
|
|
|
|
2020-12-19 02:44:47 +00:00
|
|
|
if(ENABLE_OPENEXR_SUPPORT)
|
2023-11-29 19:00:59 +00:00
|
|
|
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexEXR.h)
|
|
|
|
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexEXR.cpp)
|
2020-12-19 02:44:47 +00:00
|
|
|
endif()
|
|
|
|
|
2024-01-20 19:02:19 +00:00
|
|
|
if(ENABLE_LIBJPEG_SUPPORT)
|
|
|
|
if(WIN32)
|
|
|
|
message(STATUS "Use of the Windows Imaging Component (WIC) instead of libjpeg is recommended.")
|
|
|
|
endif()
|
|
|
|
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexJPEG.h)
|
|
|
|
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexJPEG.cpp)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_LIBPNG_SUPPORT)
|
|
|
|
if(WIN32)
|
|
|
|
message(STATUS "Use of the Windows Imaging Component (WIC) instead of libpng is recommended.")
|
|
|
|
endif()
|
|
|
|
list(APPEND LIBRARY_HEADERS Auxiliary/DirectXTexPNG.h)
|
|
|
|
list(APPEND LIBRARY_SOURCES Auxiliary/DirectXTexPNG.cpp)
|
|
|
|
endif()
|
|
|
|
|
2021-01-08 10:20:55 +00:00
|
|
|
if(BUILD_DX11 AND WIN32)
|
2022-12-03 06:33:06 +00:00
|
|
|
if(NOT COMPILED_SHADERS)
|
|
|
|
if(USE_PREBUILT_SHADERS)
|
2021-10-07 06:14:26 +00: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 07:29:00 +00:00
|
|
|
else()
|
|
|
|
file(TO_CMAKE_PATH ${COMPILED_SHADERS} COMPILED_SHADERS)
|
2021-10-07 06:14:26 +00:00
|
|
|
endif()
|
|
|
|
|
2023-11-29 19:00:59 +00:00
|
|
|
list(APPEND LIBRARY_SOURCES ${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc)
|
2021-10-07 06:14:26 +00:00
|
|
|
|
2022-12-03 06:33:06 +00:00
|
|
|
if(NOT USE_PREBUILT_SHADERS)
|
2021-10-07 06:14:26 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc"
|
|
|
|
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders/CompileShaders.cmd"
|
|
|
|
DEPENDS ${SHADER_SOURCES}
|
|
|
|
COMMENT "Generating HLSL shaders..."
|
2022-05-06 21:01:02 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" CompileShaders.cmd > "${COMPILED_SHADERS}/compileshaders.log"
|
2021-10-07 06:14:26 +00:00
|
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders"
|
|
|
|
USES_TERMINAL)
|
|
|
|
endif()
|
2021-01-01 21:36:40 +00:00
|
|
|
endif()
|
2019-07-12 07:40:57 +00:00
|
|
|
|
2021-01-05 07:10:30 +00:00
|
|
|
add_library(${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
|
|
|
|
|
2021-10-07 06:14:26 +00:00
|
|
|
if(BUILD_DX11 AND WIN32)
|
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${COMPILED_SHADERS})
|
|
|
|
endif()
|
|
|
|
|
2019-11-15 08:39:50 +00:00
|
|
|
source_group(${PROJECT_NAME} REGULAR_EXPRESSION DirectXTex/*.*)
|
2019-09-19 06:48:38 +00:00
|
|
|
|
2020-12-18 23:28:28 +00:00
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/DirectXTex>
|
2022-05-02 10:01:40 +00:00
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
2019-07-12 07:40:57 +00:00
|
|
|
|
2022-05-28 00:18:38 +00:00
|
|
|
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
|
|
|
|
|
2023-04-24 20:53:24 +00:00
|
|
|
if(BC_USE_OPENMP)
|
|
|
|
find_package(OpenMP)
|
|
|
|
if(OpenMP_CXX_FOUND)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC OpenMP::OpenMP_CXX)
|
|
|
|
else()
|
|
|
|
set(BC_USE_OPENMP OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-12-19 02:44:47 +00:00
|
|
|
if(ENABLE_OPENEXR_SUPPORT)
|
2021-01-10 18:50:24 +00:00
|
|
|
find_package(OpenEXR REQUIRED)
|
2023-04-24 20:53:24 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC OpenEXR::OpenEXR)
|
2020-12-19 02:44:47 +00:00
|
|
|
endif()
|
|
|
|
|
2023-11-29 19:00:59 +00:00
|
|
|
if(BUILD_XBOX_EXTS_SCARLETT AND WIN32)
|
2024-02-09 19:52:49 +00:00
|
|
|
if(EXISTS "${GameDK_DIR}/GXDK/toolKit/include/gxdk.h")
|
2023-11-29 19:00:59 +00:00
|
|
|
message(STATUS "Building Xbox extensions for Xbox Series X|S")
|
2024-01-22 15:58:00 +00:00
|
|
|
|
|
|
|
add_library(Xbox::GDKX SHARED IMPORTED)
|
|
|
|
set_target_properties(Xbox::GDKX PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${GameDK_DIR}/GXDK/bin/Scarlett/xg_xs.dll"
|
|
|
|
IMPORTED_IMPLIB "${GameDK_DIR}/GXDK/toolKit/lib/amd64/Scarlett/xg_xs.lib"
|
|
|
|
MAP_IMPORTED_CONFIG_MINSIZEREL ""
|
|
|
|
MAP_IMPORTED_CONFIG_RELWITHDEBINFO ""
|
|
|
|
INTERFACE_COMPILE_DEFINITIONS "_USE_GXDK;_USE_SCARLETT"
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${GameDK_DIR}/GXDK/toolKit/include;${GameDK_DIR}/GXDK/toolKit/include/Scarlett")
|
|
|
|
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_XBOX_EXTS)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Xbox::GDKX)
|
2023-11-29 19:00:59 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Building Xbox extensions requires GameDKLatest")
|
|
|
|
endif()
|
|
|
|
elseif(BUILD_XBOX_EXTS_XBOXONE AND WIN32)
|
2024-02-09 19:52:49 +00:00
|
|
|
if(EXISTS "${GameDK_DIR}/GXDK/toolKit/include/gxdk.h")
|
2023-11-29 19:00:59 +00:00
|
|
|
message(STATUS "Building Xbox extensions for XboxOne using the Microsoft GDK")
|
2024-01-22 15:58:00 +00:00
|
|
|
|
|
|
|
add_library(Xbox::GDKX SHARED IMPORTED)
|
|
|
|
set_target_properties(Xbox::GDKX PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${GameDK_DIR}/GXDK/bin/XboxOne/xg.dll"
|
|
|
|
IMPORTED_IMPLIB "${GameDK_DIR}/GXDK/toolKit/lib/amd64/XboxOne/xg.lib"
|
|
|
|
MAP_IMPORTED_CONFIG_MINSIZEREL ""
|
|
|
|
MAP_IMPORTED_CONFIG_RELWITHDEBINFO ""
|
|
|
|
INTERFACE_COMPILE_DEFINITIONS "_USE_GXDK"
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${GameDK_DIR}/GXDK/toolKit/include;${GameDK_DIR}/GXDK/toolKit/include/XboxOne")
|
|
|
|
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_XBOX_EXTS)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Xbox::GDKX)
|
|
|
|
|
2024-02-09 19:52:49 +00:00
|
|
|
elseif(EXISTS "${XboxOneXDK_DIR}/PC/include/xdk.h")
|
2023-11-29 19:00:59 +00:00
|
|
|
message(STATUS "Building Xbox extensions for XboxOne using the Xbox One XDK")
|
2024-01-22 15:58:00 +00:00
|
|
|
|
|
|
|
add_library(Xbox::XDK SHARED IMPORTED)
|
|
|
|
set_target_properties(Xbox::XDK PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${XboxOneXDK_DIR}/bin/xg.dll"
|
|
|
|
IMPORTED_IMPLIB "${XboxOneXDK_DIR}/PC/lib/amd64/xg.lib"
|
|
|
|
MAP_IMPORTED_CONFIG_MINSIZEREL ""
|
|
|
|
MAP_IMPORTED_CONFIG_RELWITHDEBINFO ""
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${XboxOneXDK_DIR}/PC/include")
|
|
|
|
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_XBOX_EXTS)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Xbox::XDK)
|
2023-11-29 19:00:59 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Building Xbox extensions requires GameDKLatest or XboxOneXDKLatest")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2024-01-20 19:02:19 +00:00
|
|
|
if(ENABLE_LIBJPEG_SUPPORT)
|
|
|
|
find_package(JPEG REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC JPEG::JPEG)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_LIBPNG_SUPPORT)
|
|
|
|
find_package(PNG REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC PNG::PNG)
|
|
|
|
endif()
|
|
|
|
|
2022-12-03 06:33:06 +00:00
|
|
|
if(NOT MINGW)
|
2020-03-29 22:09:59 +00:00
|
|
|
target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXTex/DirectXTexP.h)
|
|
|
|
endif()
|
2020-03-29 19:49:11 +00:00
|
|
|
|
2023-02-10 05:58:13 +00:00
|
|
|
if(MINGW OR (NOT WIN32))
|
2021-01-08 10:20:55 +00:00
|
|
|
find_package(directxmath CONFIG REQUIRED)
|
2023-02-10 05:58:13 +00:00
|
|
|
find_package(directx-headers CONFIG REQUIRED)
|
|
|
|
else()
|
|
|
|
find_package(directxmath CONFIG QUIET)
|
|
|
|
find_package(directx-headers CONFIG QUIET)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(directxmath_FOUND)
|
|
|
|
message(STATUS "Using DirectXMath package")
|
2023-02-06 23:27:58 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectXMath)
|
2023-02-10 05:58:13 +00:00
|
|
|
endif()
|
2023-02-06 23:27:58 +00:00
|
|
|
|
2023-02-10 05:58:13 +00:00
|
|
|
if(directx-headers_FOUND)
|
|
|
|
message(STATUS "Using DirectX-Headers package")
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
|
2023-02-16 06:07:52 +00:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC USING_DIRECTX_HEADERS)
|
|
|
|
endif()
|
|
|
|
|
2020-12-18 23:28:28 +00:00
|
|
|
#--- Package
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
2020-12-29 10:49:19 +00:00
|
|
|
string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME)
|
|
|
|
|
2020-12-18 23:28:28 +00:00
|
|
|
write_basic_package_version_file(
|
2022-05-02 10:01:40 +00:00
|
|
|
${PACKAGE_NAME}-config-version.cmake
|
2020-12-18 23:28:28 +00:00
|
|
|
VERSION ${DIRECTXTEX_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion)
|
|
|
|
|
|
|
|
install(TARGETS ${PROJECT_NAME}
|
|
|
|
EXPORT ${PROJECT_NAME}-targets
|
2022-05-02 10:01:40 +00:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2020-12-18 23:28:28 +00:00
|
|
|
|
2022-12-05 02:22:15 +00:00
|
|
|
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/build/${PROJECT_NAME}-config.cmake.in
|
2022-05-02 10:01:40 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
|
2022-06-03 07:33:58 +00:00
|
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
|
2020-12-18 23:28:28 +00:00
|
|
|
|
|
|
|
install(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
FILE ${PROJECT_NAME}-targets.cmake
|
|
|
|
NAMESPACE Microsoft::
|
2022-06-03 07:33:58 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
|
2020-12-18 23:28:28 +00:00
|
|
|
|
|
|
|
install(FILES ${LIBRARY_HEADERS}
|
2022-05-02 10:01:40 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2020-12-18 23:28:28 +00:00
|
|
|
|
2021-01-05 07:10:30 +00:00
|
|
|
install(FILES
|
2022-05-02 10:01:40 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake
|
2022-06-03 07:33:58 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
|
2020-12-18 23:28:28 +00:00
|
|
|
|
2023-12-21 07:06:31 +00:00
|
|
|
# Create pkg-config file
|
|
|
|
include(build/JoinPaths.cmake)
|
|
|
|
# from: https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files
|
|
|
|
join_paths(DIRECTXTEX_INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
|
|
join_paths(DIRECTXTEX_LIBDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
|
|
|
|
|
|
|
set(DIRECTXTEX_DEP_L "")
|
|
|
|
if(ENABLE_OPENEXR_SUPPORT)
|
|
|
|
list(APPEND DIRECTXTEX_DEP_L "OpenEXR")
|
|
|
|
endif()
|
|
|
|
if(directxmath_FOUND)
|
|
|
|
list(APPEND DIRECTXTEX_DEP_L "DirectXMath")
|
|
|
|
endif()
|
|
|
|
if(directx-headers_FOUND)
|
|
|
|
list(APPEND DIRECTXTEX_DEP_L "DirectX-Headers")
|
|
|
|
endif()
|
2024-01-20 19:02:19 +00:00
|
|
|
if(ENABLE_LIBJPEG_SUPPORT AND JPEG_FOUND)
|
|
|
|
list(APPEND DIRECTXTEX_DEP_L "libjpeg")
|
|
|
|
endif()
|
|
|
|
if(ENABLE_LIBPNG_SUPPORT AND PNG_FOUND)
|
|
|
|
list(APPEND DIRECTXTEX_DEP_L "libpng")
|
|
|
|
endif()
|
|
|
|
|
2023-12-21 07:06:31 +00:00
|
|
|
list(LENGTH DIRECTXTEX_DEP_L DEP_L)
|
|
|
|
if(DEP_L)
|
|
|
|
STRING(REPLACE ";" ", " DIRECTXTEX_DEP " ${DIRECTXTEX_DEP_L}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/build/DirectXTex.pc.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/DirectXTex.pc" @ONLY)
|
|
|
|
|
|
|
|
# Install the pkg-config file
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DirectXTex.pc"
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
|
|
|
|
2020-12-18 23:28:28 +00:00
|
|
|
#--- Command-line tools
|
2023-12-30 20:45:09 +00:00
|
|
|
set(TOOL_EXES "")
|
2022-03-23 23:52:58 +00:00
|
|
|
|
2023-12-30 20:45:09 +00:00
|
|
|
if(BUILD_TOOLS AND WIN32)
|
2020-12-19 02:05:07 +00:00
|
|
|
add_executable(texassemble
|
2020-07-01 08:37:13 +00:00
|
|
|
Texassemble/texassemble.cpp
|
2022-08-31 01:27:46 +00:00
|
|
|
Texassemble/texassemble.rc
|
2023-06-13 22:40:45 +00:00
|
|
|
Texassemble/settings.manifest
|
2020-07-01 08:37:13 +00:00
|
|
|
Texassemble/AnimatedGif.cpp)
|
2024-02-09 19:52:49 +00:00
|
|
|
target_compile_features(texassemble PRIVATE cxx_std_17)
|
2023-06-16 18:35:08 +00:00
|
|
|
target_link_libraries(texassemble PRIVATE ${PROJECT_NAME} ole32.lib version.lib)
|
2020-12-19 02:05:07 +00:00
|
|
|
source_group(texassemble REGULAR_EXPRESSION Texassemble/*.*)
|
2023-12-30 20:45:09 +00:00
|
|
|
list(APPEND TOOL_EXES texassemble)
|
|
|
|
endif()
|
2019-07-12 07:40:57 +00:00
|
|
|
|
2023-12-30 20:45:09 +00:00
|
|
|
if(BUILD_TOOLS AND BUILD_DX11 AND WIN32)
|
2020-12-19 02:05:07 +00:00
|
|
|
add_executable(texconv
|
2020-06-05 03:07:21 +00:00
|
|
|
Texconv/texconv.cpp
|
2022-08-31 01:27:46 +00:00
|
|
|
Texconv/texconv.rc
|
2023-06-13 22:40:45 +00:00
|
|
|
Texconv/settings.manifest
|
2020-06-05 03:07:21 +00:00
|
|
|
Texconv/ExtendedBMP.cpp
|
|
|
|
Texconv/PortablePixMap.cpp)
|
2024-02-09 19:52:49 +00:00
|
|
|
target_compile_features(texconv PRIVATE cxx_std_17)
|
2023-06-16 18:35:08 +00:00
|
|
|
target_link_libraries(texconv PRIVATE ${PROJECT_NAME} ole32.lib shell32.lib version.lib)
|
2020-12-19 02:05:07 +00:00
|
|
|
source_group(texconv REGULAR_EXPRESSION Texconv/*.*)
|
2023-12-30 20:45:09 +00:00
|
|
|
list(APPEND TOOL_EXES texconv)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BUILD_TOOLS AND WIN32)
|
2022-08-31 01:27:46 +00:00
|
|
|
add_executable(texdiag
|
|
|
|
Texdiag/texdiag.cpp
|
2023-06-13 22:40:45 +00:00
|
|
|
Texdiag/texdiag.rc
|
|
|
|
Texdiag/settings.manifest)
|
2024-02-09 19:52:49 +00:00
|
|
|
target_compile_features(texdiag PRIVATE cxx_std_17)
|
2023-06-16 18:35:08 +00:00
|
|
|
target_link_libraries(texdiag PRIVATE ${PROJECT_NAME} ole32.lib version.lib)
|
2020-12-19 02:05:07 +00:00
|
|
|
source_group(texdiag REGULAR_EXPRESSION Texdiag/*.*)
|
2023-12-30 20:45:09 +00:00
|
|
|
list(APPEND TOOL_EXES texdiag)
|
|
|
|
endif()
|
2020-12-19 02:44:47 +00:00
|
|
|
|
2023-12-30 20:45:09 +00:00
|
|
|
if(BUILD_TOOLS AND WIN32)
|
2020-12-19 02:44:47 +00:00
|
|
|
if(ENABLE_OPENEXR_SUPPORT)
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
2022-10-22 21:35:26 +00:00
|
|
|
target_include_directories(${t} PRIVATE Auxiliary)
|
2023-06-16 18:35:08 +00:00
|
|
|
target_link_libraries(${t} PRIVATE ${OPENEXR_ILMIMF_LIBRARY})
|
2024-01-08 03:26:09 +00:00
|
|
|
target_compile_definitions(${t} PRIVATE USE_OPENEXR)
|
2022-03-23 23:52:58 +00:00
|
|
|
endforeach()
|
2020-12-19 02:44:47 +00:00
|
|
|
endif()
|
2024-01-20 19:02:19 +00:00
|
|
|
if(ENABLE_LIBJPEG_SUPPORT)
|
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_include_directories(${t} PRIVATE Auxiliary)
|
|
|
|
target_link_libraries(${t} PRIVATE JPEG::JPEG)
|
|
|
|
target_compile_definitions(${t} PRIVATE USE_LIBJPEG)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
if(ENABLE_LIBPNG_SUPPORT)
|
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_include_directories(${t} PRIVATE Auxiliary)
|
|
|
|
target_link_libraries(${t} PRIVATE PNG::PNG)
|
|
|
|
target_compile_definitions(${t} PRIVATE USE_LIBPNG)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2024-01-22 15:58:00 +00:00
|
|
|
if(BUILD_XBOX_EXTS_SCARLETT OR BUILD_XBOX_EXTS_XBOXONE)
|
|
|
|
target_include_directories(texconv PRIVATE Auxiliary)
|
|
|
|
target_compile_definitions(texconv PRIVATE USE_XBOX_EXTS)
|
|
|
|
target_link_libraries(texconv PUBLIC $<TARGET_NAME_IF_EXISTS:Xbox::GDKX> $<TARGET_NAME_IF_EXISTS:Xbox::XDK>)
|
|
|
|
|
2024-02-09 19:52:49 +00:00
|
|
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21")
|
2024-01-22 15:58:00 +00:00
|
|
|
add_custom_command(TARGET texconv POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
|
|
$<TARGET_RUNTIME_DLLS:texconv> $<TARGET_FILE_DIR:texconv>
|
|
|
|
COMMAND_EXPAND_LISTS
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-12-19 02:05:07 +00:00
|
|
|
endif()
|
2019-11-15 08:39:50 +00:00
|
|
|
|
2022-03-28 00:29:48 +00:00
|
|
|
#--- DDSView sample
|
2023-03-17 22:47:52 +00:00
|
|
|
if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32)
|
2022-03-28 00:29:48 +00:00
|
|
|
list(APPEND TOOL_EXES ddsview)
|
|
|
|
|
2022-12-03 06:33:06 +00:00
|
|
|
if(NOT COMPILED_DDSVIEW_SHADERS)
|
|
|
|
if(USE_PREBUILT_SHADERS)
|
2022-05-06 07:29:00 +00:00
|
|
|
message(FATAL_ERROR "ERROR: Using prebuilt shaders requires the COMPILED_DDSVIEW_SHADERS variable is set")
|
|
|
|
endif()
|
|
|
|
set(COMPILED_DDSVIEW_SHADERS ${CMAKE_CURRENT_BINARY_DIR}/Shaders/Compiled)
|
|
|
|
file(MAKE_DIRECTORY ${COMPILED_DDSVIEW_SHADERS})
|
|
|
|
else()
|
|
|
|
file(TO_CMAKE_PATH ${COMPILED_DDSVIEW_SHADERS} COMPILED_DDSVIEW_SHADERS)
|
|
|
|
endif()
|
|
|
|
|
2022-03-28 00:29:48 +00:00
|
|
|
add_executable(ddsview WIN32
|
|
|
|
DDSView/ddsview.cpp
|
2022-03-28 06:03:24 +00:00
|
|
|
DDSView/ddsview.rc
|
2022-05-06 07:29:00 +00:00
|
|
|
${COMPILED_DDSVIEW_SHADERS}/ddsview_ps1D.inc)
|
2023-06-16 18:35:08 +00:00
|
|
|
target_link_libraries(ddsview PRIVATE ${PROJECT_NAME} d3d11.lib ole32.lib)
|
2022-03-28 00:29:48 +00:00
|
|
|
source_group(ddsview REGULAR_EXPRESSION DDSView/*.*)
|
2022-03-28 06:03:24 +00:00
|
|
|
|
2022-05-06 07:29:00 +00:00
|
|
|
target_include_directories(ddsview PRIVATE ${COMPILED_DDSVIEW_SHADERS})
|
2022-03-28 06:03:24 +00:00
|
|
|
|
2022-12-03 06:33:06 +00:00
|
|
|
if(NOT USE_PREBUILT_SHADERS)
|
2022-03-28 06:03:24 +00:00
|
|
|
add_custom_command(
|
2022-05-06 07:29:00 +00:00
|
|
|
OUTPUT "${COMPILED_DDSVIEW_SHADERS}/ddsview_ps1D.inc"
|
2022-03-28 06:03:24 +00:00
|
|
|
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DDSView/hlsl.cmd"
|
|
|
|
DEPENDS "${PROJECT_SOURCE_DIR}/DDSView/ddsview.fx"
|
|
|
|
COMMENT "Generating HLSL shaders for DDSView..."
|
2022-05-06 21:01:02 +00:00
|
|
|
COMMAND COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_DDSVIEW_SHADERS}" hlsl.cmd > "${COMPILED_DDSVIEW_SHADERS}/hlsl.log"
|
2022-03-28 06:03:24 +00:00
|
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DDSView"
|
|
|
|
USES_TERMINAL)
|
|
|
|
endif()
|
2022-03-28 00:29:48 +00:00
|
|
|
endif()
|
|
|
|
|
2023-02-10 05:58:13 +00:00
|
|
|
if(directxmath_FOUND)
|
2022-05-04 06:44:20 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
2023-06-16 18:35:08 +00:00
|
|
|
target_link_libraries(${t} PRIVATE Microsoft::DirectXMath)
|
2022-05-04 06:44:20 +00:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2019-12-02 18:52:27 +00:00
|
|
|
if(MSVC)
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2024-02-12 21:06:47 +00:00
|
|
|
target_compile_options(${t} PRIVATE /Wall /GR-)
|
2022-03-23 23:52:58 +00:00
|
|
|
endforeach()
|
2019-12-02 18:52:27 +00:00
|
|
|
|
2023-08-20 18:01:09 +00:00
|
|
|
if(NO_WCHAR_T)
|
|
|
|
message(STATUS "Using non-native wchar_t as unsigned short")
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE "/Zc:wchar_t-")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2019-11-15 08:39:50 +00:00
|
|
|
endif()
|
2019-07-12 07:40:57 +00:00
|
|
|
|
2024-02-12 21:06:47 +00:00
|
|
|
include(build/CompilerAndLinker.cmake)
|
2022-05-05 21:50:13 +00:00
|
|
|
|
2024-02-12 21:06:47 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_definitions(${t} PRIVATE ${COMPILER_DEFINES})
|
|
|
|
target_compile_options(${t} PRIVATE ${COMPILER_SWITCHES})
|
|
|
|
target_link_options(${t} PRIVATE ${LINKER_SWITCHES})
|
|
|
|
endforeach()
|
2022-05-05 21:50:13 +00:00
|
|
|
|
2023-12-21 07:06:31 +00:00
|
|
|
if(MINGW)
|
2024-02-12 21:06:47 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
2023-12-21 07:06:31 +00:00
|
|
|
target_link_options(${t} PRIVATE -municode)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2024-02-09 19:52:49 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|IntelLLVM")
|
2022-11-15 20:09:51 +00:00
|
|
|
set(WarningsLib -Wall -Wpedantic -Wextra)
|
2023-11-29 19:00:59 +00:00
|
|
|
|
|
|
|
if((BUILD_XBOX_EXTS_XBOXONE OR BUILD_XBOX_EXTS_SCARLETT) AND WIN32)
|
|
|
|
list(APPEND WarningsLib "-Wno-microsoft-enum-value" "-Wno-non-virtual-dtor" "-Wno-ignored-pragmas" "-Wno-deprecated-dynamic-exception-spec")
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
|
|
|
|
list(APPEND WarningsLib "-Wno-reserved-identifier")
|
|
|
|
endif()
|
|
|
|
endif()
|
2024-02-12 21:06:47 +00:00
|
|
|
|
2023-04-28 00:03:18 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
|
|
|
|
list(APPEND WarningsLib "-Wno-unsafe-buffer-usage")
|
|
|
|
endif()
|
2019-11-15 08:39:50 +00:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
|
|
|
|
|
2024-02-05 18:08:59 +00:00
|
|
|
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-switch-default" "-Wno-covered-switch-default" "-Wno-language-extension-token" "-Wno-missing-prototypes" "-Wno-global-constructors" "-Wno-double-promotion")
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_compile_options(${t} PRIVATE ${WarningsEXE})
|
|
|
|
endforeach()
|
2023-12-21 07:06:31 +00:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
2022-05-05 21:50:13 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2024-01-07 01:40:03 +00:00
|
|
|
target_compile_options(${t} PRIVATE "-Wno-ignored-attributes" "-Walloc-size-larger-than=4GB")
|
2022-05-05 21:50:13 +00:00
|
|
|
endforeach()
|
2024-02-09 19:52:49 +00:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)
|
2022-12-03 06:33:06 +00:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
2024-04-05 21:37:53 +00:00
|
|
|
|
|
|
|
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.37)
|
|
|
|
AND (NOT (${DIRECTX_ARCH} MATCHES "^arm"))
|
|
|
|
AND ((${DIRECTX_ARCH} MATCHES "x64") OR (CMAKE_SIZEOF_VOID_P EQUAL 8)))
|
|
|
|
# Enable since DirectXTex library has a lot of large switch statements
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE /jumptablerdata)
|
|
|
|
endif()
|
|
|
|
|
2020-06-05 22:01:02 +00:00
|
|
|
if(ENABLE_CODE_ANALYSIS)
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2024-05-17 23:56:19 +00:00
|
|
|
target_compile_options(${t} PRIVATE /analyze /WX)
|
2022-03-23 23:52:58 +00:00
|
|
|
endforeach()
|
2020-12-19 02:05:07 +00:00
|
|
|
endif()
|
2020-06-05 22:01:02 +00:00
|
|
|
|
2024-02-09 19:52:49 +00:00
|
|
|
if(ENABLE_SPECTRE_MITIGATION
|
|
|
|
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.13)
|
|
|
|
AND (NOT ENABLE_OPENEXR_SUPPORT)
|
|
|
|
AND (NOT WINDOWS_STORE))
|
|
|
|
message(STATUS "Building Spectre-mitigated libraries")
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2024-02-09 19:52:49 +00:00
|
|
|
target_compile_options(${t} PRIVATE "/Qspectre")
|
2022-03-23 23:52:58 +00:00
|
|
|
endforeach()
|
2024-02-09 19:52:49 +00:00
|
|
|
endif()
|
|
|
|
|
2024-02-12 21:06:47 +00:00
|
|
|
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
|
|
|
|
AND BUILD_XBOX_EXTS_XBOXONE)
|
2023-02-16 06:07:52 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2024-02-12 21:06:47 +00:00
|
|
|
target_compile_options(${t} PRIVATE /wd5104 /wd5204)
|
2023-02-16 06:07:52 +00:00
|
|
|
endforeach()
|
2024-01-29 23:08:07 +00:00
|
|
|
endif()
|
|
|
|
|
2024-08-19 23:27:36 +00:00
|
|
|
set(WarningsEXE "/wd4061" "/wd4062" "/wd4365" "/wd4514" "/wd4571" "/wd4625" "/wd4626" "/wd4627" "/wd4668" "/wd4710" "/wd4711" "/wd4751" "/wd4774" "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd5219")
|
2022-12-03 06:33:06 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.34)
|
2024-02-09 19:52:49 +00:00
|
|
|
list(APPEND WarningsEXE "/wd5262" "/wd5264")
|
2022-10-18 01:41:09 +00:00
|
|
|
endif()
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_compile_options(${t} PRIVATE ${WarningsEXE})
|
|
|
|
endforeach()
|
2023-11-06 07:12:56 +00:00
|
|
|
|
2024-02-09 19:52:49 +00:00
|
|
|
if(BUILD_FUZZING
|
|
|
|
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.32)
|
|
|
|
AND (NOT WINDOWS_STORE))
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2024-02-12 21:06:47 +00:00
|
|
|
target_compile_options(${t} PRIVATE ${ASAN_SWITCHES})
|
|
|
|
target_link_libraries(${t} PRIVATE ${ASAN_LIBS})
|
2024-02-09 19:52:49 +00:00
|
|
|
endforeach()
|
2023-11-06 07:12:56 +00:00
|
|
|
endif()
|
2019-07-12 07:40:57 +00:00
|
|
|
endif()
|
|
|
|
|
2019-12-12 00:19:23 +00:00
|
|
|
if(WIN32)
|
2024-02-09 19:52:49 +00:00
|
|
|
if(XBOX_CONSOLE_TARGET STREQUAL "durango")
|
2023-04-28 00:03:18 +00:00
|
|
|
set(WINVER 0x0602)
|
|
|
|
elseif(BUILD_DX12 OR (${DIRECTX_ARCH} MATCHES "^arm64"))
|
2022-12-06 19:43:45 +00:00
|
|
|
message(STATUS "Building with DirectX 12 Runtime support")
|
2022-11-15 20:09:51 +00:00
|
|
|
set(WINVER 0x0A00)
|
|
|
|
elseif(${DIRECTX_ARCH} MATCHES "^arm")
|
|
|
|
set(WINVER 0x0602)
|
2019-12-14 01:30:01 +00:00
|
|
|
else()
|
2022-12-06 19:43:45 +00:00
|
|
|
message(STATUS "Building with Windows 7 compatibility")
|
2022-11-15 20:09:51 +00:00
|
|
|
set(WINVER 0x0601)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN7_PLATFORM_UPDATE)
|
2019-12-14 01:30:01 +00:00
|
|
|
endif()
|
2022-11-15 20:09:51 +00:00
|
|
|
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2024-02-12 21:06:47 +00:00
|
|
|
target_compile_definitions(${t} PRIVATE _WIN32_WINNT=${WINVER})
|
2022-05-04 06:44:20 +00:00
|
|
|
endforeach()
|
2022-12-27 20:03:08 +00:00
|
|
|
|
|
|
|
if(DISABLE_MSVC_ITERATOR_DEBUGGING)
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_definitions(${t} PRIVATE _ITERATOR_DEBUG_LEVEL=0)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2019-12-12 00:19:23 +00:00
|
|
|
endif()
|
2020-08-11 03:54:31 +00:00
|
|
|
|
2023-03-17 22:47:52 +00:00
|
|
|
if(BUILD_TOOLS AND BUILD_DX11 AND WIN32)
|
2024-02-09 19:52:49 +00:00
|
|
|
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT texconv)
|
2020-12-19 02:05:07 +00:00
|
|
|
endif()
|
2022-11-22 19:37:25 +00:00
|
|
|
|
2024-01-11 09:06:56 +00:00
|
|
|
if(BUILD_TOOLS AND (NOT VCPKG_TOOLCHAIN))
|
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
2024-01-29 23:08:07 +00:00
|
|
|
install(TARGETS ${t} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2024-01-11 09:06:56 +00:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2022-11-22 19:37:25 +00:00
|
|
|
#--- Test suite
|
2024-01-29 23:08:07 +00:00
|
|
|
if(WIN32 AND (NOT WINDOWS_STORE) AND (NOT (DEFINED XBOX_CONSOLE_TARGET)))
|
|
|
|
include(CTest)
|
|
|
|
if(BUILD_TESTING AND (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Tests/CMakeLists.txt"))
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Tests)
|
|
|
|
elseif(BUILD_FUZZING AND (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Tests/fuzzloaders/CMakeLists.txt"))
|
|
|
|
message(STATUS "Building for fuzzing")
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Tests/fuzzloaders)
|
2024-02-09 19:52:49 +00:00
|
|
|
endif()
|
2022-11-22 19:37:25 +00:00
|
|
|
endif()
|