From 13d183dd22c2929db8230a20151020b636273e8d Mon Sep 17 00:00:00 2001
From: Maximilien Siavelis <maximilien.siavelis@simulease.com>
Date: 周六, 06 1月 2018 03:57:46 +0800
Subject: [PATCH] fix MSVC build

---
 src/tools/base_lib/win/CryptoHelperWindows.cpp |   16 ++++++++--------
 CMakeLists.txt                                 |    7 +------
 test/functional/volid_test.cpp                 |    6 ++++--
 src/library/pc-identifiers.c                   |    6 +++++-
 4 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc755ac..49fcd95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,7 +29,6 @@
 endif(CMAKE_BUILD_TYPE)
 
 if(MSVC)
-
 	SET(PLATFORM_LIBS "")
 	include(target_arch)
 	target_architecture( TARGET_ARCHITECTURE )
@@ -68,6 +67,7 @@
   SET(HAVE_64BIT_SIZE_T 0)
 endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
 
+set( Boost_USE_STATIC_LIBS ON )
 find_package(Boost 1.55.0 COMPONENTS date_time unit_test_framework program_options system filesystem)
 #set below in case of dynamic linking in debug.
 #set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:BOOST_TEST_DYN_LINK>)
@@ -125,8 +125,3 @@
   message( STATUS "Build type: " ${CMAKE_BUILD_TYPE})
 endif(CMAKE_BUILD_TYPE)
 message( STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX})
-if(DOXYGEN_FOUND)
-  message(STATUS "Doxygen: " ${DOXYGEN_EXECUTABLE})
-else(DOXYGEN_FOUND)
-  message(STATUS "Doxygen: not found.")
-endif(DOXYGEN_FOUND)
diff --git a/src/library/pc-identifiers.c b/src/library/pc-identifiers.c
index 6b4144b..10c51b2 100644
--- a/src/library/pc-identifiers.c
+++ b/src/library/pc-identifiers.c
@@ -84,7 +84,11 @@
 			}
 		}
 end:
-		*num_identifiers = cmin(*num_identifiers, adapter_num * disk_num);
+#ifdef _MSC_VER
+        *num_identifiers = min(*num_identifiers, adapter_num * disk_num);
+#else
+        *num_identifiers = cmin(*num_identifiers, adapter_num * disk_num);
+#endif
 		free(diskInfoPtr);
 		free(adapterInfoPtr);
 	}
diff --git a/src/tools/base_lib/win/CryptoHelperWindows.cpp b/src/tools/base_lib/win/CryptoHelperWindows.cpp
index cdef638..c21a89b 100644
--- a/src/tools/base_lib/win/CryptoHelperWindows.cpp
+++ b/src/tools/base_lib/win/CryptoHelperWindows.cpp
@@ -62,7 +62,7 @@
 	KEYLENGTH | CRYPT_EXPORTABLE, &m_hCryptKey)) {
 		dwErrCode = GetLastError();
 		throw logic_error(
-				string("Error generating keys ") + to_string(dwErrCode));
+				string("Error generating keys ") + to_string(static_cast<long long>(dwErrCode)));
 	}
 }
 
@@ -86,7 +86,7 @@
 		dwErrCode = GetLastError();
 		throw logic_error(
 				string("Error calculating size of public key ")
-						+ to_string(dwErrCode));
+						+ to_string(static_cast<long long>(dwErrCode)));
 	}
 	// Allocate memory for the pbKeyBlob.
 	if ((pbKeyBlob = new BYTE[dwBlobLen]) == NULL) {
@@ -98,7 +98,7 @@
 		delete pbKeyBlob;
 		dwErrCode = GetLastError();
 		throw logic_error(
-				string("Error exporting public key ") + to_string(dwErrCode));
+				string("Error exporting public key ") + to_string(static_cast<long long>(dwErrCode)));
 	} else {
 		ss << "\t";
 		for (unsigned int i = 0; i < dwBlobLen; i++) {
@@ -108,7 +108,7 @@
 					ss << "\\" << endl << "\t";
 				}
 			}
-			ss << to_string(pbKeyBlob[i]);
+			ss << to_string(static_cast<long long>(pbKeyBlob[i]));
 		}
 		delete pbKeyBlob;
 	}
@@ -146,7 +146,7 @@
 		dwErrCode = GetLastError();
 		throw logic_error(
 				string("Error calculating size of private key ")
-						+ to_string(dwErrCode));
+						+ to_string(static_cast<long long>(dwErrCode)));
 	}
 	// Allocate memory for the pbKeyBlob.
 	if ((pbKeyBlob = new BYTE[dwBlobLen]) == NULL) {
@@ -159,7 +159,7 @@
 		delete pbKeyBlob;
 		dwErrCode = GetLastError();
 		throw logic_error(
-				string("Error exporting private key ") + to_string(dwErrCode));
+				string("Error exporting private key ") + to_string(static_cast<long long>(dwErrCode)));
 	} else {
 		ss << "\t";
 		for (unsigned int i = 0; i < dwBlobLen; i++) {
@@ -169,7 +169,7 @@
 					ss << "\\" << endl << "\t";
 				}
 			}
-			ss << to_string(pbKeyBlob[i]);
+			ss << to_string(static_cast<long long>(pbKeyBlob[i]));
 		}
 		delete pbKeyBlob;
 	}
@@ -216,7 +216,7 @@
 			&hKey)) {
 		throw logic_error(
 				string("Error in importing the PrivateKey ")
-						+ to_string(GetLastError()));
+						+ to_string(static_cast<long long>(GetLastError())));
 	}
 
 	//-------------------------------------------------------------------
diff --git a/test/functional/volid_test.cpp b/test/functional/volid_test.cpp
index e9bf9ae..40901f5 100644
--- a/test/functional/volid_test.cpp
+++ b/test/functional/volid_test.cpp
@@ -27,7 +27,9 @@
 			strategy);
 	BOOST_ASSERT(generate_ok == FUNCTION_RETURN::FUNC_RET_OK);
 	cout << "Identifier:" << identifier_out << endl;
-	vector<string> extraArgs = { "-s", identifier_out };
+	vector<string> extraArgs;
+    extraArgs.push_back("-s");
+    extraArgs.push_back(identifier_out);
 	generate_license(licLocation, extraArgs);
 
 	LicenseInfo license;
@@ -109,7 +111,7 @@
 					sizeof(PcSignature));
 			EVENT_TYPE val_result = validate_pc_signature(pcsig);
 			string message = string("pc signature verification strategy:")
-					+ to_string(i) + " generated: [" + generated_identifier
+					+ to_string(static_cast<long long>(i)) + " generated: [" + generated_identifier
 					+ "] reference: [" + reference_signatures[i] + "]";
 			BOOST_TEST_CHECKPOINT("Verifying signature: ");
 			BOOST_CHECK_EQUAL(val_result, LICENSE_OK);

--
Gitblit v1.9.1