[CMake] Bug in find_file() command ?
Glenn Coombs
glenn.coombs at gmail.com
Mon Sep 3 15:11:45 EDT 2012
Once the driver project has converted to using cmake that is what I plan to
do - use find_path() to look for driver_root/CMakeLists.txt. But in the
meantime I'm stuck using find_file() instead which works but it looks like
a bug that I need to specify the NO_DEFAULT_PATH option to avoid getting an
incorrect match.
--
Glenn
On 3 September 2012 09:58, Adolfo Rodríguez Tsouroukdissian <
adolfo.rodriguez at pal-robotics.com> wrote:
>
>
> On Tue, Aug 28, 2012 at 6:59 PM, Glenn Coombs <glenn.coombs at gmail.com>wrote:
>
>> I need to test for the presence of a directory called driver_root. I
>> couldn't see a find_directory() command in the help
>
>
> I cannot comment about your issues concerning find_file, but if you know
> the name of a file contained in the directory you can use find_path:
>
> http://cmake.org/cmake/help/v2.8.8/cmake.html#command:find_path
>
> Cheers,
>
> Adolfo.
>
>
>> so I am using the following lines in my CMakeLists.txt:
>>
>> message("1 DRV_ROOT_CHECK: ${DRV_ROOT_CHECK}")
>> if (DEFINED ENV{DRV_ROOT})
>> find_file(DRV_ROOT_CHECK driver_root $ENV{DRV_ROOT}/..)
>> message("2 DRV_ROOT_CHECK: ${DRV_ROOT_CHECK}")
>> endif()
>>
>> message("3 DRV_ROOT_CHECK: ${DRV_ROOT_CHECK}")
>> find_file(DRV_ROOT_CHECK driver_root
>> ../CVSFILES
>> ../..
>> ../../CVSFILES
>> ../../..
>> ../../../CVSFILES
>> ../../../..
>> )
>> message("4 DRV_ROOT_CHECK: ${DRV_ROOT_CHECK}")
>>
>> set(DRV_ROOT "${DRV_ROOT_CHECK}" CACHE PATH "Location of
>> driver tree")
>> set(DRV_ROOT_CHECK "${DRV_ROOT_CHECK}" CACHE INTERNAL "Location of
>> driver tree")
>>
>> message("5 DRV_ROOT_CHECK: ${DRV_ROOT_CHECK}")
>>
>> if (DRV_ROOT_CHECK)
>> message(" DRV_ROOT: ${DRV_ROOT}")
>> else()
>> message(FATAL_ERROR "Unable to locate driver_root directory.
>> Please set DRV_ROOT variable.")
>> endif()
>>
>> It works fine on my machine but fails on one of our build machines. Both
>> machines are Windows 7 (64-bit) and are using CMake 2.8.9. On my machine
>> it produces this output:
>>
>> 1 DRV_ROOT_CHECK:
>> 3 DRV_ROOT_CHECK:
>> 4 DRV_ROOT_CHECK: C:/data/perforceCheckouts/sim/vxe/CVSFILES/driver_root
>> 5 DRV_ROOT_CHECK: C:/data/perforceCheckouts/sim/vxe/CVSFILES/driver_root
>> DRV_ROOT: C:/data/perforceCheckouts/sim/vxe/CVSFILES/driver_root
>>
>> but on the build machine it produces this output:
>>
>> 1 DRV_ROOT_CHECK:
>> 3 DRV_ROOT_CHECK:
>> 4 DRV_ROOT_CHECK: C:/Windows/System32/driver_root
>> 5 DRV_ROOT_CHECK: C:/Windows/System32/driver_root
>>
>> There is no file or directory called driver_root in the windows/systsem32
>> folder. If I change the find_file() command to this:
>>
>> find_file(DRV_ROOT_CHECK driver_root PATHS
>> ../CVSFILES
>> ../..
>> ../../CVSFILES
>> ../../..
>> ../../../CVSFILES
>> ../../../..
>> NO_DEFAULT_PATH
>> )
>>
>> then it works producing this output:
>>
>> 1 DRV_ROOT_CHECK:
>> 3 DRV_ROOT_CHECK:
>> 4 DRV_ROOT_CHECK: C:/glenn/CVSFILES/driver_root
>> 5 DRV_ROOT_CHECK: C:/glenn/CVSFILES/driver_root
>>
>> Is this a bug in cmake or can somebody explain how it found a
>> non-existant file/folder in the windows/system32 folder ?
>>
>> --
>> Glenn
>>
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>
>
>
> --
> Adolfo Rodríguez Tsouroukdissian
> Robotics engineer
> adolfo.rodriguez at pal-robotics.com
> http://www.pal-robotics.com
>
> PAL ROBOTICS S.L
> c/ Pujades 77-79, 4º4ª
> 08005 Barcelona, Spain.
> Tel. +34.93.414.53.47
> Fax.+34.93.209.11.09
>
> AVISO DE CONFIDENCIALIDAD: Este mensaje y sus documentos adjuntos, pueden
> contener información privilegiada y/o confidencial que está dirigida
> exclusivamente a su destinatario. Si usted recibe este mensaje y no es el
> destinatario indicado, o el empleado encargado de su entrega a dicha
> persona, por favor, notifíquelo inmediatamente y remita el mensaje original
> a la dirección de correo electrónico indicada. Cualquier copia, uso o
> distribución no autorizados de esta comunicación queda estrictamente
> prohibida.
>
> CONFIDENTIALITY NOTICE: This e-mail and the accompanying document(s) may
> contain confidential information which is privileged and intended only for
> the individual or entity to whom they are addressed. If you are not the
> intended recipient, you are hereby notified that any disclosure, copying,
> distribution or use of this e-mail and/or accompanying document(s) is
> strictly prohibited. If you have received this e-mail in error, please
> immediately notify the sender at the above e-mail address.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120903/a545c440/attachment.htm>
More information about the CMake
mailing list