Skip to content

Commit

Permalink
cmake: enable more detection on Windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vszakats committed Oct 11, 2022
1 parent 2302983 commit 474a947
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 0 additions & 3 deletions CMake/Platforms/WindowsCache.cmake
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -1293,6 +1293,8 @@ if(WIN32)

if(NOT HAVE_MINGW_ORIGINAL)
list(APPEND CURL_LIBS "bcrypt")
else()
set(HAVE_FTRUNCATE OFF)
endif()
endif()

Expand Down

0 comments on commit 474a947

Please sign in to comment.