Closed ahogen closed 10 months ago
Thanks for the bug! The toolchain files were setting MSVC_VERSION themselves, which ends-up by-passing CMake's built-in logic to calculate MSVC_TOOLSET_VERSION. If I remove the logic to set MSVC_VERSION
in the toolchain, then MSVC_VERSION
and MSVC_TOOLSET_VERSION
will be correctly set by CMake. I'll try things out a bit more, and send a PR later.
Ah okay, that makes sense. Not a huge deal for me, given that I was able to use MSVC_VERSION
instead for my little minimum version check.
This may be a different discussion topic, but have you considered using the version=<...>
keys supported by CMake v3.27 CMAKE_GENERATOR_PLATFORM
(or CMake 3.12 CMAKE_GENERATOR_TOOLSET
) variables for the EWDK toolset? I may have come up with a rather simple CMake toolchain file using those extra keys/values.
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2024 Engineering Design Team, Inc.
# Author: Alex Hogen <alex@edt.com>
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}" CACHE INTERNAL "")
set(CMAKE_SYSTEM_VERSION "$ENV{Version_Number}")
set(CMAKE_SYSTEM_VERSION "${CMAKE_SYSTEM_VERSION}" CACHE INTERNAL "")
set(CMAKE_GENERATOR_INSTANCE "$ENV{VSINSTALLDIR}")
set(CMAKE_GENERATOR_INSTANCE "${CMAKE_GENERATOR_INSTANCE}" CACHE INTERNAL "")
set(CMAKE_GENERATOR_PLATFORM "$ENV{VSCMD_ARG_TGT_ARCH},version=$ENV{Version_Number}")
set(CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CACHE INTERNAL "")
set(CMAKE_GENERATOR_TOOLSET "host=$ENV{VSCMD_ARG_HOST_ARCH},version=$ENV{VCToolsVersion}")
set(CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" CACHE INTERNAL "")
# https://cmake.org/cmake/help/v3.15/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.html
set(ENV{CMAKE_WINDOWS_KITS_10_DIR} "$ENV{WindowsSdkDir}")
I've only tested this with the "Visual Studio 16 2019" generator. The CMAKE_GENERATOR_PLATFORM
"version=" in particular seems to help fix some previous issues I've had with CMake's ABI checks failing to find and link to kernel32.lib
.
I'm wondering, has been tried and found to have some issue I haven't run in to yet?
The CMAKE_GENERATOR_PLATFORM
/CMAKE_GENERATOR_TOOLSET
variables only work with Visual Studio generators, which really isn't the purpose of the Toolchain files in this repo.
And from looking at your output, it looks like you're using EWDK environment variables for configuration but finding an installed Visual Studio..? I don't think the Visual Studio Generators work with EWDK build Windows.
Edit: Ah. I suppose you could probably use CMAKE_GENERATOR_INSTANCE
to get the Visual Studio Generator to use the Visual Studio instance in the eWDK.
Fixed by #91.
Using EWDK with Visual Studio 2019 (v16.9.2),
fe_release.20348.1
.Initialized my repo using "Windows.EWDK.toolchain.cmake" toolchain and "Ninja Multi-Config" generator.
I had a check in my CMakeLists.txt ensuring
MSVC_TOOLSET_VERSION
was at least80
(VS 2005), but that CMake variable is unset, so my check fails. I've refactored my minimum version check to useMSVC_VERSION
instead, which works.MSVC_TOOLSET_VERSION
used to be set worked when I used the "Visual Studio 16 2019" generator.Project build scripts were otherwise generated successfully (ty! :grinning:).