Export: Fix internal CMake version test logic

Fix the internal DEVEL_CMAKE_VERSION macro to use CMake_VERSION_ENCODE
to compare version component-wise.  Otherwise an old invocation of the
macro may be tricked into using the current version when the requested
major version is smaller than the current version but the requested
minor version is larger.  It should use the requested (old) version in
that case.
This commit is contained in:
Brad King 2014-02-10 11:50:54 -05:00
parent d2059d2511
commit 9bcc1b21f0
1 changed files with 6 additions and 4 deletions

View File

@ -19,15 +19,17 @@
#include "cmInstallExportGenerator.h"
#include "cmInstallTargetGenerator.h"
#include "cmTargetExport.h"
#include "cmVersionConfig.h"
#include "cmVersionMacros.h"
#include "cmVersion.h"
#define STRINGIFY_HELPER(X) #X
#define STRINGIFY(X) STRINGIFY_HELPER(X)
#define DEVEL_CMAKE_VERSION(maj, min, patch) \
(maj > CMake_VERSION_MAJOR \
|| min > CMake_VERSION_MINOR \
|| patch > CMake_VERSION_PATCH) ? \
(CMake_VERSION_ENCODE(maj, min, patch) > \
CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, \
CMake_VERSION_PATCH) \
) ? \
STRINGIFY(CMake_VERSION_MAJOR) "." STRINGIFY(CMake_VERSION_MINOR) "." \
STRINGIFY(CMake_VERSION_PATCH) "." STRINGIFY(CMake_VERSION_TWEAK) \
: #maj "." #min "." #patch