add_custom_target(NSISTest_Preprocess SOURCES precompress.nsi)
add_custom_command(TARGET NSISTest_Preprocess POST_BUILD
COMMAND "${NSIS_PATH}" "...\\precompress.nsi")
安装程序的输出名称在nsi脚本中定义。现在我想简单地运行安装程序。当我在Visual Studio 2010中使用'Debug-> Start Debugging'或'Debug-> Start Without Debugging'时,如何指定应该发生什么?
我尝试了生成.user文件的CreateLaunchers.cmake脚本,但我认为它只适用于add_executable
。
我还尝试了目标属性ARCHIVE_OUTPUT_NAME
,LIBRARY_OUTPUT_NAME
,RUNTIME_OUTPUT_NAME
,但它们都没有任何效果。
答案 0 :(得分:1)
.user
设置方法也适用于自定义目标。您可以添加 - 如果路径已知 - 安装程序的.exe
作为调试器应该使用'Debug-> Start Debugging'调用的命令。
<强> VS2010Test-Debug.vcxproj.user.in 强>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>${_my_installer_path}</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
<强>的CMakeLists.txt 强>
...
if (MSVC_VERSION GREATER 1599 AND
NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/NSISTest_Preprocess.vcxproj.user")
file(TO_NATIVE_PATH "[your installer's path goes here]" _my_installer_path)
configure_file(
"VS2010Test-Debug.vcxproj.user.in"
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/NSISTest_Preprocess.vcxproj.user"
)
file(
COPY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/NSISTest_Preprocess.vcxproj.user"
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}"
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
<强>背景强>
.user
文件的外部更改configure_file()
维护)<强>参考强>