madduci
madduci

Reputation: 2893

Generate a redistributable project with CMake

I'm looking for generating a redistributable project for Windows and Linux using CMake as project configuration system and gcc-4.8 / VS2012, plus extra thirdparty libraries like Qt5. How can i create a package with all the needed dependencies and make the project running on other machines, without installing on those machines the required packages (i.e. Qt5 setup)?

EDIT

Googling heavily i've found Qt5 requires some files and i've found this discussion Application deployed with QT5 libraries does not start on Windows 7

which explains the required Qt5 dependencies.

Upvotes: 9

Views: 3704

Answers (1)

user2033018
user2033018

Reputation:

Normally, I would use install to list the desired files and CPack for packaging them. That is, suppose I'd like to create a package consisting of the following components:

  • my_nifty_library.dll
  • my_nifty_executable.exe
  • QtCore.dll
  • QtGUI.dll

(Disclaimer: I'm not Qt expert so the last two files might not exist at all, but you get the idea.)

Given that both my_nifty_library and my_nifty_executable are part of your project, you have control over them, so simply do the following:

install(TARGETS my_nifty_library my_nifty_executable
        RUNTIME DESTINATION bin
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib)

Now, since Qt won't be built as part of your project, I suggest you use the ExternalProject module.

Now, you can use CPack and create, say, a NSIS installer or a tar.gz out of the installed files.

Upvotes: 1

Related Questions