我正在尝试使用cmake生成.msi安装程序.我能够在CMakeLists.txt中使用一些配置生成.dll和.lib文件.请提供示例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)