Generate config.h for Windows build
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4185 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f390767..9c08e8b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -85,6 +85,22 @@
"<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>")
endif()
+# Generate config.h
+include(CheckIncludeFiles)
+include(CheckFunctionExists)
+set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h)
+set(CMAKE_REQUIRED_LIBRARIES ws2_32)
+check_function_exists(inet_aton HAVE_INET_ATON)
+check_function_exists(inet_ntop HAVE_INET_NTOP)
+set(CMAKE_EXTRA_INCLUDE_FILES)
+set(CMAKE_REQUIRED_LIBRARIES)
+check_function_exists(snprintf HAVE_SNPRINTF)
+check_function_exists(strcasecmp HAVE_STRCASECMP)
+check_function_exists(strncasecmp HAVE_STRNCASECMP)
+check_function_exists(vsnprintf HAVE_VSNPRINTF)
+configure_file(config.h.cmake.in config.h)
+add_definitions(-DHAVE_CONFIG_H)
+include_directories(${CMAKE_BINARY_DIR})
add_subdirectory(common)
add_subdirectory(win)
diff --git a/config.h.cmake.in b/config.h.cmake.in
new file mode 100644
index 0000000..87aa9d5
--- /dev/null
+++ b/config.h.cmake.in
@@ -0,0 +1,6 @@
+#cmakedefine HAVE_INET_ATON
+#cmakedefine HAVE_INET_NTOP
+#cmakedefine HAVE_SNPRINTF
+#cmakedefine HAVE_STRCASECMP
+#cmakedefine HAVE_STRNCASECMP
+#cmakedefine HAVE_VSNPRINTF