[CMake] [PATCH] Fix for CMakeFindDependencyMacro.cmake

Aurélien Gâteau agateau at kde.org
Mon Feb 24 12:16:57 EST 2014


Hi,

The find_dependency() macro defined in CMakeFindDependencyMacro.cmake has a 
bug which makes it reuse the version number used in a previous call in 
certain situation.

Here is my test case:

cmake_minimum_required(VERSION 3.0)

include(CMakeFindDependencyMacro)
find_dependency(Qt5Script 5.2)
find_dependency(KF5Pty 4.96.0)

This fails here (with CMake 3.0.0rc1 from the release branch): the second 
call to find_dependency fails, complaining it cannot find KF5Pty 5.2.

It turns out the code checks if the version number is passed to 
find_dependency() with: if (${ARGV1}) which is FALSE if ARGV1 is 4.96.0 (!).

Since find_dependency() is a macro, the previous call to it set the 
"version" variable, causing it to be reused in the second call. Attached 
patch sets the version variable unconditionally so that it is not skipped if 
the version ends with ".0" and turns the macro into a function so that it 
does not leak local variables.

Aurélien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-version-handling-in-find_dependency.patch
Type: text/x-patch
Size: 1340 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140224/6a662d13/attachment.bin>


More information about the CMake mailing list