Skip to content

[cmake] Fix win x64 and arm64 detection in cmake#675

Merged
opdenkamp merged 2 commits intoPulse-Eight:masterfrom
fuzzard:fix_win-x64_detection
Mar 5, 2025
Merged

[cmake] Fix win x64 and arm64 detection in cmake#675
opdenkamp merged 2 commits intoPulse-Eight:masterfrom
fuzzard:fix_win-x64_detection

Conversation

@fuzzard
Copy link

@fuzzard fuzzard commented Mar 1, 2025

Kodi has been patching the use of _USE_32BIT_TIME_T for long before i started getting involved in the project.

As im wanting to reduce the patching we do, i wanted to work out what the root cause of the following errors we get when building libcec for x86_64

14:06:19 C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt.h(634,1): error C1189: #error:  You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64 [C:\jenkws\workspace\WIN-64\kodi-build.x64\build\cec\src\cec-build\src\libcec\cec.vcxproj] [C:\jenkws\workspace\WIN-64\kodi-build.x64\cec.vcxproj]
14:06:19     (compiling source file '../../../cec/src/libcec/CECProcessor.cpp')
14:06:19     
14:06:19 C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt.h(634,1): error C1189: #error:  You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64 [C:\jenkws\workspace\WIN-64\kodi-build.x64\build\cec\src\cec-build\src\libcec\cec.vcxproj] [C:\jenkws\workspace\WIN-64\kodi-build.x64\cec.vcxproj]
14:06:19     (compiling source file '../../../cec/src/libcec/CECClient.cpp')

The root cause is check_symbol_exists for the symbol X64 is not valid (since at least win7 sdk as far as i could tell) in Windows.h. Checks libcec use then rely on WIN64 being set, but it is not.
Change to use AMD64, that is used to define an x86_64 symbol in Windows.h for the WIN64 variable, and then dont use the value of it for the tests.

the ARM64 changes recently also dont work correctly in cmake.
_M_ARM64 is a compile definition that VS sets/uses for arm64 platform, however this does not mean anything to cmake, and therefore is always false.
Introduce a check_symbol_exists call for ARM64 for it to be used to properly show libcec is building for arm64 target.

cec-client and cecc-client dont explicitly use CheckPlatformSupport.cmake, so ive added their check_symbol_exists explicitly.

fuzzard added 2 commits March 1, 2025 17:22
Windows SDK's dont look like they have _X64_ defined in Windows.h.
I checked back until win 7 sdk's. They all do have _AMD64_ that says
it is x86_64.
Remove the unnecessary symbol check for _X64_ and rename the output of
_AMD64_ to WIN64.

Kodi was patching _USE_32BIT_TIME_T to avoid the following errors when
building for x86_64. Time to properly fix the root cause

14:06:19 C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt.h(634,1): error C1189: #error:  You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64 [C:\jenkws\workspace\WIN-64\kodi-build.x64\build\cec\src\cec-build\src\libcec\cec.vcxproj] [C:\jenkws\workspace\WIN-64\kodi-build.x64\cec.vcxproj]
14:06:19     (compiling source file '../../../cec/src/libcec/CECProcessor.cpp')
14:06:19
14:06:19 C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt.h(634,1): error C1189: #error:  You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64 [C:\jenkws\workspace\WIN-64\kodi-build.x64\build\cec\src\cec-build\src\libcec\cec.vcxproj] [C:\jenkws\workspace\WIN-64\kodi-build.x64\cec.vcxproj]
14:06:19     (compiling source file '../../../cec/src/libcec/CECClient.cpp')
_M_ARM64 is a compile definition used by VS. Its not known to cmake,
therefore it isnt suitable to be used as a check.

Use a check_symbol_exists just like x86_64 and use an ARM64 variable
to appropriately define arm64 platform in cmake
@opdenkamp opdenkamp merged commit 842852d into Pulse-Eight:master Mar 5, 2025
@fuzzard fuzzard deleted the fix_win-x64_detection branch March 5, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants