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
[email protected]
<mailto:[email protected]>
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.cmake_minimum_required(VERSION 2.8)
## Setup the environment for you, this would usually be done by something else)
set(ENV{CMAKE_SVN_USERNAME} foo)
set(ENV{CMAKE_SVN_PASSWORD} bar)
find_program(svnexe svn DOC "subversion command line client")
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()
if(DEFINED TestFile)
file(WRITE "${CMAKE_BINARY_DIR}/svncmd.cmd"
"@\"${svnexe}\" --non-interactive
${_SvnCredPart}${_SvnUserPart}${_SvnPassPart} info .")
execute_process(COMMAND "${CMAKE_BINARY_DIR}/svncmd.cmd"
OUTPUT_VARIABLE _out
ERROR_VARIABLE _err
RESULT_VARIABLE _res)
else()
execute_process(COMMAND "${svnexe}" --non-interactive
${_SvnCredPart}${_SvnUserPart}${_SvnPassPart}
info .
OUTPUT_VARIABLE _out
ERROR_VARIABLE _err
RESULT_VARIABLE _res)
endif()
message(STATUS "out: ${_out}")
message(STATUS "err: ${_err}")
message(STATUS "res: ${_res}")
_______________________________________________
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