mirror of https://github.com/aria2/aria2
fix windows io headers
parent
731aec33db
commit
549d8ffea1
|
@ -11,12 +11,13 @@ project(
|
|||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
|
||||
|
||||
# ####### Set compiler flags ########
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||
set(CMAKE_C_STANDARD_REQUIRED true)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_C_EXTENSIONS OFF)
|
||||
|
||||
#include(GenerateExportHeader)
|
||||
include(GenerateConfigH)
|
||||
|
||||
config_h_add_compile_definitions(PACKAGE="${PROJECT_NAME}")
|
||||
|
@ -83,6 +84,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|||
add_compile_definitions(NOMINMAX)
|
||||
config_h_add_compile_macro("__restrict__ __restrict")
|
||||
config_h_add_compile_macro("__attribute__(unused) /*Empty*/")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT MINGW)
|
||||
|
@ -262,9 +264,10 @@ if(WIN32)
|
|||
ws2tcpip.h
|
||||
mmsystem.h
|
||||
io.h
|
||||
iphlpapi.
|
||||
iphlpapi.h
|
||||
winioctl.h
|
||||
share.h
|
||||
sys/utime.h
|
||||
)
|
||||
|
||||
foreach(header ${_check_headers})
|
||||
|
@ -283,6 +286,15 @@ if(WIN32)
|
|||
|
||||
unset(_check_headers)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# Cake can't find them but they absolutly exist
|
||||
set(HAVE_IPHLPAPI_H true)
|
||||
set(HAVE_WINIOCTL_H true)
|
||||
config_h_add_compile_definitions(HAVE_IPHLPAPI_H)
|
||||
config_h_add_compile_definitions(HAVE_WINIOCTL_H)
|
||||
|
||||
endif()
|
||||
|
||||
else()
|
||||
set(WIN_BUILD no)
|
||||
endif()
|
||||
|
|
|
@ -18,7 +18,9 @@ function(config_h_generate_header name)
|
|||
set(${def_name}_config_h_val "${${def_name}}")
|
||||
string(REPLACE "yes" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||
string(REPLACE "ON" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||
string(REPLACE "on" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||
string(REPLACE "TRUE" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||
string(REPLACE "true" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||
endif()
|
||||
write_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in "#define ${def_name} @${def_name}_config_h_val@\n" APPEND)
|
||||
endforeach()
|
||||
|
|
|
@ -81,7 +81,7 @@ int BufferedFile::onClose()
|
|||
int rv = 0;
|
||||
if (fp_) {
|
||||
fflush(fp_);
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
#if defined(__MINGW32__)
|
||||
fsync(fileno(fp_));
|
||||
#else // __MINGW32__
|
||||
_commit(fileno(fp_));
|
||||
|
|
|
@ -36,8 +36,9 @@
|
|||
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
# include <getopt.h>
|
||||
#endif
|
||||
#include <getopt.h>
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
|
|
|
@ -54,6 +54,15 @@
|
|||
#include "LogFactory.h"
|
||||
#include "fmt.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
|
||||
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
# endif
|
||||
# if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
File::File(const std::string& name) : name_(name) {}
|
||||
|
|
|
@ -54,6 +54,9 @@
|
|||
#ifdef HAVE_SHARE_H
|
||||
# include <share.h>
|
||||
#endif // HAVE_SHARE_H
|
||||
#ifdef HAVE_SYS_UTIME_H
|
||||
# include <sys/utime.h>
|
||||
#endif
|
||||
|
||||
// in some platforms following definitions are missing:
|
||||
#ifndef EINPROGRESS
|
||||
|
|
Loading…
Reference in New Issue