From c4bb6b79ea36c05ccfe3033174a7950ac6a51609 Mon Sep 17 00:00:00 2001 From: Pierre Wendling Date: Tue, 12 Sep 2023 18:33:46 +0200 Subject: [PATCH] MSVC: Enable building ocspcheck. - Add `STDIN_FILENO` to compat unistd header. - Use quotes to include compat getopt header in the compat unistd. - Export additional symbols needed by ocspcheck (optarg, optind, ftruncate) --- apps/ocspcheck/CMakeLists.txt | 4 ---- crypto/CMakeLists.txt | 2 ++ include/compat/unistd.h | 3 ++- tls/CMakeLists.txt | 2 ++ 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/ocspcheck/CMakeLists.txt b/apps/ocspcheck/CMakeLists.txt index 43eebdf466..9cf7a8b318 100644 --- a/apps/ocspcheck/CMakeLists.txt +++ b/apps/ocspcheck/CMakeLists.txt @@ -1,5 +1,3 @@ -if(NOT MSVC) - set( OCSPCHECK_SRC http.c @@ -33,5 +31,3 @@ if(ENABLE_LIBRESSL_INSTALL) install(FILES ocspcheck.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8) endif(ENABLE_LIBRESSL_INSTALL) - -endif() diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 6ff46c8cbb..d61e607ccf 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -778,6 +778,8 @@ endif() if(NOT HAVE_GETOPT) set(CRYPTO_SRC ${CRYPTO_SRC} compat/getopt_long.c) set(EXTRA_EXPORT ${EXTRA_EXPORT} getopt) + set(EXTRA_EXPORT ${EXTRA_EXPORT} optarg) + set(EXTRA_EXPORT ${EXTRA_EXPORT} optind) endif() if(NOT HAVE_GETPAGESIZE) diff --git a/include/compat/unistd.h b/include/compat/unistd.h index 2583a6eae3..63c07fc3dc 100644 --- a/include/compat/unistd.h +++ b/include/compat/unistd.h @@ -23,6 +23,7 @@ ssize_t pwrite(int d, const void *buf, size_t nbytes, off_t offset); #include #include +#define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 @@ -65,7 +66,7 @@ int getentropy(void *buf, size_t buflen); #endif #ifndef HAVE_GETOPT -#include +#include "getopt.h" #endif #ifndef HAVE_GETPAGESIZE diff --git a/tls/CMakeLists.txt b/tls/CMakeLists.txt index 59deee3662..4beef36ea9 100644 --- a/tls/CMakeLists.txt +++ b/tls/CMakeLists.txt @@ -22,6 +22,8 @@ if(WIN32) compat/pread.c compat/pwrite.c ) + + set(LIBTLS_EXTRA_EXPORT ${LIBTLS_EXTRA_EXPORT} ftruncate) endif() if(NOT "${OPENSSLDIR}" STREQUAL "")