[CMake] Configuring .bat file with native path under windows

Nicolas Desprès nicolas.despres at gmail.com
Tue Oct 14 10:59:08 EDT 2008


On Tue, Oct 14, 2008 at 4:48 PM, Andy Lego <andy at legoandy.com> wrote:
> Hi,
>
> Look at FILE and STRING commands.

Thanks. That's what I did.

Here the wrapper I have written:

  # Wrapper around 'configure_file'
  # _in_: the input file
  # _out_ the output file
  # OPTIONS: the list of options to give to 'configure_file'.
  # VARIABLES: the list of variables to convert. The result is stored in a
  #            variable suffixed by '_in'. Use this variable in your template.
  function(configure_file_with_native_paths in out)

    parse_arguments(
      ${in}
      "OPTIONS;VARIABLES;"
      ""
      ${ARGN})

    foreach(var ${${in}_VARIABLES})
      string(REPLACE "/" "\\" ${var}_in "${${var}}")
    endforeach(var)

    configure_file(${in} ${out} ${${in}_OPTIONS})
  endfunction(configure_file_with_native_paths)

Cheers,

Nico

>
> Andy
>
> On Tue, Oct 14, 2008 at 7:29 AM, Nicolas Desprès <nicolas.despres at gmail.com>
> wrote:
>>
>> Hi everyone,
>>
>> I'm using cmake 2.6.2 for win32 and I'm trying to configure a .bat
>> file. I use a couple of cmake variable in my .bat.in template such as
>> CMAKE_CURRENT_BINARY_DIR. The problem is that I have to convert every
>> variable used in the template and containing a cmake path to a native
>> path before to configure the file. Currently, I'm using a wrapper
>> around configure_file to do the tricks but it is very cumbersome.
>>
>> Does any one know a better way to deal with this issue?
>> Is there any chance to have an option to configure_file that do the
>> tricks?
>>
>> Best regards,
>>
>> --
>> Nicolas Desprès
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>
>
>
> --
> Lets bike the world together
> http://legoandy.com
>



-- 
Nicolas Desprès


More information about the CMake mailing list