From 474a947e661abe1cdc752866e4f148c0db7ef571 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 11 Oct 2022 07:52:32 +0000 Subject: [PATCH] cmake: enable more detection on Windows Enable `HAVE_UNISTD_H`, `HAVE_STRTOK_R` and `HAVE_STRCASECMP` detection on Windows, instead of having predefined values. With these features detected correctly, CMake Windows builds get closer to the autotools and `config-win32.h` ones. This also fixes detecting `HAVE_FTRUNCATE` correctly, which required `unistd.h`. Fixing `ftruncate()` in turn causes a build warning/error with legacy MinGW/MSYS1 due to an offset type size mismatch. This env misses to detect `HAVE_FILE_OFFSET_BITS`, which may be a reason. This patch force-disables `HAVE_FTRUNCATE` for this platform. Reviewed-by: Daniel Stenberg Closes #9687 --- CMake/Platforms/WindowsCache.cmake | 3 --- CMakeLists.txt | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMake/Platforms/WindowsCache.cmake b/CMake/Platforms/WindowsCache.cmake index e056ad0d9e76fc..d6dc5a0fa82896 100644 --- a/CMake/Platforms/WindowsCache.cmake +++ b/CMake/Platforms/WindowsCache.cmake @@ -54,14 +54,11 @@ if(NOT UNIX) set(HAVE_TERMIOS_H 0) set(HAVE_TERMIO_H 0) set(HAVE_TIME_H 1) - set(HAVE_UNISTD_H 0) set(HAVE_UTIME_H 0) set(HAVE_SOCKET 1) set(HAVE_SELECT 1) set(HAVE_STRDUP 1) - set(HAVE_STRTOK_R 0) - set(HAVE_STRCASECMP 0) set(HAVE_STRICMP 1) set(HAVE_STRCMPI 1) set(HAVE_GETTIMEOFDAY 0) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d11fc593530a7..156fe790392dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1293,6 +1293,8 @@ if(WIN32) if(NOT HAVE_MINGW_ORIGINAL) list(APPEND CURL_LIBS "bcrypt") + else() + set(HAVE_FTRUNCATE OFF) endif() endif()