[CMake] file(READ) issue?

Steven Van Ingelgem steven at vaningelgem.be
Wed Mar 25 11:26:34 EDT 2009


What I did (and solved the issue) is:
file(READ "zconf.in.h" ZCONF_H)
STRING(REPLACE "HAVE_STD_HEADERS_H" ${HAVE_STD_HEADERS_H} "${ZCONF_H}")
file(WRITE "zconf.test" "${ZCONF_H}")

Especially the quotes around the variable are important as otherwise CMake
think it's an array and not a string... I think :)




2009/3/25 David Cole <david.cole at kitware.com>

> ";" is the CMake list element separator character. The ";" are still there
> in the variable, you probably just can't see them with your processing code
> that comes after reading in the file...
>
> You can replace semi-colons like this with escaped semi-colons:
>   STRING(REGEX REPLACE ";" "\\\\;" ZCONF_H "${ZCONF_H}")
>
> Then CMake will treat the variable ZCONF_H as one large string that has
> embedded (escaped) semi-colons in it.
>
>
> HTH,
> David
>
>
> On Sun, Mar 22, 2009 at 6:07 AM, Steven Van Ingelgem <
> steven at vaningelgem.be> wrote:
>
>> Hi,
>>
>>
>> I'm trying to read in a C-header file with "file(READ)":
>>   file(READ "zconf.in.h" ZCONF_H)
>>
>> !! But this variable contains no ";" whatsoever?
>>
>> How can I ask to read it in completely?
>>
>>
>> Thanks,
>> Steven
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090325/35b9443a/attachment.htm>


More information about the CMake mailing list