fix build error on windows

This commit is contained in:
cuijg 2021-10-31 05:58:00 +08:00
parent 05f3f844bb
commit d0eb946e57
6 changed files with 927 additions and 909 deletions

View File

@ -85,6 +85,10 @@ ELSE ()
MESSAGE(STATUS "================ ERROR: This platform is unsupported!!! ================")
ENDIF (UNIX)
IF (WIN32)
add_definitions(-DNOMINMAX)
ENDIF ()
#-------------------------------------------------------------
set(TARS2CPP "${CMAKE_BINARY_DIR}/bin/tars2cpp")

View File

@ -47,6 +47,9 @@ set(LIB_SSL)
set(LIB_CRYPTO)
set(LIB_PROTOBUF)
set(LIB_GTEST)
set(LIB_GPERF)
set(LIB_TCMALLOC_PROFILER)
set(LIB_TCMALLOC_MINIMAL)
#-------------------------------------------------------------
add_custom_target(thirdparty)
@ -55,21 +58,23 @@ include(ExternalProject)
if (TARS_GPERF)
set(GPERF_DIR_INC "${THIRDPARTY_PATH}/gpref/include")
set(GRPEF_DIR_LIB "${THIRDPARTY_PATH}/gpref/lib")
set(GPERF_DIR_INC "${THIRDPARTY_PATH}/gperf/include")
set(GRPEF_DIR_LIB "${THIRDPARTY_PATH}/gperf/lib")
include_directories(${GPERF_DIR_INC})
link_directories(${GRPEF_DIR_LIB})
if (UNIX)
set(LIB_GPERF "profiler")
set(LIB_TCMALLOC_PROFILER "tcmalloc_and_profiler")
set(LIB_TCMALLOC_MINIMAL "tcmalloc_and_minimal")
ExternalProject_Add(ADD_${LIB_GPERF}
URL https://tars-thirdpart-1300910346.cos.ap-guangzhou.myqcloud.com//src/gperftools-2.7.tar.gz
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/src/gpref --disable-shared --disable-debugalloc
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gpref-lib
CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/src/gperf --disable-shared --disable-debugalloc
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gperf-lib
BUILD_IN_SOURCE 1
BUILD_COMMAND make
# INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install
@ -78,11 +83,11 @@ if (TARS_GPERF)
add_dependencies(thirdparty ADD_${LIB_GPERF})
INSTALL(FILES ${CMAKE_BINARY_DIR}/src/gpref/bin/pprof
INSTALL(FILES ${CMAKE_BINARY_DIR}/src/gperf/bin/pprof
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
DESTINATION thirdparty/bin/)
INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/src/gpref/lib DESTINATION thirdparty)
INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/src/gpref/include/gperftools DESTINATION thirdparty/include)
INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/src/gperf/lib DESTINATION thirdparty)
INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/src/gperf/include/gperftools DESTINATION thirdparty/include)
endif (UNIX)
@ -213,7 +218,7 @@ if (TARS_SSL)
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND perl Configure --prefix=${CMAKE_BINARY_DIR}/src/openssl VC-WIN64A no-asm
CONFIGURE_COMMAND perl Configure --prefix=${CMAKE_BINARY_DIR}/src/openssl --openssldir=ssl VC-WIN64A no-asm
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/openssl-lib
BUILD_IN_SOURCE 1
BUILD_COMMAND nmake
@ -229,7 +234,7 @@ if (TARS_SSL)
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
PREFIX ${CMAKE_BINARY_DIR}
INSTALL_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND ./config --prefix=${CMAKE_BINARY_DIR}/src/openssl no-shared
CONFIGURE_COMMAND ./config --prefix=${CMAKE_BINARY_DIR}/src/openssl --openssldir=ssl no-shared
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/openssl-lib
BUILD_IN_SOURCE 1
BUILD_COMMAND make

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.2)
project(tools)
include_directories(${util_SOURCE_DIR}/include)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.2)
project(util)
if(WIN32)

View File

@ -49,6 +49,14 @@
using namespace std;
#if TARGET_PLATFORM_WINDOWS
#ifndef ssize_t
#define ssize_t __int64
#endif
#endif
namespace tars
{
/////////////////////////////////////////////////

View File

@ -618,7 +618,8 @@ int epoll_wait(epoll_t port_handle, struct epoll_event *events, int maxevents, i
OVERLAPPED_ENTRY entries[64];
/* Compute how much overlapped entries can be dequeued at most. */
DWORD max_entries = min(ARRAY_COUNT(entries), maxevents);
int tmp_count = ARRAY_COUNT(entries);
DWORD max_entries = min(tmp_count, maxevents);
ULONG count = 0;
DWORD result = GetQueuedCompletionStatusEx(port_data->getHandle(), entries, max_entries, &count, gqcs_timeout, TRUE);