Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate .msi installer with cmake?

I am trying to generate .msi installer with cmake. I am able to generate .dll and .lib files with some configuration in CMakeLists.txt. Please provide an example CMakeLists.txt to generate an .msi installer. What are the commands that I need to use in the command prompt ?

The commands that I am using so far are:

> 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 

I used the following configuration to generate the .dll and .lib files.

Here is my 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)
like image 446
123r789 Avatar asked Aug 26 '13 05:08

123r789


2 Answers

You need to set the generator when you run cpack so instead of

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

You should specify

cpack -G WIX -C Release
like image 84
drescherjm Avatar answered Oct 15 '22 16:10

drescherjm


The WiX capability was added in CMake 2.8.11

like image 30
Steve Huston Avatar answered Oct 15 '22 18:10

Steve Huston