8

我正在尝试.msi使用cmake. .dll我能够.libCMakeLists.txt. 请提供一个示例CMakeLists.txt来生成.msi安装程序。我需要在命令提示符中使用哪些命令?

到目前为止,我使用的命令是:

> cmake -G"Visual Studio 10" -H"Root CMakeLists.txt path" -B"path to generate the sln"
> cmake --build "path of the sln" --config Release
> cpack -C Release
output: CPack Error: CPack generator not specified 

我使用以下配置来生成.dll.lib文件。

这是我的CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(mydll)
INCLUDE_DIRECTORIES(common/include) 
SET(my_lib_src dllmain.cpp mydll.cpp )
SET_SOURCE_FILES_PROPERTIES(${my_lib_src} PROPERTIES LANGUAGE C)
ADD_LIBRARY(mydll  SHARED ${my_lib_src})
SET_TARGET_PROPERTIES(mydll PROPERTIES 
LINKER_LANGUAGE C
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/common/bin                      
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/common/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/common/lib
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/common/lib)
install(TARGETS mydll 
  ARCHIVE
  DESTINATION lib
  COMPONENT libraries)
install(FILES mydll.h
  DESTINATION include
  COMPONENT headers)
set(CPACK_GENERATOR WIX)
set(CPACK_PACKAGE_NAME "mydll")
set(CPACK_PACKAGE_VENDOR "CMake.org")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example")
set(CPACK_PACKAGE_VERSION "1.0.0")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")

INCLUDE(CPack)
4

3 回答 3

8

您需要在运行 cpack 时设置生成器,而不是

3) cpack -C Release
output: CPack Error: CPack generator not specified

你应该指定

cpack -G WIX -C Release
于 2013-08-26T11:16:12.797 回答
2

在 CMake 2.8.11 中添加了 WiX 功能

于 2014-01-08T22:01:29.007 回答
0

似乎 MSI 不在 CPack 生成器列表中,尽管 CPack 有启用此功能的补丁。

见: http ://annealingtechnologies.blogspot.com/2010/02/wix-and-cpack-integration.html

于 2013-08-27T17:24:36.540 回答