Skip to content

Commit

Permalink
Fix building C++ client using Cygwin
Browse files Browse the repository at this point in the history
  • Loading branch information
djungelorm committed Jul 11, 2017
1 parent ea26b64 commit f4883cb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 10 deletions.
18 changes: 8 additions & 10 deletions client/cpp/CMakeLists.txt.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8.4)
project(kRPC)
cmake_minimum_required(VERSION 2.8)

set(VERSION_NUMBER %VERSION%)
set(CMAKE_BUILD_TYPE "Release")
Expand All @@ -21,16 +21,10 @@ if(NOT HAVE_ASIO)
endif()
add_definitions(-DASIO_STANDALONE)

if(WIN32)
if(WIN32 OR CYGWIN)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
# set _WIN32_WINNT for ASIO
if (CMAKE_SYSTEM_VERSION)
set(winver ${CMAKE_SYSTEM_VERSION})
string(REPLACE "." "" winver ${winver})
string(REGEX REPLACE "([0-9])" "0\\1" winver ${winver})
set(winver "0x${winver}")
endif()
add_definitions(-D_WIN32_WINNT=${winver})
add_definitions(-D_WIN32_WINNT=0x0501)
add_definitions(-D__USE_W32_SOCKETS)
endif()

if(MSVC)
Expand All @@ -56,6 +50,10 @@ set_target_properties(

target_link_libraries(krpc ${PROTOBUF_LIBRARIES})

if(WIN32 OR CYGWIN)
target_link_libraries(krpc ws2_32 mswsock)
endif()

install(TARGETS krpc
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
Expand Down
37 changes: 37 additions & 0 deletions client/cpp/configure.ac.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
AC_INIT([krpc], [%VERSION%])
AC_SUBST([LT_RELEASE],[%VERSION%])
AM_INIT_AUTOMAKE
AC_CANONICAL_HOST
AC_CONFIG_MACRO_DIR(m4)
AC_PROG_CXX
AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_11(noext, mandatory)
AC_PROG_LIBTOOL
PKG_CHECK_MODULES([protobuf], [protobuf >= 3.3])
AC_DEFINE([ASIO_STANDALONE], [1], [Define ASIO standalone])
case $host in
*-*-linux*)
CXXFLAGS="$CXXFLAGS -pthread"
LDFLAGS="$LDFLAGS -pthread"
;;
*-*-solaris*)
if test "$GXX" = yes; then
CXXFLAGS="$CXXFLAGS -D_PTHREADS"
else
# We'll assume Sun's CC.
CXXFLAGS="$CXXFLAGS -mt"
fi
LIBS="$LIBS -lsocket -lnsl -lpthread"
;;
*-*-mingw32*)
CXXFLAGS="$CXXFLAGS -mthreads"
LDFLAGS="$LDFLAGS -mthreads"
LIBS="$LIBS -lws2_32 -lmswsock"
;;
*-pc-cygwin*)
CXXFLAGS="$CXXFLAGS -D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501"
LIBS="$LIBS -lws2_32 -lmswsock"
;;
*-apple-darwin*)
CXXFLAGS="$CXXFLAGS"
LDFLAGS="$LDFLAGS"
;;
*-*-freebsd*)
CXXFLAGS="$CXXFLAGS -pthread"
LDFLAGS="$LDFLAGS -pthread"
;;
*-*-netbsd*)
CXXFLAGS="$CXXFLAGS -pthread"
LDFLAGS="$LDFLAGS -pthread"
;;
esac
AC_CHECK_HEADER(asio.hpp, , AC_MSG_ERROR([Couldn't find ASIO headers.]))
AC_OUTPUT(Makefile include/Makefile src/Makefile)

0 comments on commit f4883cb

Please sign in to comment.