From 912345edea448775209c440acea42572f99dce9f Mon Sep 17 00:00:00 2001
From: Nehal J Wani <nehaljw.kkd1@gmail.com>
Date: Sun, 25 Mar 2018 10:25:51 -0500
Subject: [PATCH] Update CMakeLists.txt to define INSTALL files, targets... in
 Windows systems.

xref: https://github.com/FreeTDS/freetds/commit/425c2109cae4de11f701008d3d6922c00c735786
---
 CMakeLists.txt                  | 27 +++++++++++++++++++++++++++
 src/apps/CMakeLists.txt         |  9 +++++++++
 src/ctlib/CMakeLists.txt        |  9 +++++++++
 src/dblib/CMakeLists.txt        |  9 +++++++++
 src/odbc/CMakeLists.txt         |  9 +++++++++
 src/replacements/CMakeLists.txt | 10 ++++++++++
 src/tds/CMakeLists.txt          |  9 +++++++++
 7 files changed, 82 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8481ed3..ceb3ccc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -453,3 +453,30 @@ configure_file(${CMAKE_SOURCE_DIR}/include/freetds/version.h.in ${CMAKE_BINARY_D
 if(NOT EXISTS "${CMAKE_SOURCE_DIR}/configure")
 	configure_file(${CMAKE_SOURCE_DIR}/src/odbc/version.rc.in ${CMAKE_SOURCE_DIR}/src/odbc/version.rc)
 endif(NOT EXISTS "${CMAKE_SOURCE_DIR}/configure")
+
+
+if(WIN32)
+set(FREETDS_PUBLIC_INCLUDE
+       ${CMAKE_SOURCE_DIR}/include/bkpublic.h
+       ${CMAKE_SOURCE_DIR}/include/cspublic.h
+       ${CMAKE_SOURCE_DIR}/include/cstypes.h
+       ${CMAKE_SOURCE_DIR}/include/ctpublic.h
+       ${CMAKE_SOURCE_DIR}/include/sqldb.h
+       ${CMAKE_SOURCE_DIR}/include/sqlfront.h
+       ${CMAKE_SOURCE_DIR}/include/sybdb.h
+       ${CMAKE_SOURCE_DIR}/include/sybfront.h
+       ${CMAKE_SOURCE_DIR}/include/syberror.h
+       ${CMAKE_SOURCE_DIR}/include/odbcss.h
+       ${CMAKE_BINARY_DIR}/include/tds_sysdep_public.h)
+
+set(FREETDS_PUBLIC_INCLUDE_2
+       ${CMAKE_BINARY_DIR}/include/freetds/version.h)
+
+set(FREETDS_CONF_FILES
+       ${CMAKE_SOURCE_DIR}/freetds.conf
+       ${CMAKE_SOURCE_DIR}/locales.conf)
+
+install(FILES ${FREETDS_PUBLIC_INCLUDE} DESTINATION include)
+install(FILES ${FREETDS_PUBLIC_INCLUDE_2} DESTINATION include/freetds)
+install(FILES ${FREETDS_CONF_FILES} DESTINATION etc)
+endif(WIN32)
diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt
index 7bdc8f0..d045161 100644
--- a/src/apps/CMakeLists.txt
+++ b/src/apps/CMakeLists.txt
@@ -15,3 +15,12 @@ endif(WIN32)
 
 add_executable(bsqlodbc bsqlodbc.c)
 target_link_libraries(bsqlodbc tdsodbc replacements ${libs})
+
+if(WIN32)
+INSTALL(TARGETS tsql bsqlodbc
+       PUBLIC_HEADER DESTINATION include
+               RUNTIME DESTINATION bin
+               LIBRARY DESTINATION lib
+               ARCHIVE DESTINATION lib
+       )
+endif(WIN32)
diff --git a/src/ctlib/CMakeLists.txt b/src/ctlib/CMakeLists.txt
index 60eee9c..9a4db42 100644
--- a/src/ctlib/CMakeLists.txt
+++ b/src/ctlib/CMakeLists.txt
@@ -31,3 +31,12 @@ endif()
 if(MINGW OR CYGWIN)
 	set_target_properties(ct PROPERTIES LINK_FLAGS "--static")
 endif(MINGW OR CYGWIN)
+
+if(WIN32)
+INSTALL(TARGETS ct ct-static
+       PUBLIC_HEADER DESTINATION include
+               RUNTIME DESTINATION bin
+               LIBRARY DESTINATION lib
+               ARCHIVE DESTINATION lib
+       )
+endif(WIN32)
diff --git a/src/dblib/CMakeLists.txt b/src/dblib/CMakeLists.txt
index 38e4721..6ee1a1d 100644
--- a/src/dblib/CMakeLists.txt
+++ b/src/dblib/CMakeLists.txt
@@ -24,3 +24,12 @@ endif()
 if(MINGW OR CYGWIN)
 	set_target_properties(sybdb PROPERTIES LINK_FLAGS "--static")
 endif(MINGW OR CYGWIN)
+
+if(WIN32)
+INSTALL(TARGETS sybdb db-lib
+       PUBLIC_HEADER DESTINATION include
+               RUNTIME DESTINATION bin
+               LIBRARY DESTINATION lib
+               ARCHIVE DESTINATION lib
+       )
+endif(WIN32)
diff --git a/src/odbc/CMakeLists.txt b/src/odbc/CMakeLists.txt
index 6a60d50..8b338a9 100644
--- a/src/odbc/CMakeLists.txt
+++ b/src/odbc/CMakeLists.txt
@@ -33,3 +33,12 @@ target_link_libraries(tdsodbc tds replacements ${libs} ${lib_NETWORK} ${lib_BASE
 if(MINGW OR CYGWIN)
 	set_target_properties(tdsodbc PROPERTIES LINK_FLAGS "--static -Wl,--kill-at -Wl,--enable-stdcall-fixup")
 endif(MINGW OR CYGWIN)
+
+if(WIN32)
+INSTALL(TARGETS tdsodbc
+       PUBLIC_HEADER DESTINATION include
+               RUNTIME DESTINATION bin
+               LIBRARY DESTINATION lib
+               ARCHIVE DESTINATION lib
+       )
+endif(WIN32)
diff --git a/src/replacements/CMakeLists.txt b/src/replacements/CMakeLists.txt
index cafba2a..0536dea 100644
--- a/src/replacements/CMakeLists.txt
+++ b/src/replacements/CMakeLists.txt
@@ -26,3 +26,13 @@ if (NOT WIN32)
 endif()
 
 add_subdirectory(unittests)
+
+
+if(WIN32)
+INSTALL(TARGETS replacements
+       PUBLIC_HEADER DESTINATION include
+               RUNTIME DESTINATION bin
+               LIBRARY DESTINATION lib
+               ARCHIVE DESTINATION lib
+       )
+endif(WIN32)
diff --git a/src/tds/CMakeLists.txt b/src/tds/CMakeLists.txt
index ce4448a..1b630cb 100644
--- a/src/tds/CMakeLists.txt
+++ b/src/tds/CMakeLists.txt
@@ -47,3 +47,12 @@ add_library(tds STATIC
 if (NOT WIN32)
 	set_target_properties(tds PROPERTIES COMPILE_FLAGS -fPIC)
 endif()
+
+if(WIN32)
+INSTALL(TARGETS tds
+       PUBLIC_HEADER DESTINATION include
+               RUNTIME DESTINATION bin
+               LIBRARY DESTINATION lib
+               ARCHIVE DESTINATION lib
+       )
+endif(WIN32)
-- 
2.16.1

