From 32d41a98fdd438927131cc1f40edde38d28be2df Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 9 Feb 2023 18:54:37 -0800 Subject: [PATCH] CMake code review (#102) --- CMakeLists.txt | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2599383..19c8d88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,15 +131,23 @@ if(NOT MINGW) target_precompile_headers(${PROJECT_NAME} PRIVATE UVAtlas/pch.h) endif() -if(MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) +if(MINGW OR (NOT WIN32)) 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) - find_package(directx-headers CONFIG REQUIRED) - target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers) - target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS) - endif() +if(directxmath_FOUND) + message(STATUS "Using DirectXMath package") + target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectXMath) +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() if(ENABLE_USE_EIGEN) @@ -187,7 +195,7 @@ install(FILES if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE)) set(TOOL_EXES uvatlastool) - message(STATUS "Using VCPKG for DirectXMesh and DirectXTex (required for uvatlastool).") + message(STATUS "Using DirectXMesh and DirectXTex (required for uvatlastool).") find_package(directxmesh CONFIG REQUIRED COMPONENTS library utils) find_package(directxtex CONFIG REQUIRED) @@ -206,7 +214,7 @@ if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE)) Microsoft::DirectXMesh::Utilities) source_group(uvatlastool REGULAR_EXPRESSION UVAtlasTool/*.*) - if(MINGW OR VCPKG_TOOLCHAIN) + if(directxmath_FOUND) target_link_libraries(uvatlastool Microsoft::DirectXMath) endif() endif() @@ -329,7 +337,7 @@ if(WIN32) target_compile_definitions(${PROJECT_NAME} PRIVATE WINAPI_FAMILY=WINAPI_FAMILY_APP) endif() - if(WINDOWS_STORE OR (${DIRECTX_ARCH} MATCHES "^arm64") OR VCPKG_TARGET_IS_XBOX) + if(WINDOWS_STORE OR (${DIRECTX_ARCH} MATCHES "^arm64") OR (DEFINED XBOX_CONSOLE_TARGET)) set(WINVER 0x0A00) elseif(${DIRECTX_ARCH} MATCHES "^arm") set(WINVER 0x0602)