[cmake-developers] [CMake 0015736]: FeatureTesting unreliable

Mantis Bug Tracker mantis at public.kitware.com
Thu Sep 10 13:46:51 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15736 
====================================================================== 
Reported By:                Felix Geyer
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15736
Category:                   Modules
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-09-10 13:46 EDT
Last Modified:              2015-09-10 13:46 EDT
====================================================================== 
Summary:                    FeatureTesting unreliable
Description: 
The CompileFeatures test fails in Debian on the architecture alpha.
My guess is that it's a general problem and other architectures just got lucky.

The problem seems to be that Modules/Internal/FeatureTesting.cmake doesn't add a
terminator (\0 or \n for example) at the start of const char features.

As a result a printable character can appear in the binary right before
"${lang}_FEATURE:".
So when cmake extracts strings from the binary it reads
"kC_FEATURE:1c_function_prototypes\n".
The extra "k" at the start confuses the module as it expects "C_FEATURE".

This code in Modules/Internal/FeatureTesting.cmake might be supposed to add a
null character at the start:
  const char features[] = {\"\"\n")

However if I'm not mistaken C just concats string literals that are space
separated -> it's a noop.

Replacing that empty string literal with "\0" fixes the problem.

Original bug report with an analysis of the problem:
https://bugs.debian.org/789807
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-09-10 13:46 Felix Geyer    New Issue                                    
======================================================================



More information about the cmake-developers mailing list