[CMake] Issues with execute_process and svn

David Cole david.cole at kitware.com
Wed Jul 13 14:05:39 EDT 2011


Take the double quotes off the set commands for your args variables.
And put spaces in between the dereferences of those vars in the
execute_process command.

Like this:

# No double quotes here:
if(NOT $ENV{CMAKE_SVN_USERNAME} STREQUAL "")
  set(_SvnCredPart --no-auth-cache)
  set(_SvnUserPart --username $ENV{CMAKE_SVN_USERNAME})
endif()
if(NOT $ENV{CMAKE_SVN_PASSWORD} STREQUAL "")
  set(_SvnCredPart --no-auth-cache)
  set(_SvnPassPart --password $ENV{CMAKE_SVN_PASSWORD})
endif()

# Spaces in between dereferenced vars here:
execute_process(COMMAND "${svnexe}" --non-interactive
  ${_SvnCredPart} ${_SvnUserPart} ${_SvnPassPart}
  info .
  OUTPUT_VARIABLE _out
  ERROR_VARIABLE _err
  RESULT_VARIABLE _res)

message(STATUS "out: ${_out}")
message(STATUS "err: ${_err}")
message(STATUS "res: ${_res}")


HTH,
David


On Wed, Jul 13, 2011 at 1:57 PM,  <aaron.meadows at thomsonreuters.com> wrote:
> Hi all,
>
>
>
> I’ve been having a devil of a time with executing SVN with execute_process.
> Basically, I need to read environment variables to specify the username and
> password for builds on our build server (where we do not cache credentials).
>
>
>
> I’ve made several attempts at this, and have been foiled continually by one
> problem, exemplified in the attached CMakeLists.txt.  If I build arguments
> in variables and then specify them in the execute_process, I get an error
> like this:
>
>
>
> -- err: svn.exe: invalid option: --no-auth-cache --username foo --password
> bar
>
> Type 'svn help' for usage.
>
>
>
> However, if I write the identical command to a file and execute that, I get
> no issue.  I’ve narrowed it down to the <space> between --username and foo,
> but can’t seem to figure out what the deal is.  I’ve tried replacing them
> with a value from string(ASCI 32 _sep), but that didn’t change the
> behavior.  I’ve tried this on Windows 7 and Windows Server 2008, and both
> behave the same way.
>
>
>
> You can try these two methods out on the CMakeLists.txt.  By default, it
> will use the straight execute_process.  If you call cmake with –D TestFile=1
> it will write the commands to a file and execute that.  (in which case
> you’ll get svn: '.' is not a working copy and not the invalid option issue)
>
>
>
> Thanks for any help you can provide!
>
>
>
> Aaron Meadows
> Software Engineer
>
> Thomson Reuters
>
> Phone: 314.468.3530
> Mobile: 636.541.6139
> aaron.meadows at thomsonreuters.com
> thomsonreuters.com
>
>
>
> This email was sent to you by Thomson Reuters, the global news and
> information company. Any views expressed in this message are those of the
> individual sender, except where the sender specifically states them to be
> the views of Thomson Reuters.
> _______________________________________________
> 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
>


More information about the CMake mailing list