MantisBT - CMake
View Issue Details
0014795CMakeModulespublic2014-03-07 06:152014-10-06 10:32
trsystran 
 
normalminoralways
closedno change required 
Ubuntu
CMake 2.8.12.2 
 
0014795: flex_target: some errors silently ignored
Current flex version (v2.5.37) sometimes generates an empty output file in case of error.
(at least when m4 program is missing: "flex: fatal internal error, exec of /usr/bin/m4 failed")

In such case flex returns a non zero return code, and cmake correctly reports a target build failure, however flex did generate the output file: an empty file.

This is an issue: if we do two "make" in a row the first one will correctly fail, but the second one will think the target is generated (since the file exists) and proceed without error. It will maybe fail later when symbols are missing (or not if we only build dynamic libraries).
* install flex
* remove m4
* use flex_target
find_package(FLEX "2.5.37" QUIET REQUIRED)
flex_target(Test test.l ${CMAKE_CURRENT_BINARY_DIR}/test.c)
create_library(test SHARED ${FLEX_test_OUTPUTS})
* run cmake
* run "make; make"
* result: the library "test" is build without error on the second make; it shouldn't.
Maybe we should report this to flex, but in any case in order to support older versions we should still have a workaround in FindFLEX.cmake: delete the output in case of flex error.
No tags attached.
Issue History
2014-03-07 06:15trsystranNew Issue
2014-03-10 10:50Brad KingNote Added: 0035357
2014-03-10 10:50Brad KingSeveritymajor => minor
2014-03-10 10:50Brad KingStatusnew => backlog
2014-03-10 11:00Brad KingNote Added: 0035360
2014-03-10 11:35trsystranNote Added: 0035369
2014-03-10 11:48Brad KingNote Added: 0035370
2014-03-10 11:50trsystranNote Added: 0035371
2014-03-10 11:52Brad KingNote Added: 0035372
2014-03-10 11:52Brad KingStatusbacklog => resolved
2014-03-10 11:52Brad KingResolutionopen => no change required
2014-10-06 10:32Robert MaynardNote Added: 0036938
2014-10-06 10:32Robert MaynardStatusresolved => closed

Notes
(0035357)
Brad King   
2014-03-10 10:50   
This should be fixed by flex upstream.
(0035360)
Brad King   
2014-03-10 11:00   
According to local testing flex does delete the output file on normal errors like bad input. It is only an internal error produced by cases like missing m4 that cause this behavior. Still, it is an upstream issue.

Working around this issue in FindFLEX.cmake would require wrapping the flex invocation in a script that checks the return code and removes the output.
(0035369)
trsystran   
2014-03-10 11:35   
Bug opened upstream:
https://sourceforge.net/p/flex/bugs/164/ [^]

The script workaround could be a cmake script, couldn't it? It would still be useful for older flex releases I think.
(0035370)
Brad King   
2014-03-10 11:48   
Re 0014795:0035369: Yes, but it could also be a local flex.sh that is set as FLEX_EXECUTABLE instead.

IMO it is not worth the extra indirection at runtime and extra infrastructure/maintenance within CMake just to work around installations of flex that are missing their dependencies.
(0035371)
trsystran   
2014-03-10 11:50   
OK, let's close this issue then.
(0035372)
Brad King   
2014-03-10 11:52   
Re 0014795:0035371: Okay, thanks.
(0036938)
Robert Maynard   
2014-10-06 10:32   
Closing resolved issues that have not been updated in more than 4 months.