mirror of https://github.com/CGAL/cgal
New test that checks:
- that GMP and MPFR are correctly linked, - and that they are DLL, with correct fileversion meta-info.
This commit is contained in:
parent
e95329afcb
commit
17d637cb92
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <iostream>
|
||||
#include <cassert>
|
||||
#include <windows.h>
|
||||
#include "gmp.h"
|
||||
#include <mpfr.h>
|
||||
|
||||
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
|
||||
Loading…
Reference in New Issue