I need to test for the presence of a directory called driver_root.  I
couldn't see a find_directory() command in the help 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

Reply via email to