[cmake-developers] [CMake 0015211]: Faulty parsing of variables with multi-line content

Mantis Bug Tracker mantis at public.kitware.com
Sat Oct 18 16:52:42 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=15211 
====================================================================== 
Reported By:                Timo Korthals
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15211
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   high
Status:                     new
====================================================================== 
Date Submitted:             2014-10-18 16:52 EDT
Last Modified:              2014-10-18 16:52 EDT
====================================================================== 
Summary:                    Faulty parsing of variables with multi-line content
Description: 
cmake (above 2.8.7 up to master/head) fails to parse variables which have more
than two lines (and therefore two 'newline' character) in it. The outcome of it
is, that the project is unmakeable, because of the faulty produced makefiles.

As a minimal example I define multiple include directories in the variable
"GCC_INCLUDES" and hand it over to "include_directories", which produces the
"CXX_FLAGS" in "flags.make".
I give you first an working example with the corresponding output file, and then
an example with the faulty output:

Working "CMakeLists.txt"
-----------------------START
  cmake_minimum_required(VERSION 2.8.7 FATAL_ERROR)
  project ("helloWorld")
  set(GCC_INCLUDES "/test1\n/test2")
  include_directories(
      ${GCC_INCLUDES}
  )
  add_executable("helloWorld" main.cpp)
-----------------------END

Correct outputfile "CMakeFiles/helloWorld.dir/flags.make"
-----------------------START
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

# compile CXX with /usr/bin/c++
CXX_FLAGS = -I/test1 -I/test2

  CXX_DEFINES = 
-----------------------END

Faulty "CMakeLists.txt"
-----------------------START
  cmake_minimum_required(VERSION 2.8.7 FATAL_ERROR)
  project ("helloWorld")
  set(GCC_INCLUDES "/test1\n/test2\n/test3")
  include_directories(
      ${GCC_INCLUDES}
  )
  add_executable("helloWorld" main.cpp)
-----------------------END

Faulty outputfile "CMakeFiles/helloWorld.dir/flags.make"
-----------------------START
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

# compile CXX with /usr/bin/c++
CXX_FLAGS = -I/test1 -I/test2
/test3 -I/test3   

CXX_DEFINES = 
-----------------------END

Steps to Reproduce: 
Use the CMakeLists.txt files in the section "Description" and run "cmake ." to
produce the error message.

Example "main.cpp"
-----------------------START
#include <iostream>

using namespace std;

int main(void) {
 cout << "Hallo World" << endl;
 return 0;
}
-----------------------END

Additional Information: 
I tested the following cmake versions

OS: Ubuntu 12.04.4; cmake 2.8.7
Result: No parsing error

OS: Ubuntu 14.04.1; cmake 2.8.7
Result: No parsing error

OS: Ubuntu 14.04.1; cmake 2.12.2
Result: ERROR

OS: Ubuntu 14.04.1; cmake master/head (commit
d4525d7288ef935ee8b9d8cf338763498850364f)
Result: ERROR
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-10-18 16:52 Timo Korthals  New Issue                                    
======================================================================




More information about the cmake-developers mailing list