MantisBT - CMake
View Issue Details
0007316CMakeCMakepublic2008-07-09 11:202008-07-16 10:40
Matt Leotta 
Bill Hoffman 
normalmajoralways
closedfixed 
CMake-2-6 
 
0007316: TRY_RUN fails to compile with generator for Xcode
CMake 2.6.0 seems produces faulty Xcode projects for running TRY_RUN tests in some cases. These fail to compile. It seems to be related to the use of double quote characters in
CMAKE_FLAGS -DCOMPILE_DEFINTIONS:STRING=${SOME_STRING}

For example, if SOME_STRING is "-I \"/some/path\"" it will fail whereas if it is "-I /some/path" it will work fine. The quotes are needed in case the path contains spaces. This was discovered while compiling VXL. This comes up in the DETERMINE_TYPE macro in vxl/src/config/cmake/config/vxl_config_macros.cmake. As a result vxl_byte, vxl_int_32, etc are all defined to be void.
Mac OS X 10.5.4 (Intel)
Xcode 3.0
CMake 2.6.0

I've attached a simple CMakeLists.txt file that isolates the problem.

The error message from TRY_RUN is:
Change Dir: /projects/test/my bin/CMakeFiles/CMakeTmp

Run Build Command:/Applications/CMake\ 2.6-0.app/Contents/bin/cmakexbuild -project
CMAKE_TRY_COMPILE.xcodeproj build -target cmTryCompileExec -configuration Debug
2008-07-09 08:32:20.045 xcodebuild[4650:613] CFPropertyListCreateFromXMLData():
        Old-style plist parser: missing semicolon in dictionary.
2008-07-09 08:32:20.046 xcodebuild[4650:613] XML parser error:
        Unexpected character / at line 1
Old-style plist parser error:
        Missing ';' on line 168
xcodebuild: Error: couldn't load project
        /projects/test/my bin/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.xcodeproj
No tags attached.
related to 0007315closed Bradley Lowekamp ITK XCode 3.0 builds of ITK fail in vnl_matlab_header.h 
related to 0004022closed Bill Hoffman CMake Xcode generator produce invalid code when there is a quote in a string 
txt CMakeLists.txt (2,530) 2008-07-09 11:20
https://public.kitware.com/Bug/file/1588/CMakeLists.txt
Issue History
2008-07-09 11:20Matt LeottaNew Issue
2008-07-09 11:20Matt LeottaFile Added: CMakeLists.txt
2008-07-14 17:09Hans JohnsonNote Added: 0012697
2008-07-14 17:28Brad KingRelationship addedrelated to 0007315
2008-07-14 17:47Brad KingRelationship addedrelated to 0004022
2008-07-14 17:48Brad KingNote Added: 0012699
2008-07-16 09:27Bill HoffmanNote Added: 0012718
2008-07-16 09:33Brad KingNote Added: 0012719
2008-07-16 09:41Matt LeottaNote Added: 0012720
2008-07-16 09:53Brad KingNote Added: 0012721
2008-07-16 10:40Brad KingStatusnew => assigned
2008-07-16 10:40Brad KingAssigned To => Bill Hoffman
2008-07-16 10:40Brad KingStatusassigned => closed
2008-07-16 10:40Brad KingResolutionopen => fixed

Notes
(0012697)
Hans Johnson   
2008-07-14 17:09   
This is the same problem as 0007315.
(0012699)
Brad King   
2008-07-14 17:48   
The fix to bug 0004022 introduced this bug. It added escaping to all string values in Xcode projects, but some values were already escaped.
(0012718)
Bill Hoffman   
2008-07-16 09:27   
I fixed the issue. However, this is a really bad way to do a try compile as the -I"path" does not work with several compilers. I added this as a test to cmake, and it failed on several compilers. For example on the sun it did this:


  /opt/SUNWspro/bin/CC -I
  "/home/kitware/Dashboards/MyTests/CMake-CC/Tests/TryCompile/CMakeTmp" -o
  CMakeFiles/cmTryCompileExec.dir/my_test.cxx.o -c
  /home/kitware/Dashboards/MyTests/CMake-CC/Tests/TryCompile/my_test.cxx

  CC: Invalid input file name
  /home/kitware/Dashboards/MyTests/CMake-CC/Tests/TryCompile/CMakeTmp, no
  output generated for this file.

Best to change the test to use INCLUDE_DIRECTORIES somehow.
(0012719)
Brad King   
2008-07-16 09:33   
FYI, you can specify include directories with this option:

CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING=/some/include/dir;/other/include/dir
(0012720)
Matt Leotta   
2008-07-16 09:41   
Thanks, I will update the VXL tests using Brad's suggestion. But I have two questions:

Is it safe (or even appropriate) to use quotes with -DINCLUDE_DIRECTORIES if there is a possibility of spaces in the include path?

Is -DINCLUDE_DIRECTORIES supported in CMake 2.4? VXL is still supporting CMake >= 2.4.5
(0012721)
Brad King   
2008-07-16 09:53   
Will system include dirs really have spaces in the path? Anyway, the INCLUDE_DIRECTORIES thing is implemented by writing

  INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})

in the generated CMakeLists.txt file. The INCLUDE_DIRECTORIES definition is expanded by the CMake language, which only separates on semicolon (not space). Therefore you should not have to quote anything. Of course it wouldn't hurt to quote it in the call to TRY_COMPILE:

  "-DINCLUDE_DIRECTORIES:STRING=/some/include/dir;/other/include/dir"

Oh, and this has been in CMake since 2002 so it's definately in 2.4.