[Development] Add possibility to build Windows programs with GNUTLS via cmake.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4241 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c08e8b..9d5bff7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -85,6 +85,14 @@
"<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>")
endif()
+# Check for GNUTLS library
+find_package(GnuTLS)
+if(GNUTLS_FOUND)
+ include_directories(${GNUTLS_INCLUDE_DIR})
+ add_definitions("-DHAVE_GNUTLS")
+ add_definitions(${GNUTLS_DEFINITIONS})
+endif()
+
# Generate config.h
include(CheckIncludeFiles)
include(CheckFunctionExists)
diff --git a/common/rdr/CMakeLists.txt b/common/rdr/CMakeLists.txt
index 2872fd7..8be9679 100644
--- a/common/rdr/CMakeLists.txt
+++ b/common/rdr/CMakeLists.txt
@@ -14,4 +14,9 @@
ZlibInStream.cxx
ZlibOutStream.cxx)
-target_link_libraries(rdr zlib os)
+set(RDR_LIBRARIES zlib os)
+if(GNUTLS_FOUND)
+ set(RDR_LIBRARIES ${RDR_LIBRARIES} ${GNUTLS_LIBRARIES})
+endif()
+
+target_link_libraries(rdr ${RDR_LIBRARIES})
diff --git a/common/rfb/CMakeLists.txt b/common/rfb/CMakeLists.txt
index 050d408..b76e86a 100644
--- a/common/rfb/CMakeLists.txt
+++ b/common/rfb/CMakeLists.txt
@@ -1,7 +1,7 @@
include_directories(${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/win
${CMAKE_SOURCE_DIR}/common/jpeg ${CMAKE_SOURCE_DIR}/common/jpeg/win)
-add_library(rfb STATIC
+set(RFB_SOURCES
Blacklist.cxx
CConnection.cxx
CMsgHandler.cxx
@@ -66,4 +66,20 @@
encodings.cxx
util.cxx)
-target_link_libraries(rfb jpeg os)
+set(RFB_LIBRARIES jpeg os)
+
+if(GNUTLS_FOUND)
+ set(RFB_SOURCES
+ ${RFB_SOURCES}
+ CSecurityTLS.cxx
+ SSecurityTLS.cxx
+ )
+ set(RFB_LIBRARIES
+ ${RFB_LIBRARIES}
+ ${GNUTLS_LIBRARIES}
+ )
+endif()
+
+add_library(rfb STATIC ${RFB_SOURCES})
+
+target_link_libraries(rfb ${RFB_LIBRARIES})
diff --git a/config.h.cmake.in b/config.h.cmake.in
index 87aa9d5..eee0f77 100644
--- a/config.h.cmake.in
+++ b/config.h.cmake.in
@@ -4,3 +4,8 @@
#cmakedefine HAVE_STRCASECMP
#cmakedefine HAVE_STRNCASECMP
#cmakedefine HAVE_VSNPRINTF
+
+/* MS Visual Studio 2008 and newer doesn't know ssize_t */
+#if defined(HAVE_GNUTLS) && defined(WIN32)
+#define ssize_t long
+#endif