[CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path
David Cole
david.cole at kitware.com
Mon Mar 14 12:17:07 EDT 2011
On Mon, Mar 14, 2011 at 11:17 AM, Urbach, Marcel [Rohmann GmbH]
<urbach at rohmann.de> wrote:
> I have already tried to use the SCRIPT. But there is a problem to submit the name of the dll or the project name to the extern script. I need something like a parameter and I guess that doesn't exsist. Do you have any ideas to solve this?
> INSTALL(SCRIPT "PostInst.cmake" PARAMETeR...)
>
How about something like this?
# File "script.cmake.in"
set(p1 "@param1@")
execute_process(COMMAND xyz ${p1} OUTPUT_VARIABLE ov RESULT_VARIABLE rv)
if(NOT rv STREQUAL "0")
message(FATAL_ERROR "xyz failed: rv='${rv}'")
endif()
And then:
# in CMakeLists.txt
set(param1 "value-of-p1")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/script.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/script.cmake @ONLY)
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/script.cmake")
I have written code in the past which calls regsvr32 successfully.
What are the arguments you are passing that are causing problems? Can
you call the same regsvr32 from the Windows command prompt
successfully? Are you using the same regsvr32 in both scenarios?
> I also tried to use execute_process, but it didn't work with regsvr32.
> It ended in an endless loop. Only a timeout could break it. Can you confirm that?
>
> -----Ursprüngliche Nachricht-----
> Von: David Cole [mailto:david.cole at kitware.com]
> Gesendet: Freitag, 11. März 2011 16:50
> An: Tyler
> Cc: Urbach, Marcel [Rohmann GmbH]; cmake at cmake.org
> Betreff: Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path
>
> Tyler's right. Use install(SCRIPT instead.
>
> And use execute_process instead of exec_program. It's better.
>
> From the help at
> http://cmake.org/cmake/help/cmake-2-8-docs.html#command:execute_process
> :
> "The execute_process command is a newer more powerful version of
> exec_program, but the old command has been kept for compatibility."
>
>
> On Fri, Mar 11, 2011 at 10:34 AM, Tyler <tyler at cryptio.net> wrote:
>> I believe the canonical answer is to write the command line you wish
>> to execute into a file and use install(SCRIPT ...) instead of
>> install(CODE ...).
>>
>> tyler
>>
>> On Fri, Mar 11, 2011 at 7:14 AM, Urbach, Marcel [Rohmann GmbH]
>> <urbach at rohmann.de> wrote:
>>> Hi,
>>>
>>> I am using Windows 7 and I have tried to register my builded dll files with
>>> regsvr32 after installing them. It works for paths without spaces.
>>>
>>>
>>>
>>> INSTALL( CODE
>>>
>>> "EXEC_PROGRAM( regsvr32 ARGS \"/s\" ARGS \"C:\\lib\\test.dll\"
>>> OUTPUT_VARIABLE POST_INST_OUT RETURN_VALUE POST_INST_RES )"
>>>
>>> )
>>>
>>>
>>>
>>> But when there a spaces inside a path regsvr32 returns with an error:
>>>
>>> "Error loading module "C:\Program".
>>>
>>>
>>>
>>> INSTALL( CODE
>>>
>>> "EXEC_PROGRAM( regsvr32 ARGS \"/s\" ARGS \"C:\\Program
>>> Files\\test\\lib\\test.dll\" OUTPUT_VARIABLE POST_INST_OUT RETURN_VALUE
>>> POST_INST_RES )"
>>>
>>> )
>>>
>>>
>>>
>>> I have spended the whole day escaping the path in the right way but I don't
>>> get it.
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>> _______________________________________________
>> 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
>>
> _______________________________________________
> 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