mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 06:47:53 +00:00
Fix network MSYS compilation
MSYS/MinGW uses winsock but obviously doesn't set _MSC_VER. Use _WIN32 to decide whether to use winsock or BSD headers. Also remove these headers from src/transport_git.c altogether, as they are not needed. MSYS is very conservative, so we have to tell it that we don't care about versions of Windows lower than WindowsXP. We also need to tell CMake to add ws2_32 to the libraries list and we shouldn't add the -fPIC option, to MSYS because it complains that it does it anyway. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
parent
e1bf24c862
commit
39cdf27280
@ -53,7 +53,10 @@ IF (MSVC)
|
||||
SET(CMAKE_C_FLAGS_DEBUG "/Od /DEBUG /MTd")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "/MT /O2")
|
||||
ELSE ()
|
||||
SET(CMAKE_C_FLAGS "-Wall -Wextra -fPIC")
|
||||
SET(CMAKE_C_FLAGS "-Wall -Wextra")
|
||||
IF (NOT MINGW) # MinGW always does PIC and complains if we tell it to
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
||||
ENDIF ()
|
||||
SET(CMAKE_C_FLAGS_DEBUG "-g -O0")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "-O2")
|
||||
ENDIF()
|
||||
@ -86,6 +89,11 @@ ENDIF ()
|
||||
|
||||
# Compile and link libgit2
|
||||
ADD_LIBRARY(git2 ${SRC} ${SRC_ZLIB})
|
||||
|
||||
IF (WIN32)
|
||||
TARGET_LINK_LIBRARIES(git2 ws2_32)
|
||||
ENDIF ()
|
||||
|
||||
TARGET_LINK_LIBRARIES(git2 ${CMAKE_THREAD_LIBS_INIT})
|
||||
SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING})
|
||||
SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_VERSION_MAJOR})
|
||||
|
@ -23,11 +23,12 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#ifndef _WIN32
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
# include <netdb.h>
|
||||
#else
|
||||
# define _WIN32_WINNT 0x0501
|
||||
# include <winsock2.h>
|
||||
# include <Ws2tcpip.h>
|
||||
# pragma comment(lib, "Ws2_32.lib")
|
||||
|
@ -23,16 +23,6 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
# include <netdb.h>
|
||||
#else
|
||||
# include <winsock2.h>
|
||||
# include <Ws2tcpip.h>
|
||||
# pragma comment(lib, "Ws2_32.lib")
|
||||
#endif
|
||||
|
||||
#include "git2/net.h"
|
||||
#include "git2/pkt.h"
|
||||
#include "git2/common.h"
|
||||
|
Loading…
Reference in New Issue
Block a user