Skip to content

Regression: DirectXTK no longer is able to generate project using certain configurations #508

Open
@joshuamaiche

Description

Summary

Previously, DirectXTK supported clang-cl in visual studio, using CMake with CMakePresets.json. Now, the project can't be generated due to a missing symbol (DIRECTX_ARCH).

Setup

Folder Structure

repro_folder
  - CMakePresets.json
  - CMakeLists.txt

CMakePresets.json

{
    "version": 4,

    "configurePresets": [
        {
            "name": "msvc",
            "displayName": "MSVC",
            "cacheVariables": { "CMAKE_CXX_COMPILER": "cl.exe" },
            "architecture": { "value": "x64", "strategy": "external" }
        },
        {
            "name": "clang",
            "displayName": "Clang",
            "cacheVariables": { "CMAKE_CXX_COMPILER": "clang-cl" },
            "architecture": { "value": "x64", "strategy": "external" }
        }
    ]
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.24)

include(FetchContent)

project(repro LANGUAGES CXX)

FetchContent_Declare(
    DirectXTK
    GIT_REPOSITORY https://github.com/Microsoft/DirectXTK.git
    GIT_TAG main
    OVERRIDE_FIND_PACKAGE
)

FetchContent_MakeAvailable(DirectXTK)

Repro

  • Ensure Visual Studio is using presets.json (Tools > Options > CMake > General >CMake configuration file: > Always use CMake Presets)
  • Open Visual Studio
  • Select Open a local folder
  • Open repro_folder
  • Select MSVC configuration. Generate project (can be triggered by re-saving CMakeLists.txt). Notice the generation succeeds.
  • Select Clang configuration. Generate project. Notice the generation fails.

Error message

1> [CMake] CMake Error at out/build/clang/_deps/directxtk-src/build/CompilerAndLinker.cmake:215 (if):
1> [CMake]   if given arguments:
1> [CMake] 
1> [CMake]     "STREQUAL" "x64"
1> [CMake] 
1> [CMake]   Unknown arguments specified
1> [CMake] Call Stack (most recent call first):
1> [CMake]   out/build/clang/_deps/directxtk-src/CMakeLists.txt:66 (include)
1> [CMake] -- Configuring incomplete, errors occurred!

Misc

This error is caused by DIRECTX_ARCH not being set. When debugging why, I saw that with the Clang configuration, both CMAKE_GENERATOR_PLATFORM and CMAKE_VS_PLATFORM_NAME_DEFAULT seem to be blank. This regression was introduced when the code coverage change was added a month ago (270d2e7). Using a prior commit allows the project to be generated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions