View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015969CMakeCMakepublic2016-02-11 02:582016-06-10 14:21
ReporterA. Klitzing 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformiOSOSOSXOS Version10.10
Product Version 
Target VersionFixed in Version 
Summary0015969: String property broken in cmake 3.5.0-rc2 with XCode
DescriptionWe build our application for iOS with cmake and iOS toolchain file [1].

We pass some strings with "-D" property to the compiler. In cmake 3.5.0rc2 (rc1 not tested) the build will fail as the quotes of the strings are broken.

Same code works with cmake 3.4.1.


[1] https://github.com/cristeab/ios-cmake [^]
Steps To Reproduce1. cmake ../source -DCMAKE_BUILD_TYPE=release -DCMAKE_PREFIX_PATH=/[...]/dist -DCMAKE_TOOLCHAIN_FILE=../source/cmake/iOS.toolchain.cmake -GXcode

2. xcodebuild -target install -configuration Release

3. Compiler failed
Additional InformationSnippets of compiler cmdline:
See at -DVERSION=


3.5.0-rc2:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch armv7 [.....] -std=c++11 -ObjC++ -fPIC -DVERSION=\\1.6.3+5-default-53920e4f2686\\ -MMD -MT dependencies [...] -c /.../src/main.cpp -o /.../build/src/XYZ.build/Release-iphoneos/XYZ.build/Objects-normal/armv7/main.o



3.4.1:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch armv7 [.....] -std=c++11 -fPIC -DVERSION=\"1.6.3+5-default-53920e4f2686\" -MMD -MT dependencies -c /.../src/main.cpp -o /.../build/src/XYZ.build/Release-iphoneos/XYZ.build/Objects-normal/armv7/main.o




We use a little wrapper for quoted strings as XCode, windres and other compilers works different here.




FUNCTION(GET_QUOTED_STRING _dest _str _filename)
    IF(CMAKE_GENERATOR STREQUAL Xcode)
        SET(tmp_var \\\\"${_str}\\\\")
    ELSEIF(NOT ${arg} MATCHES ".rc$")
        SET(tmp_var \\"${_str}\\")
    ELSE()
        SET(tmp_var ${_str})
    ENDIF()

    SET(${_dest} ${tmp_var} PARENT_SCOPE)
ENDFUNCTION()

FUNCTION(ADD_STRING_DEFINITION _str _def)
    IF(ARGN)
        FOREACH(arg ${ARGN})
            IF (${arg} MATCHES "^AppTargetName")
                SET(ARG_TYPE TARGET)
            ELSE()
                SET(ARG_TYPE SOURCE)
            ENDIF()

            IF(NOT "${_str}" STREQUAL "")
                GET_QUOTED_STRING(tmp_var ${_str} ${arg})
                SET(tmp_var =${tmp_var})
            ENDIF()

            SET_PROPERTY(${ARG_TYPE} ${arg} APPEND_STRING PROPERTY COMPILE_FLAGS " -D${_def}${tmp_var}")
        ENDFOREACH()
    ELSE()
        IF(NOT "${_str}" STREQUAL "")
            GET_QUOTED_STRING(tmp_var ${_str} ${arg})
            SET(tmp_var =${tmp_var})
        ENDIF()
        ADD_DEFINITIONS(-D${_def}${tmp_var})
    ENDIF()
ENDFUNCTION()

FUNCTION(ADD_DEFINITION _def)
    ADD_STRING_DEFINITION("" ${_def} ${ARGN})
ENDFUNCTION()


##########################################

PROJECT(XYZ VERSION 1.6.3 CXX)
SET(VERSION_MERCURIAL ${PROJECT_VERSION}+5-default-53920e4f2686)
ADD_STRING_DEFINITION(${VERSION_MERCURIAL} "VERSION" main.cpp)
TagsNo tags attached.
Attached Files

 Relationships
related to 0015328closedGregor Jasny cmake generates corrupt Xcode projects for KDE projects 

  Notes
(0040470)
Brad King (manager)
2016-02-11 08:27

If you remove your CMAKE_GENERATOR==Xcode workaround does it work as expected? That looks like a workaround for the lack of the fix in 0015328.
(0040472)
A. Klitzing (reporter)
2016-02-11 09:42

Thanks for quick response!

Yeah, that was the problem... the build works again. We need to adjust our work-around. :-)

IF(CMAKE_GENERATOR STREQUAL Xcode AND CMAKE_VERSION VERSION_LESS "3.5")
(0040473)
Brad King (manager)
2016-02-11 09:58

Re 0015969:0040472: Thanks for checking. Normally we use a policy for behavior changes but in this case I think that would be too heavy since fixes to projects that worked around the bug are easy. I've added a release note for 3.5 to call attention to the change:

 Help: Add release note about Xcode escaping fix
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=878632c9 [^]
(0041255)
Kitware Robot (administrator)
2016-06-10 14:21

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2016-02-11 02:58 A. Klitzing New Issue
2016-02-11 08:25 Brad King Relationship added related to 0015328
2016-02-11 08:27 Brad King Note Added: 0040470
2016-02-11 09:42 A. Klitzing Note Added: 0040472
2016-02-11 09:58 Brad King Note Added: 0040473
2016-02-11 09:59 Brad King Status new => resolved
2016-02-11 09:59 Brad King Resolution open => no change required
2016-06-10 14:21 Kitware Robot Note Added: 0041255
2016-06-10 14:21 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team