Fix Windows build:
* CMake "install" commands require a RUNTIME argument for platforms with
DLLs (e.g. Windows).
* Replace use of non-standard variable length array with vector
* Remove unnecessary #include of unistd.h
* Add #ifdefs to dynamic backend code to disable for non-Unix platforms
where you can't use dlopen etc. We could implement this properly for Windows
later using LoadLibrary etc., but for now erroring is fine.
* Add missing #include of <algorithm>
Change-Id: Ic8ef5fd599b37bf8772510157b6e479819f6a1eb
diff --git a/src/backends/backendsCommon/DynamicBackendUtils.cpp b/src/backends/backendsCommon/DynamicBackendUtils.cpp
index fc4336f..da7c324 100644
--- a/src/backends/backendsCommon/DynamicBackendUtils.cpp
+++ b/src/backends/backendsCommon/DynamicBackendUtils.cpp
@@ -16,6 +16,7 @@
void* DynamicBackendUtils::OpenHandle(const std::string& sharedObjectPath)
{
+#if defined(__unix__)
if (sharedObjectPath.empty())
{
throw RuntimeException("OpenHandle error: shared object path must not be empty");
@@ -28,16 +29,23 @@
}
return sharedObjectHandle;
+#else
+ throw RuntimeException("Dynamic backends not supported on this platform");
+#endif
}
void DynamicBackendUtils::CloseHandle(const void* sharedObjectHandle)
{
+#if defined(__unix__)
if (!sharedObjectHandle)
{
return;
}
dlclose(const_cast<void*>(sharedObjectHandle));
+#else
+ throw RuntimeException("Dynamic backends not supported on this platform");
+#endif
}
bool DynamicBackendUtils::IsBackendCompatible(const BackendVersion &backendVersion)
@@ -56,6 +64,7 @@
std::string DynamicBackendUtils::GetDlError()
{
+#if defined(__unix__)
const char* errorMessage = dlerror();
if (!errorMessage)
{
@@ -63,6 +72,9 @@
}
return std::string(errorMessage);
+#else
+ throw RuntimeException("Dynamic backends not supported on this platform");
+#endif
}
std::vector<std::string> DynamicBackendUtils::GetBackendPaths(const std::string& overrideBackendPath)