[CMake] FILE(LOCK ... GUARD FILE) fails with cmake -P

Sergey Zakharchenko doublef.mobile at gmail.com
Fri Jun 23 02:23:44 EDT 2017


Hello,

CMake crashes on an assertion when I use FILE(LOCK ... GUARD FILE)
inside of a file called (directly or indirectly) from cmake -P.

$ cat x.cmake
FILE(LOCK . DIRECTORY GUARD FILE)

$ cat y.cmake
INCLUDE(x.cmake)

$ cmake -P  x.cmake
Assertion failed: (!this->FileScopes.empty()), function LockFileScope,
file /wrkdirs/usr/ports/devel/cmake/work/cmake-3.5.0/Source/cmFileLockPool.cxx,
line 76.
Abort trap (core dumped)

$ cmake -P y.cmake
Assertion failed: (!this->FileScopes.empty()), function LockFileScope,
file /wrkdirs/usr/ports/devel/cmake/work/cmake-3.5.0/Source/cmFileLockPool.cxx,
line 76.
Abort trap (core dumped)

I've tested this with different base systems and CMake versions from
3.4.1 to 3.7.2 with similar results (doesn't matter if I lock a file
instead either). It's easy to work around (wrap code with function)
but a bit inelegant. I understand there may be some limitation but
there could at least be some sensible error message like with 'GUARD
FUNCTION' when it's not used in a function definition...

Best regards,

-- 
DoubleF


More information about the CMake mailing list