MantisBT - CMake
View Issue Details
0011991CMakeCMakepublic2011-03-21 10:552013-01-09 10:57
Daniel Franke 
David Cole 
normalcrashalways
closedno change required 
WindowsXP
CMake-2-8 
CMake 2.8.10 
0011991: stack smash with (assumed) case-sensitive file names
FindFLEX.cmake was not available in cmake-2.6 but was added in cmake.2.8.

In order to allow find_package() for either version, I created FindFlex.cmake (note the lowercase part of FLEX) in my CMAKE_MODULE_PATH. This file contains:

if (${CMAKE_VERSION} VERSION_LESS 2.8)
  set (FLEX_FOUND "false")
else ()
  find_package (FLEX)
endif ()

This works for Linux, but on windows, cmake dies with ERRORLEVEL=-1073741819, i.e. 0xC0000005 which indicates a crash. Taking into account that the file system is not case sensitive, I assume that find_package(Flex) and find_package(FLEX) are not distinguished and thus result in a infinite loop of above script.

The problem was seen with cmake 2.8.2.
No tags attached.
Issue History
2011-03-21 10:55Daniel FrankeNew Issue
2011-03-21 11:10Michael WildNote Added: 0025840
2012-08-11 10:47David ColeAssigned To => David Cole
2012-08-11 10:47David ColeStatusnew => assigned
2012-08-11 10:48David ColeNote Added: 0030217
2012-08-11 10:48David ColeStatusassigned => resolved
2012-08-11 10:48David ColeFixed in Version => CMake 2.8.10
2012-08-11 10:48David ColeResolutionopen => no change required
2013-01-09 10:57Robert MaynardNote Added: 0032042
2013-01-09 10:57Robert MaynardStatusresolved => closed

Notes
(0025840)
Michael Wild   
2011-03-21 11:10   
Your implementation has several problems:
- doesn't work on case-insensitive file systems (e.g. Mac or Windows, as you noticed)
- doesn't forward additional arguments to find_package properly, such as version numbers or REQUIRED.

Instead, let CMake work its magic:

# ------------------------------------------
set(CMAKE_MODULE_PATH
  "${CMAKE_ROOT}/Modules"
  "${CMAKE_SOURCE_DIR}/cmake" # or wherever your CMake modules are
  )

find_package(FLEX)
# ------------------------------------------

If you give them the same name (including the same case), things should work fine automatically. If CMake is new enough, it will first find the version shipped with it, otherwise it will fall back to your custom version.
(0030217)
David Cole   
2012-08-11 10:48   
Please follow suggestions made by Michael Wild in his note. Let us know if you still have problems after that.
(0032042)
Robert Maynard   
2013-01-09 10:57   
Closing resolved issues that have not been updated in more than 4 months.