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-03-18 20:51:50 +00:00
|
|
|
cmake_minimum_required (VERSION 3.13)
|
2019-11-15 08:39:50 +00:00
|
|
|
|
2021-11-17 22:59:35 +00:00
|
|
|
set(DIRECTXTEX_VERSION 1.9.5)
|
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)
|
|
|
|
|
2022-03-28 00:29:48 +00:00
|
|
|
option(BUILD_SAMPLE "Build DDSView sample" ON)
|
|
|
|
|
2021-01-01 21:36:40 +00:00
|
|
|
# Includes the functions for Direct3D 11 resources and DirectCompute compression
|
2019-12-14 01:30:01 +00:00
|
|
|
option(BUILD_DX11 "Build with DirectX11 Runtime support" ON)
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
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)
|
|
|
|
|
2020-12-19 02:44:47 +00:00
|
|
|
# Includes the functions for loading/saving OpenEXR files at runtime
|
|
|
|
# NOTE requires adding DirectXTexEXR.h/.cpp source files (vcpkg does this automatically)
|
|
|
|
option(ENABLE_OPENEXR_SUPPORT "Build with OpenEXR 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)
|
|
|
|
|
2020-08-11 03:04:44 +00: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-07-12 07:40:57 +00:00
|
|
|
|
2022-03-19 05:05:23 +00:00
|
|
|
if (DEFINED VCPKG_TARGET_ARCHITECTURE)
|
|
|
|
set(DIRECTX_ARCH ${VCPKG_TARGET_ARCHITECTURE})
|
2022-03-23 23:52:58 +00: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 05:05:23 +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)
|
|
|
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
|
|
|
DirectXTex/DirectXTexFlipRotate.cpp
|
|
|
|
DirectXTex/DirectXTexWIC.cpp)
|
|
|
|
endif()
|
2019-12-14 01:30:01 +00:00
|
|
|
|
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)
|
2021-01-01 21:36:40 +00:00
|
|
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
|
|
|
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)
|
2021-01-01 21:36:40 +00:00
|
|
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
|
|
|
DirectXTex/d3dx12.h
|
|
|
|
DirectXTex/DirectXTexD3D12.cpp)
|
2019-12-14 01:30:01 +00:00
|
|
|
endif()
|
|
|
|
|
2020-12-19 02:44:47 +00:00
|
|
|
if(ENABLE_OPENEXR_SUPPORT)
|
|
|
|
set(LIBRARY_HEADERS ${LIBRARY_HEADERS}
|
|
|
|
DirectXTex/DirectXTexEXR.h)
|
|
|
|
|
|
|
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
|
|
|
DirectXTex/DirectXTexEXR.h
|
|
|
|
DirectXTex/DirectXTexEXR.cpp)
|
|
|
|
endif()
|
|
|
|
|
2021-01-08 10:20:55 +00:00
|
|
|
if(BUILD_DX11 AND WIN32)
|
2021-10-07 06:14:26 +00: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 07:10:30 +00:00
|
|
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
2021-10-07 06:14:26 +00:00
|
|
|
${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc)
|
|
|
|
|
|
|
|
if (NOT USE_PREBUILT_SHADERS)
|
|
|
|
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..."
|
|
|
|
COMMAND set CompileShadersOutput=${COMPILED_SHADERS}
|
2022-05-04 06:44:20 +00:00
|
|
|
COMMAND 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
|
|
|
|
2020-12-19 02:44:47 +00:00
|
|
|
if(ENABLE_OPENEXR_SUPPORT)
|
2021-01-10 18:50:24 +00:00
|
|
|
find_package(OpenEXR REQUIRED)
|
2020-12-19 02:44:47 +00:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENEXR_INCLUDE_DIRS}/OpenEXR)
|
|
|
|
endif()
|
|
|
|
|
2020-03-29 22:09:59 +00:00
|
|
|
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
|
|
|
|
target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXTex/DirectXTexP.h)
|
|
|
|
endif()
|
2020-03-29 19:49:11 +00:00
|
|
|
|
2019-12-02 18:52:27 +00:00
|
|
|
if(MSVC)
|
2020-12-18 23:28:28 +00:00
|
|
|
# Use max Warning Level
|
2019-12-02 18:52:27 +00: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})
|
|
|
|
|
|
|
|
# Not using typeid or dynamic_cast, so disable RTTI to save binary size
|
|
|
|
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
|
|
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
|
|
|
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
|
|
|
endif()
|
2019-11-18 02:24:19 +00:00
|
|
|
|
2021-02-04 07:21:08 +00:00
|
|
|
if ((NOT WIN32) OR VCPKG_TOOLCHAIN)
|
|
|
|
message("INFO: Using VCPKG for DirectX-Headers and DirectXMath.")
|
2021-01-08 10:20:55 +00:00
|
|
|
find_package(directx-headers CONFIG REQUIRED)
|
|
|
|
find_package(directxmath CONFIG REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectX-Headers Microsoft::DirectXMath)
|
2021-05-12 05:42:41 +00:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS)
|
2021-01-08 10:20:55 +00:00
|
|
|
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
|
|
|
|
|
|
|
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/.nuget/${PROJECT_NAME}-config.cmake.in
|
2022-05-02 10:01:40 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
|
|
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}/cmake/)
|
2020-12-18 23:28:28 +00:00
|
|
|
|
|
|
|
install(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
FILE ${PROJECT_NAME}-targets.cmake
|
|
|
|
NAMESPACE Microsoft::
|
2022-05-02 10:01:40 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}/cmake/)
|
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
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}/cmake/)
|
2020-12-18 23:28:28 +00:00
|
|
|
|
|
|
|
#--- Command-line tools
|
2021-01-14 07:10:06 +00:00
|
|
|
if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE))
|
2022-03-23 23:52:58 +00:00
|
|
|
set(TOOL_EXES texassemble texconv texdiag)
|
|
|
|
|
2020-12-19 02:05:07 +00:00
|
|
|
add_executable(texassemble
|
2020-07-01 08:37:13 +00:00
|
|
|
Texassemble/texassemble.cpp
|
|
|
|
Texassemble/AnimatedGif.cpp)
|
2021-01-14 07:10:06 +00:00
|
|
|
target_link_libraries(texassemble ${PROJECT_NAME} ole32.lib version.lib)
|
2020-12-19 02:05:07 +00:00
|
|
|
source_group(texassemble REGULAR_EXPRESSION Texassemble/*.*)
|
2019-07-12 07:40:57 +00:00
|
|
|
|
2020-12-19 02:05:07 +00:00
|
|
|
add_executable(texconv
|
2020-06-05 03:07:21 +00:00
|
|
|
Texconv/texconv.cpp
|
|
|
|
Texconv/ExtendedBMP.cpp
|
|
|
|
Texconv/PortablePixMap.cpp)
|
2021-01-14 07:10:06 +00:00
|
|
|
target_link_libraries(texconv ${PROJECT_NAME} ole32.lib shell32.lib version.lib)
|
2020-12-19 02:05:07 +00:00
|
|
|
source_group(texconv REGULAR_EXPRESSION Texconv/*.*)
|
2019-07-12 07:40:57 +00:00
|
|
|
|
2020-12-19 02:05:07 +00:00
|
|
|
add_executable(texdiag Texdiag/texdiag.cpp)
|
2021-01-14 07:10:06 +00:00
|
|
|
target_link_libraries(texdiag ${PROJECT_NAME} ole32.lib version.lib)
|
2020-12-19 02:05:07 +00:00
|
|
|
source_group(texdiag REGULAR_EXPRESSION Texdiag/*.*)
|
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)
|
|
|
|
target_link_libraries(${t} ${OPENEXR_ILMIMF_LIBRARY})
|
|
|
|
target_compile_options(${t} PRIVATE -DUSE_OPENEXR)
|
|
|
|
endforeach()
|
2020-12-19 02:44:47 +00:00
|
|
|
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
|
2022-03-28 00:32:51 +00:00
|
|
|
if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32 AND (NOT WINDOWS_STORE))
|
2022-03-28 00:29:48 +00:00
|
|
|
list(APPEND TOOL_EXES ddsview)
|
|
|
|
|
|
|
|
add_executable(ddsview WIN32
|
|
|
|
DDSView/ddsview.cpp
|
2022-03-28 06:03:24 +00:00
|
|
|
DDSView/ddsview.rc
|
|
|
|
${COMPILED_SHADERS}/ddsview_ps1D.inc)
|
2022-03-28 00:29:48 +00:00
|
|
|
target_link_libraries(ddsview ${PROJECT_NAME} d3d11.lib)
|
|
|
|
source_group(ddsview REGULAR_EXPRESSION DDSView/*.*)
|
2022-03-28 06:03:24 +00:00
|
|
|
|
|
|
|
target_include_directories(ddsview PRIVATE ${COMPILED_SHADERS})
|
|
|
|
|
|
|
|
if (NOT USE_PREBUILT_SHADERS)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${COMPILED_SHADERS}/ddsview_ps1D.inc"
|
|
|
|
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DDSView/hlsl.cmd"
|
|
|
|
DEPENDS "${PROJECT_SOURCE_DIR}/DDSView/ddsview.fx"
|
|
|
|
COMMENT "Generating HLSL shaders for DDSView..."
|
|
|
|
COMMAND set CompileShadersOutput=${COMPILED_SHADERS}
|
2022-05-04 06:44:20 +00:00
|
|
|
COMMAND hlsl.cmd > ${COMPILED_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()
|
|
|
|
|
2022-05-04 06:44:20 +00:00
|
|
|
if ((NOT WIN32) OR VCPKG_TOOLCHAIN)
|
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_link_libraries(${t} Microsoft::DirectXMath)
|
|
|
|
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})
|
|
|
|
target_compile_options(${t} PRIVATE /fp:fast "$<$<NOT:$<CONFIG:DEBUG>>:/guard:cf>")
|
2022-03-24 00:29:20 +00:00
|
|
|
target_link_options(${t} PRIVATE /DYNAMICBASE /NXCOMPAT)
|
2022-03-23 23:52:58 +00:00
|
|
|
endforeach()
|
2019-12-02 18:52:27 +00:00
|
|
|
|
2022-05-04 06:44:20 +00:00
|
|
|
if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "^arm"))
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /arch:SSE2)
|
|
|
|
target_link_options(${t} PRIVATE /SAFESEH)
|
|
|
|
endforeach()
|
2019-12-02 18:52:27 +00:00
|
|
|
endif()
|
2019-11-15 08:39:50 +00:00
|
|
|
endif()
|
2019-07-12 07:40:57 +00:00
|
|
|
|
2021-01-08 10:20:55 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2019-11-15 08:39:50 +00:00
|
|
|
set(WarningsLib "-Wpedantic" "-Wextra")
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
|
|
|
|
|
2019-12-14 06:26:18 +00:00
|
|
|
# OpenMP is not supported for clang for Windows by default
|
|
|
|
|
2022-03-28 00:29:48 +00:00
|
|
|
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-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()
|
2019-07-12 07:40:57 +00:00
|
|
|
endif()
|
2021-01-08 10:20:55 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2022-05-04 06:44:20 +00:00
|
|
|
target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus)
|
2022-03-23 23:52:58 +00:00
|
|
|
endforeach()
|
2019-11-15 08:39:50 +00:00
|
|
|
|
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})
|
|
|
|
target_compile_options(${t} PRIVATE /analyze)
|
|
|
|
endforeach()
|
2020-12-19 02:05:07 +00:00
|
|
|
endif()
|
2020-06-05 22:01:02 +00:00
|
|
|
|
2022-03-18 20:51:50 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24)
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /ZH:SHA_256)
|
|
|
|
endforeach()
|
2022-03-18 20:51:50 +00:00
|
|
|
endif()
|
|
|
|
|
2020-05-20 03:11:23 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
|
2022-03-23 23:52:58 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /Zc:preprocessor /wd5105)
|
|
|
|
endforeach()
|
2020-05-20 03:11:23 +00:00
|
|
|
endif()
|
|
|
|
|
2022-05-04 06:44:20 +00:00
|
|
|
if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) AND (NOT (${DIRECTX_ARCH} MATCHES "^arm")))
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2022-03-23 23:52:58 +00:00
|
|
|
target_link_options(${t} PRIVATE /CETCOMPAT)
|
|
|
|
endforeach()
|
2022-03-18 20:51:50 +00:00
|
|
|
endif()
|
|
|
|
|
2020-06-05 22:01:02 +00:00
|
|
|
if(BC_USE_OPENMP)
|
2019-12-14 06:26:18 +00:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE /openmp /Zc:twoPhase-)
|
2021-01-14 07:10:06 +00:00
|
|
|
if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE))
|
2020-12-19 02:05:07 +00:00
|
|
|
target_compile_options(texconv PRIVATE /openmp /Zc:twoPhase-)
|
|
|
|
endif()
|
2019-12-14 06:26:18 +00:00
|
|
|
endif()
|
|
|
|
|
2022-03-23 23:52:58 +00:00
|
|
|
set(WarningsEXE "/wd4061" "/wd4062" "/wd4365" "/wd4514" "/wd4625" "/wd4626" "/wd4627" "/wd4668" "/wd4710" "/wd4751" "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd5219")
|
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_compile_options(${t} PRIVATE ${WarningsEXE})
|
|
|
|
endforeach()
|
2019-07-12 07:40:57 +00:00
|
|
|
endif()
|
|
|
|
|
2019-12-12 00:19:23 +00:00
|
|
|
if(WIN32)
|
2022-05-04 06:44:20 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_definitions(${t} PRIVATE _UNICODE UNICODE)
|
2022-03-23 23:52:58 +00:00
|
|
|
endforeach()
|
2019-12-14 01:30:01 +00:00
|
|
|
|
2022-03-02 10:16:46 +00:00
|
|
|
if(WINDOWS_STORE)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE WINAPI_FAMILY=WINAPI_FAMILY_APP)
|
|
|
|
endif()
|
|
|
|
|
2020-12-24 20:59:19 +00:00
|
|
|
if(BUILD_DX12 OR WINDOWS_STORE)
|
2022-01-25 10:11:59 +00:00
|
|
|
if(BUILD_DX12)
|
|
|
|
message("INFO: Building with DirectX 12 Runtime support")
|
|
|
|
endif()
|
2019-12-14 01:30:01 +00:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0A00)
|
|
|
|
else()
|
2022-01-25 10:11:59 +00:00
|
|
|
message("INFO: Building with Windows 7 compatibility")
|
2022-04-21 07:45:19 +00:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0601 _WIN7_PLATFORM_UPDATE)
|
2019-12-14 01:30:01 +00:00
|
|
|
endif()
|
2022-05-04 06:44:20 +00:00
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_compile_definitions(${t} PRIVATE _WIN32_WINNT=0x0601)
|
|
|
|
endforeach()
|
2019-12-12 00:19:23 +00:00
|
|
|
endif()
|
2020-08-11 03:54:31 +00:00
|
|
|
|
2021-01-14 07:10:06 +00:00
|
|
|
if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE))
|
2020-12-19 02:05:07 +00:00
|
|
|
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT texconv)
|
|
|
|
endif()
|