[CMake] Native Pathsupport under Windows
James Bigler
bigler at cs.utah.edu
Tue Oct 23 09:34:07 EDT 2007
On Oct 23, 2007, at 7:13 AM, Torsten Martinsen wrote:
> alexander at camek.de <> wrote:
>
>>> FILE(TO_NATIVE_PATH ...)
>>
>> When I do a FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR} RESULT)
>> and then use ${RESULT} I get the whole again with slashes.
>> So I can't use that with custom_command:
>> ADD_CUSTOM_COMMAND(...
>> COMMAND copy ${RESULT}\\image.h+${RESULT}\\test.h ${RESULT}\\image.h
>> VERBATIM)
>
> To copy files, use "${CMAKE_COMMAND} -E copy".
He doesn't just want to copy files, he wants to concatenate two files
(copy file1+file2 destfile). I doesn't look like cmake provides a
built in "cmake -E" command for that.
One possibility is to use a separate cmake script to do the
concatenation and run it as a command:
cmake_concatenate.cmake
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E copy ${FILE1} $
{DEST_FILE})
FILE(READ ${FILE2} file2_contents)
FILE(APPEND ${DEST_FILE} ${file2_contents})
########################
call it from regular CMakeLists.txt file
COMMAND ${CMAKE_COMMAND}
ARGS -P cmake_concatenate.cmake -DFILE1:STRING=${RESULT}/image.h -
DFILE2:STRING=${RESULT}/test.h -DDEST_FILE:STRING=${RESULT}/image.h
In this particular case the destination and the first source file are
the same, so a modified cmake_concatenate.cmake file could be more
appropriate.
James
More information about the CMake
mailing list