CMake code review (#318)

This commit is contained in:
Chuck Walbourn 2023-02-09 21:58:13 -08:00 committed by GitHub
parent 4c277982ed
commit 5b06df54e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,9 +56,9 @@ elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$")
set(DIRECTX_ARCH arm64) set(DIRECTX_ARCH arm64)
endif() endif()
if(VCPKG_TARGET_IS_XBOX) if(DEFINED XBOX_CONSOLE_TARGET)
set(BUILD_DX11 OFF) set(BUILD_DX11 OFF)
set(BUILD_DX12 ON) set(BUILD_DX12 ON)
endif() endif()
include(GNUInstallDirs) include(GNUInstallDirs)
@ -171,15 +171,23 @@ if(NOT MINGW)
target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXTex/DirectXTexP.h) target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXTex/DirectXTexP.h)
endif() endif()
if(MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) if(MINGW OR (NOT WIN32))
find_package(directxmath CONFIG REQUIRED) find_package(directxmath CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectXMath) find_package(directx-headers CONFIG REQUIRED)
else()
find_package(directxmath CONFIG QUIET)
find_package(directx-headers CONFIG QUIET)
endif()
if(NOT VCPKG_TARGET_IS_XBOX) if(directxmath_FOUND)
find_package(directx-headers CONFIG REQUIRED) message(STATUS "Using DirectXMath package")
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers) target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectXMath)
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS) endif()
endif()
if(directx-headers_FOUND)
message(STATUS "Using DirectX-Headers package")
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS)
endif() endif()
#--- Package #--- Package
@ -284,7 +292,7 @@ if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32 AND (NOT WINDOWS_STORE))
endif() endif()
endif() endif()
if(MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) if(directxmath_FOUND)
foreach(t IN LISTS TOOL_EXES) foreach(t IN LISTS TOOL_EXES)
target_link_libraries(${t} Microsoft::DirectXMath) target_link_libraries(${t} Microsoft::DirectXMath)
endforeach() endforeach()