The following issue has been SUBMITTED. 
====================================================================== 
https://public.kitware.com/Bug/view.php?id=15969 
====================================================================== 
Reported By:                A. Klitzing
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15969
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2016-02-11 02:58 EST
Last Modified:              2016-02-11 02:58 EST
====================================================================== 
Summary:                    String property broken in cmake 3.5.0-rc2 with XCode
Description: 
We 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 Reproduce: 
1. 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 Information: 
Snippets 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)

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2016-02-11 02:58 A. Klitzing    New Issue                                    
======================================================================

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to