Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path
Ok I finally got it to run. I've done it this way: EXECUTE_PROCESS(COMMAND cmd /c regsvr32 test.dll WORKING_DIRECTORY C:/Program Files/test/lib OUTPUT_VARIABLE ov RESULT_VARIABLE rv OUTPUT_STRIP_TRAILING_WHITESPACE ) Works fine, but there is still the problem to get the target build name for installing the dll because it differs from debug to release build. When the debug configuration was selected the debug dll should be installed and registered and vice versa for release. Do you have any ideas to solve this? -Ursprüngliche Nachricht- Von: David Cole [mailto:david.c...@kitware.com] Gesendet: Dienstag, 15. März 2011 17:05 An: Urbach, Marcel [Rohmann GmbH] Cc: cmake@cmake.org Betreff: Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path Generator expressions (like your TARGET_FILE_NAME:${project_name}) are only valid within the context of an add_custom_command call. Some are also available from the newer signature of the add_test command. See the docs for each of those for specific supported generator expressions. In the context of a CMake -P script (which an INSTALL(SCRIPT snippet is...) those are not interpreted in any way, and so will be passed directly as arguments to regsvr. You could see exactly what's being passed to the called executable by using a batch file or writing the tiniest c program possible to figure it all out. Boil it down to the very simplest script you can. Write an install script that has a bunch of hard-coded values in it until you have an execute_process command line that works. Then gradually generalize it from there. I think that approach will show you that execute_process works just fine if you pass it reasonable arguments. HTH, David On Tue, Mar 15, 2011 at 5:11 AM, Urbach, Marcel [Rohmann GmbH] urb...@rohmann.de wrote: Hi David Your solution works fine, but i still got the problem with execute_process. Right now I use it this way: #cmakelists.txt ADD_LIBRARY(${project_name} SHARED ${sources} ${headers} ${idls} ${generated} ${resources} ) SET(project_out ${INSTALL_LIB_DIR}/${project_name}_d.dll) STRING(REGEX REPLACE / project_out ${project_out} ) register_shared_libraries(${project_name} ${project_out} ) #global.cmake FUNCTION(register_shared_libraries) IF (WIN32) SET(param1 ${ARGV0}) SET(param2 ${ARGV1}) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/post_install.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/post_install.cmake @ONLY ) INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/post_install.cmake) ENDIF() ENDFUNCTION() #post_install.cmake.in SET(file_name @param2@) MESSAGE(STATUS file_name: ${file_name}) EXEC_PROGRAM( regsvr32 ARGS \/s\ ARGS \${file_name}\ OUTPUT_VARIABLE ov RETURN_VALUE rv ) MESSAGE(out ${ov}) MESSAGE(res ${rv}) SET(project_name @param1@) MESSAGE(STATUS project_name: ${project_name}) EXECUTE_PROCESS(COMMAND regsvr32 #$TARGET_FILE:${project_name} INPUT_FILE $TARGET_FILE_NAME:${project_name} WORKING_DIRECTORY $TARGET_FILE_DIR:${project_name} OUTPUT_VARIABLE ov RESULT_VARIABLE rv ) MESSAGE(out ${ov}) MESSAGE(res ${rv}) The first version using EXEC_PROGRAM works fine, but there is a problem resolving the target name. XXX.dll for release or XXX_d.for debug. The second (EXECUTE_PROCESS) never returns from regsvr32 when using regsvr32 #$TARGET_FILE:${project_name} or it says wrong syntax for file name or dir name when using regsvr32 INPUT_FILE $TARGET_FILE_NAME:${project_name} WORKING_DIRECTORY $TARGET_FILE_DIR:${project_name} -Ursprüngliche Nachricht- Von: David Cole [mailto:david.c...@kitware.com] Gesendet: Montag, 14. März 2011 17:17 An: Urbach, Marcel [Rohmann GmbH] Cc: cmake@cmake.org Betreff: Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path On Mon, Mar 14, 2011 at 11:17 AM, Urbach, Marcel [Rohmann GmbH] urb...@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
Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path
When you are running an install SCRIPT it is simply included in the context of the file cmake_install.cmake. So you can reference variables that are in use in the including file inside your install SCRIPT file. Read through the contents of a typical cmake_install.cmake to get more ideas about what's possible in this context. For this case, I would reference the CMAKE_INSTALL_CONFIG_NAME variable, something like this: if(CMAKE_INSTALL_CONFIG_NAME STREQUAL Debug) set(filename test_d.dll) set(dir C:/Program Files/test/lib) else() set(filename test.dll) set(dir C:/Program Files/test/lib) endif() EXECUTE_PROCESS(COMMAND cmd /c regsvr32 ${filename} WORKING_DIRECTORY ${dir} OUTPUT_VARIABLE ov RESULT_VARIABLE rv OUTPUT_STRIP_TRAILING_WHITESPACE ) HTH, David On Thu, Mar 17, 2011 at 12:03 PM, Urbach, Marcel [Rohmann GmbH] urb...@rohmann.de wrote: Ok I finally got it to run. I've done it this way: EXECUTE_PROCESS(COMMAND cmd /c regsvr32 test.dll WORKING_DIRECTORY C:/Program Files/test/lib OUTPUT_VARIABLE ov RESULT_VARIABLE rv OUTPUT_STRIP_TRAILING_WHITESPACE ) Works fine, but there is still the problem to get the target build name for installing the dll because it differs from debug to release build. When the debug configuration was selected the debug dll should be installed and registered and vice versa for release. Do you have any ideas to solve this? -Ursprüngliche Nachricht- Von: David Cole [mailto:david.c...@kitware.com] Gesendet: Dienstag, 15. März 2011 17:05 An: Urbach, Marcel [Rohmann GmbH] Cc: cmake@cmake.org Betreff: Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path Generator expressions (like your TARGET_FILE_NAME:${project_name}) are only valid within the context of an add_custom_command call. Some are also available from the newer signature of the add_test command. See the docs for each of those for specific supported generator expressions. In the context of a CMake -P script (which an INSTALL(SCRIPT snippet is...) those are not interpreted in any way, and so will be passed directly as arguments to regsvr. You could see exactly what's being passed to the called executable by using a batch file or writing the tiniest c program possible to figure it all out. Boil it down to the very simplest script you can. Write an install script that has a bunch of hard-coded values in it until you have an execute_process command line that works. Then gradually generalize it from there. I think that approach will show you that execute_process works just fine if you pass it reasonable arguments. HTH, David On Tue, Mar 15, 2011 at 5:11 AM, Urbach, Marcel [Rohmann GmbH] urb...@rohmann.de wrote: Hi David Your solution works fine, but i still got the problem with execute_process. Right now I use it this way: #cmakelists.txt ADD_LIBRARY(${project_name} SHARED ${sources} ${headers} ${idls} ${generated} ${resources} ) SET(project_out ${INSTALL_LIB_DIR}/${project_name}_d.dll) STRING(REGEX REPLACE / project_out ${project_out} ) register_shared_libraries(${project_name} ${project_out} ) #global.cmake FUNCTION(register_shared_libraries) IF (WIN32) SET(param1 ${ARGV0}) SET(param2 ${ARGV1}) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/post_install.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/post_install.cmake @ONLY ) INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/post_install.cmake) ENDIF() ENDFUNCTION() #post_install.cmake.in SET(file_name @param2@) MESSAGE(STATUS file_name: ${file_name}) EXEC_PROGRAM( regsvr32 ARGS \/s\ ARGS \${file_name}\ OUTPUT_VARIABLE ov RETURN_VALUE rv ) MESSAGE(out ${ov}) MESSAGE(res ${rv}) SET(project_name @param1@) MESSAGE(STATUS project_name: ${project_name}) EXECUTE_PROCESS(COMMAND regsvr32 #$TARGET_FILE:${project_name} INPUT_FILE $TARGET_FILE_NAME:${project_name} WORKING_DIRECTORY $TARGET_FILE_DIR:${project_name} OUTPUT_VARIABLE ov RESULT_VARIABLE rv ) MESSAGE(out ${ov}) MESSAGE(res ${rv}) The first version using EXEC_PROGRAM works fine, but there is a problem resolving the target name. XXX.dll for release or XXX_d.for debug. The second (EXECUTE_PROCESS) never returns from regsvr32 when using regsvr32 #$TARGET_FILE:${project_name} or it says wrong syntax for file name or dir name when using regsvr32 INPUT_FILE $TARGET_FILE_NAME:${project_name} WORKING_DIRECTORY $TARGET_FILE_DIR:${project_name} -Ursprüngliche Nachricht- Von: David Cole [mailto:david.c...@kitware.com] Gesendet: Montag, 14. März 2011 17:17 An: Urbach, Marcel [Rohmann GmbH] Cc: cmake@cmake.org Betreff: Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path On Mon, Mar 14, 2011 at 11:17 AM, Urbach, Marcel [Rohmann GmbH] urb...@rohmann.de wrote: I have already tried to use the SCRIPT. But there is a problem to submit the name
Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path
Hi David Your solution works fine, but i still got the problem with execute_process. Right now I use it this way: #cmakelists.txt ADD_LIBRARY(${project_name} SHARED ${sources} ${headers} ${idls} ${generated} ${resources} ) SET(project_out ${INSTALL_LIB_DIR}/${project_name}_d.dll) STRING(REGEX REPLACE / project_out ${project_out} ) register_shared_libraries(${project_name} ${project_out} ) #global.cmake FUNCTION(register_shared_libraries) IF (WIN32) SET(param1 ${ARGV0}) SET(param2 ${ARGV1}) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/post_install.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/post_install.cmake @ONLY ) INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/post_install.cmake) ENDIF() ENDFUNCTION() #post_install.cmake.in SET(file_name @param2@) MESSAGE(STATUS file_name: ${file_name}) EXEC_PROGRAM( regsvr32 ARGS \/s\ ARGS \${file_name}\ OUTPUT_VARIABLE ov RETURN_VALUE rv ) MESSAGE(out ${ov}) MESSAGE(res ${rv}) SET(project_name @param1@) MESSAGE(STATUS project_name: ${project_name}) EXECUTE_PROCESS(COMMAND regsvr32 #$TARGET_FILE:${project_name} INPUT_FILE $TARGET_FILE_NAME:${project_name} WORKING_DIRECTORY $TARGET_FILE_DIR:${project_name} OUTPUT_VARIABLE ov RESULT_VARIABLE rv ) MESSAGE(out ${ov}) MESSAGE(res ${rv}) The first version using EXEC_PROGRAM works fine, but there is a problem resolving the target name. XXX.dll for release or XXX_d.for debug. The second (EXECUTE_PROCESS) never returns from regsvr32 when using regsvr32 #$TARGET_FILE:${project_name} or it says wrong syntax for file name or dir name when using regsvr32 INPUT_FILE $TARGET_FILE_NAME:${project_name} WORKING_DIRECTORY $TARGET_FILE_DIR:${project_name} -Ursprüngliche Nachricht- Von: David Cole [mailto:david.c...@kitware.com] Gesendet: Montag, 14. März 2011 17:17 An: Urbach, Marcel [Rohmann GmbH] Cc: cmake@cmake.org Betreff: Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path On Mon, Mar 14, 2011 at 11:17 AM, Urbach, Marcel [Rohmann GmbH] urb...@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.c...@kitware.com] Gesendet: Freitag, 11. März 2011 16:50 An: Tyler Cc: Urbach, Marcel [Rohmann GmbH]; cmake@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 ty...@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] urb...@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
Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path
Generator expressions (like your TARGET_FILE_NAME:${project_name}) are only valid within the context of an add_custom_command call. Some are also available from the newer signature of the add_test command. See the docs for each of those for specific supported generator expressions. In the context of a CMake -P script (which an INSTALL(SCRIPT snippet is...) those are not interpreted in any way, and so will be passed directly as arguments to regsvr. You could see exactly what's being passed to the called executable by using a batch file or writing the tiniest c program possible to figure it all out. Boil it down to the very simplest script you can. Write an install script that has a bunch of hard-coded values in it until you have an execute_process command line that works. Then gradually generalize it from there. I think that approach will show you that execute_process works just fine if you pass it reasonable arguments. HTH, David On Tue, Mar 15, 2011 at 5:11 AM, Urbach, Marcel [Rohmann GmbH] urb...@rohmann.de wrote: Hi David Your solution works fine, but i still got the problem with execute_process. Right now I use it this way: #cmakelists.txt ADD_LIBRARY(${project_name} SHARED ${sources} ${headers} ${idls} ${generated} ${resources} ) SET(project_out ${INSTALL_LIB_DIR}/${project_name}_d.dll) STRING(REGEX REPLACE / project_out ${project_out} ) register_shared_libraries(${project_name} ${project_out} ) #global.cmake FUNCTION(register_shared_libraries) IF (WIN32) SET(param1 ${ARGV0}) SET(param2 ${ARGV1}) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/post_install.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/post_install.cmake @ONLY ) INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/post_install.cmake) ENDIF() ENDFUNCTION() #post_install.cmake.in SET(file_name @param2@) MESSAGE(STATUS file_name: ${file_name}) EXEC_PROGRAM( regsvr32 ARGS \/s\ ARGS \${file_name}\ OUTPUT_VARIABLE ov RETURN_VALUE rv ) MESSAGE(out ${ov}) MESSAGE(res ${rv}) SET(project_name @param1@) MESSAGE(STATUS project_name: ${project_name}) EXECUTE_PROCESS(COMMAND regsvr32 #$TARGET_FILE:${project_name} INPUT_FILE $TARGET_FILE_NAME:${project_name} WORKING_DIRECTORY $TARGET_FILE_DIR:${project_name} OUTPUT_VARIABLE ov RESULT_VARIABLE rv ) MESSAGE(out ${ov}) MESSAGE(res ${rv}) The first version using EXEC_PROGRAM works fine, but there is a problem resolving the target name. XXX.dll for release or XXX_d.for debug. The second (EXECUTE_PROCESS) never returns from regsvr32 when using regsvr32 #$TARGET_FILE:${project_name} or it says wrong syntax for file name or dir name when using regsvr32 INPUT_FILE $TARGET_FILE_NAME:${project_name} WORKING_DIRECTORY $TARGET_FILE_DIR:${project_name} -Ursprüngliche Nachricht- Von: David Cole [mailto:david.c...@kitware.com] Gesendet: Montag, 14. März 2011 17:17 An: Urbach, Marcel [Rohmann GmbH] Cc: cmake@cmake.org Betreff: Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path On Mon, Mar 14, 2011 at 11:17 AM, Urbach, Marcel [Rohmann GmbH] urb...@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.c...@kitware.com] Gesendet: Freitag, 11. März 2011 16:50 An: Tyler Cc: Urbach, Marcel [Rohmann GmbH]; cmake@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
Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path
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...) 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.c...@kitware.com] Gesendet: Freitag, 11. März 2011 16:50 An: Tyler Cc: Urbach, Marcel [Rohmann GmbH]; cmake@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 ty...@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] urb...@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
Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path
On Mon, Mar 14, 2011 at 11:17 AM, Urbach, Marcel [Rohmann GmbH] urb...@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.c...@kitware.com] Gesendet: Freitag, 11. März 2011 16:50 An: Tyler Cc: Urbach, Marcel [Rohmann GmbH]; cmake@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 ty...@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] urb...@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 ___ 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
Re: [CMake] INSTALL CODE using EXEC_PROGRAM with spaces in path
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] urb...@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
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 ty...@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] urb...@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