Led
Led

Reputation: 154

cmake can not open file

When compiling a simple project with cmake I get

    $ cmake CMakeLists.txt
    CMake Error: cmListFileCache: error can not open file /cygdrive/d/Balladen/helloWorld/CMakeFiles/CMakeSystem.cmake
    -- The C compiler identification is GNU 4.8.2
    CMake Error: cmListFileCache: error can not open file /cygdrive/d/Balladen/helloWorld/CMakeFiles/CMakeCCompiler.cmake
    CMake Error: Could not find cmake module file:/cygdrive/d/Balladen/helloWorld/CMakeFiles/CMakeCCompiler.cmake
    -- The CXX compiler identification is GNU 4.8.2
    CMake Error: cmListFileCache: error can not open file /cygdrive/d/Balladen/helloWorld/CMakeFiles/CMakeCXXCompiler.cmake
    CMake Error: Could not find cmake module file:/cygdrive/d/Balladen/helloWorld/CMakeFiles/CMakeCXXCompiler.cmake
    CMake Error: cmListFileCache: error can not open file /cygdrive/d/Balladen/helloWorld/CMakeFiles/CMakeSystem.cmake
    CMake Error: cmListFileCache: error can not open file /cygdrive/d/Balladen/helloWorld/CMakeFiles/CMakeRCCompiler.cmake
    CMake Error: Could not find cmake module file:/cygdrive/d/Balladen/helloWorld/CMakeFiles/CMakeRCCompiler.cmake

CMakeLists.txt:

    cmake_minimum_required(VERSION 2.8.4)
    project('helloWorld')

    ## Target
    set(TEST_SRCS main.cpp)
    add_executable(helloWorld ${TEST_SRCS})

    ## Link libraries
    target_link_libraries(helloWorld ${CMAKE_THREAD_LIBS_INIT})

The files CMakeCCompiler and CMakeCXXCompiler do not exist, the file CMakeSystem.cmake has no access rights. Therefore they can not be read.

    $ ls -la *
    -rw-r--r--+ 1 WUD Domain Users 10195 Mar 26 17:59 CMakeCache.txt
    ----------+ 1 WUD Domain Users   426 Mar 26 17:53 CMakeLists.txt
    ----------+ 1 WUD Domain Users    64 Mar 26 17:58 main.cpp
    ----------+ 1 WUD Domain Users  5667 Mar 26 17:34 Makefile

    CMakeFiles:
    total 16
    drwxr-xr-x+ 1 WUD Domain Users   0 Mar 26 17:59 .
    d---------+ 1 WUD Domain Users   0 Mar 26 17:59 ..
    -rw-r--r--  1 WUD Domain Users  85 Mar 26 17:59 cmake.check_cache
    -rw-r--r--  1 WUD Domain Users  72 Mar 26 17:59 CMakeError.log
    -rw-r--r--  1 WUD Domain Users 803 Mar 26 17:59 CMakeOutput.log
    ----------  1 WUD Domain Users 221 Mar 26 17:59 CMakeRCCompiler.cmake
    ----------  1 WUD Domain Users 402 Mar 26 17:59 CMakeSystem.cmake
    drwxr-xr-x+ 1 WUD Domain Users   0 Mar 26 17:59 CMakeTmp
    drwxr-xr-x+ 1 WUD Domain Users   0 Mar 26 17:59 CompilerIdC
    drwxr-xr-x+ 1 WUD Domain Users   0 Mar 26 17:59 CompilerIdCXX

If I copy the files from an other project and add reading rights to all files in CMakeFiles, then it works fine. I have this problem with several projects. Running it on a mounted drive DOES help (for example on a true-crypt drive). So I guess problems with access rights. All hints I found in the internet did not help. I'm working with Windows 7, Cygwin 32bit, cmake version 2.8.9

Any idea?

Upvotes: 2

Views: 7462

Answers (1)

Jeffrey Xiao
Jeffrey Xiao

Reputation: 51

This appears to be an issue with cmake being unable to process files with path lengths above 260 characters or more on Windows. To fix this issue you would need to reduce your path size to below 260 or set LongPathsEnabled to 1 in the file registry. See this issue for more details:

https://gitlab.kitware.com/cmake/cmake/-/issues/21875

Upvotes: 1

Related Questions