View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014923CMakeModulespublic2014-05-21 05:242015-01-05 08:39
Reporterskvadrik 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
Platformamd64OSGentoo LinuxOS Version3.14.1
Product VersionCMake 2.8.12.2 
Target VersionCMake 3.1Fixed in VersionCMake 3.1 
Summary0014923: check_cxx_compiler_flag fails when variable name contains "++"
DescriptionThe following call:

check_cxx_compiler_flag(-Weffc++ CXX_FLAG_-Weffc++)

Leads to the following error:

RegularExpression::compile(): Nested *?+.
RegularExpression::compile(): Error in compile.
CMake Error at /usr/share/cmake/Modules/CheckCXXSourceCompiles.cmake:30 (if):
  if given arguments:

    "LJS_CXX_FLAG_-Weffc++" "MATCHES" "^LJS_CXX_FLAG_-Weffc++\$"

  Regular expression "^LJS_CXX_FLAG_-Weffc++$" cannot compile
Steps To Reproducecheck_cxx_compiler_flag(-Weffc++ CXX_FLAG_-Weffc++)
Additional Informationcheck_cxx_compiler_flag calls check_cxx_source_compiles. The latter tries to
interpret variable name as a regexp:

if("${VAR}" MATCHES "^${VAR}$")

which leads to an error for a variable name "CXX_FALG_-Weffc++" (and many other
variable names, which are generally accepted by cmake)
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0036512)
Rolf Eike Beer (developer)
2014-07-31 04:48

Can't this just be "if (NOT VAR)"?
(0036515)
skvadrik (reporter)
2014-07-31 05:33

Maybe it can, it's in the source code of cmake module CheckCXXSourceCompiles
(not in my source).

I just meant that the following call:
    check_cxx_compiler_flag(-Weffc++ CXX_FLAG_-Weffc++)
shouldn't cause errors, because CXX_FLAG_-Weffc++ is a valid identifier.

So the bug is in CheckCXXSourceCompiles, not in cmake (see bug's category).
(0036517)
Rolf Eike Beer (developer)
2014-07-31 05:51

Yes, absolutely. The question was more in the direction of Brad ;)
(0036520)
Brad King (manager)
2014-07-31 08:39

Re 0014923:0036512: That logic is an ancient hack from before we had if(DEFINED). Try this patch:

diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake
index 6ce64a1..edd62a6 100644
--- a/Modules/CheckCXXSourceCompiles.cmake
+++ b/Modules/CheckCXXSourceCompiles.cmake
@@ -39,7 +39,7 @@
 
 
 macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
- if("${VAR}" MATCHES "^${VAR}$")
+ if(NOT DEFINED "${VAR}")
     set(_FAIL_REGEX)
     set(_key)
     foreach(arg ${ARGN})
(0036522)
skvadrik (reporter)
2014-07-31 08:47

It works, thank you!
Is this patch in HEAD already?
(0036526)
skvadrik (reporter)
2014-07-31 08:57

By the way, other modules have this error too:
   33:CheckFunctionExists.cmake 30:CheckCSourceRuns.cmake 45:CheckSymbolExists.cmake 30:CheckCXXSourceCompiles.cmake 32:CheckIncludeFile.cmake 30:CheckCXXSourceRuns.cmake 29:CheckIncludeFiles.cmake 30:CheckCSourceCompiles.cmake 32:CheckIncludeFileCXX.cmake 32:CheckVariableExists.cmake 32:CheckLibraryExists.cmake 282:ExternalData.cmake

I searched for regexp 'if\("\$\{.*\}" MATCHES "\^\$\{.*\}\$"\)' in /usr/share/cmake/Modules.
(0036536)
Brad King (manager)
2014-07-31 10:10

Re 0014923:0036526: Thanks. I've fixed it in all the modules:

 Check*: Allow result variables to contain regex special characters (0014923)
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4f2fcce4 [^]
(0036537)
skvadrik (reporter)
2014-07-31 10:16

Thank you!
(0037603)
Robert Maynard (manager)
2015-01-05 08:39

Closing resolved issues that have not been updated in more than 4 months

 Issue History
Date Modified Username Field Change
2014-05-21 05:24 skvadrik New Issue
2014-07-31 04:48 Rolf Eike Beer Note Added: 0036512
2014-07-31 05:33 skvadrik Note Added: 0036515
2014-07-31 05:51 Rolf Eike Beer Note Added: 0036517
2014-07-31 08:39 Brad King Note Added: 0036520
2014-07-31 08:47 skvadrik Note Added: 0036522
2014-07-31 08:57 skvadrik Note Added: 0036526
2014-07-31 10:10 Brad King Note Added: 0036536
2014-07-31 10:16 skvadrik Note Added: 0036537
2014-07-31 10:26 Brad King Status new => resolved
2014-07-31 10:26 Brad King Resolution open => fixed
2014-07-31 10:26 Brad King Fixed in Version => CMake 3.1
2014-07-31 10:26 Brad King Target Version => CMake 3.1
2015-01-05 08:39 Robert Maynard Note Added: 0037603
2015-01-05 08:39 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team