[CMake] Fwd: Re: how to do this: svn info?
Totte Karlsson
totte at dunescientific.com
Fri Jun 29 17:15:55 EDT 2012
That tip worked fine!
I ended up doing
STRING(REPLACE "\n" "\\n\\\n" svn_lastlog_with_slashes ${rr_LAST_CHANGED_LOG})
So when reading the char constant newlines are embedded.
tk
On 6/28/2012 11:08 PM, m.hergarden wrote:
>
>
> Will a string replace combo help in your case? We use it to replace line
> endings with ; to make a cmake list variable from a filelist:
>
> STRING(REPLACE "\n" "\\" svn_lastlog_with_slashes ${svn_lastlog})
>
> regards,
> Micha
>
> On 06/29/2012 01:56 AM, Totte Karlsson wrote:
>> Hi,
>>
>> I'm trying to get some svn information into a build of a C library.
>>
>> The cmake currently looks like this (gathered from various posts)
>>
>> INCLUDE(FindSubversion)
>> IF(SUBVERSION_FOUND)
>> Subversion_WC_INFO(${PROJECT_SOURCE_DIR} rr)
>> Subversion_WC_LOG(${PROJECT_SOURCE_DIR} rr)
>>
>> SET(infoFile rr_svn_info)
>>
>> FILE(WRITE ${infoFile}.txt
>> "#ifndef ${infoFile}H
>> #define ${infoFile}H
>> const int SVN_VERSION = ${rr_WC_REVISION};\n
>> const char* SVN_LAST_COMMIT_AUTHOR =\"${rr_WC_LAST_CHANGED_AUTHOR}\";\n
>> const char* SVN_LASTLOG =\" ${rr_LAST_CHANGED_LOG}\";\n
>> #endif"
>> )
>>
>> EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different
>> ${infoFile}.txt ${infoFile}.h)
>> ENDIF(SUBVERSION_FOUND)
>>
>>
>> Currently I have two problems:
>> When generating the header, the svn_lastlog expands to something like
>>
>> const char* SVN_LASTLOG ="
>> ------------------------------------------------------------------------
>> r505 | tottek | 2012-06-28 14:11:49 -0700 (Thu, 28 Jun 2012) | 20 lines
>>
>> New release
>> ..... etc..
>>
>> The above will not compile, because a string spanning multiple lines
>> in C must have a continuation character at the end of each line, e.g.
>>
>> const char* SVN_LASTLOG ="\
>> ------------------------------------------------------------------------\
>> r505 | tottek | 2012-06-28 14:11:49 -0700 (Thu, 28 Jun 2012) | 20 lines\
>> .... etc...
>>
>> How would one solve that in CMake?
>>
>> The second problem is the execute process command
>> EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different
>> ${infoFile}.txt ${infoFile}.h)
>>
>> which do create the txt file, but fails to copy it to the .h file.
>> Just getting an error saying
>> Error copying file (if different) from "the txt file" to "the h file"
>>
>> Any tips?
>>
>> -totte
>>
>
>
>
>
>
More information about the CMake
mailing list