Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use CMake to get dependencies for Windows app while building it from Linux?

Currently I'm trying to deploy a Qt application for Windows using MinGW and CMake from Linux. I used MXE to prepare building environment (install mingw32 and compile Qt5 shared libraries). I've written CMakeList.txt and a toolchain script, and they build my application OK.

The thing I can't achieve is to deliver shared Qt dlls to my built executable.

Here is my Toolchain file: http://pastebin.com/gh7kSda4

This is my CMakeLists.txt: http://pastebin.com/wHA7f7Sj

Here is the excerpt from that script, containing the installation part:

# Installation.
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/${TOOLCHAIN}-Bundle)
install(TARGETS mEyeSaver
        RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
install(CODE "
        include(BundleUtilities)
        fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/mEyeSaver${TOOLCHAIN_EXECUTABLE_FORMAT}\" \"\" \"${QT5_PATH}/bin\")
" COMPONENT Runtime)

As you can see, I use fixup_bundle for achieving my goal.

After I type make install I get the following output: http://pastebin.com/DymaH1Mu

After that there is nothing except mEyeSaver.exe in the x86_64-w64-mingw32-Bundle folder. No dlls were copied. I'm sure there were needed Qt dlls in the ~/mxe/usr/x86_64-w64-mingw32.shared/qt5/bin folder. But there is still something I'm doing wrong.

How to fix the problem? Thank you

Update

I've rethought what I'm doing and came to a point that maybe fixup_bundle just can't analyze dependencies for Windows executable, because Linux ldd (which it uses) has nothing to do with a Windows app. So I've edited my question.

Is there any easy way to get dependency libraries with CMake (or maybe another tool) for Windows executable without copying them directly?

like image 897
mvlabat Avatar asked Mar 16 '16 09:03

mvlabat


People also ask

Can CMake install dependencies?

Any complex software will have its dependencies – be it system API calls or other libraries calls either statically or dynamically linked to it. As a build system generator CMake will help you manage these dependencies in the most natural way possible.

How do I run CMakeLists txt in Windows?

Running CMake for Windows / Microsoft Visual C++ (MSVC) Run cmake-gui.exe, which should be in your Start menu under Program Files, there may also be a shortcut on your desktop, or if you built from source, it will be in the build directory. A GUI will appear similar to what is shown below.


1 Answers

In last cmake version there is file GET_RUNTIME_DEPENDENCIES command to get binary dependencies at install time.

like image 95
ephemerr Avatar answered Oct 05 '22 01:10

ephemerr