Tzalumen
Tzalumen

Reputation: 660

How do I link to Licensed Qt Libraries statically with CMake using find_package?

I'm porting a Visual Studio 2010 project to CMake and Visual Studio 2015. I have it building and linking with default behavior w/regards to Qt

find_package (Qt5 5.9.3 COMPONENTS
    Core
    Multimedia
    Network
    Widgets
    Xml
    XmlPatterns
    REQUIRED)

What I want to do is take advantage of the fact that I have a developer license and should have the ability to static link to the Qt libraries without building from source, significantly cleaning up my application directory.

I am setting up the linkage with

target_link_libraries (${ProjectName}
    Qt5::Core
    Qt5::Multimedia
    Qt5::Network
    Qt5::Widgets
    Qt5::Xml
    Qt5::XmlPatterns)

what else do I need to make it link statically?

Upvotes: 1

Views: 755

Answers (1)

J-Christophe
J-Christophe

Reputation: 2060

In case this is not already done, you will have to build Qt statically.

In a nutshell, you have to install perl, python, optionally jom and follow the instruction at https://doc.qt.io/qt-5/windows-building.html

After downloading the source, starting the shell, the configure command would look like the following

configure.bat -platform win32-msvc -release ^
-nomake examples ^
-nomake tests ^
-static

SSL

You will have to also decide if you want SSL support or not. If no, simply give the option:

-no-ssl

If yes, an additional option similar to

-openssl -I %OPENSSL_INCLUDE_DIR% -L %OPENSSL_LIBRARY_DIR%

would have to be pass.

OpenSSL version used in the Qt5 provisioning script could be used.

$version = "1_0_2o"
$externalUrl = "https://slproweb.com/download/Win64OpenSSL-$version.exe"

Graphics Driver, WebEngine, ...

You will also have to make some decision in that regards: https://doc.qt.io/qt-5/windows-requirements.html

Upvotes: 1

Related Questions