diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index 742d4c1b82d..5b6f49cf25f 100644 --- a/Installation/test/Installation/CMakeLists.txt +++ b/Installation/test/Installation/CMakeLists.txt @@ -62,6 +62,11 @@ if ( CGAL_FOUND ) create_link_to_program(CGAL_Qt4) endif() endif() + + if(WIN32) + add_executable(test_gmp_mpfr_dll test_gmp_mpfr_dll.cpp) + target_link_libraries(test_gmp_mpfr_dll Version) + endif(WIN32) else() diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp new file mode 100644 index 00000000000..0b6a2bdd176 --- /dev/null +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -0,0 +1,77 @@ +// This test is for MSVC only. +#ifndef _MSC_VER +int main() { + return 0; +} +#else + +#define GMP_SONAME "libgmp-10" +#define MPFR_SONAME "libmpfr-4" +#define GMP_MAJOR 5 +#define MPFR_MAJOR 3 + + +#include +#include +#include +#include "gmp.h" +#include + +bool get_version_info(const LPCTSTR name, + int& major, + int& minor, + int& patch, + int& build) +{ + HMODULE g_dllHandle = GetModuleHandle(name); + if(!g_dllHandle) { + std::cerr << name << " is not loaded!\n"; + return false; + } + char fileName[_MAX_PATH]; + DWORD size = GetModuleFileName(g_dllHandle, fileName, _MAX_PATH); + fileName[size] = NULL; + std::cerr << "Query FileVersion of \"" << fileName << "\"\n"; + DWORD handle = 0; + size = GetFileVersionInfoSize(fileName, &handle); + BYTE* versionInfo = new BYTE[size]; + if (!GetFileVersionInfo(fileName, handle, size, versionInfo)) + { + delete[] versionInfo; + return false; + } + // we have version information + UINT len = 0; + VS_FIXEDFILEINFO* vsfi = NULL; + VerQueryValue(versionInfo, "\\", (void**)&vsfi, &len); + major = HIWORD(vsfi->dwFileVersionMS); + minor = LOWORD(vsfi->dwFileVersionMS); + patch = HIWORD(vsfi->dwFileVersionLS); + build = LOWORD(vsfi->dwFileVersionLS); + delete[] versionInfo; + return true; +} + +int main() { + std::cout << "Hello GMP version " << gmp_version << std::endl; + std::cout << "Hello MPFR version " << mpfr_get_version() << std::endl; + int major, minor, patch, build; + bool result = get_version_info(GMP_SONAME, major, minor, patch, build); + assert(result); + std::cout << "GMP version " + << major << "." + << minor << "." + << patch << "." + << build << "\n"; + assert(major==GMP_MAJOR); + major = 0; + result = get_version_info(MPFR_SONAME, major, minor, patch, build); + assert(result); + std::cout << "MPFR version " + << major << "." + << minor << "." + << patch << "." + << build << "\n"; + assert(major==MPFR_MAJOR); +} +#endif