CMake:如何确定所有需要可执行文件的.DLL / .SO文件? [英] CMake: how to determine all the .DLL/.SO files that are need for an executable?
问题描述
让我们假设我的程序需要几个DLL来工作。我应该在我的发行版中为用户提供DLL。现在我需要QtCore4.DLL,QtGui4.DLL,msvcp90.DLL,msvcr90.DLL,mylib.DLL,Kernel32.DLL ...
Let's assume my program needs several DLL's to work. I should provide that DLLs to the user in my distribution. For now I need QtCore4.DLL, QtGui4.DLL, msvcp90.DLL, msvcr90.DLL, mylib.DLL, Kernel32.DLL...
如果CMake可以得到DLL(或.SO)文件的完整列表。然后我将从该列表中删除项目,如Kernel32.DLL,并将DLL复制到我的分布。
Would be nice if CMake could get full list of DLLs (or .SO) files. Then I would remove items like "Kernel32.DLL" from that list and copy the DLLs to my distribution.
我不能保证下一次构建将在相同版本的Visual Studio,所以硬编码路径像C:\Program Files\Microsoft Visual Studio 9.0 \VC \redist \x86 \Microsoft.VC90.CRT或E:\Qt \ 4.6.3不适合搜索DLL。
I can't guarantee the next build will be done on the same version of the Visual Studio, so hard-coding paths like "C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT" or "E:\Qt\4.6.3" is not good for searching for the DLLs.
谢谢!
推荐答案
您可以在Windows上使用 Dependency Walker (或cmd行dumpbin工具视觉工作室)。然而,这不是一个真正的CMake解决方案,并没有真正标准的解决方案与Cmake。
You can use Dependency Walker on windows (or the cmd-line dumpbin tool from visual studio). However this is not really a CMake solution and there is not really standard solution with Cmake.
但是,有一个 InstallRequiredSystemLibraries 模块,您可以使用它来获取系统dll(msvc [r | p] 90 .dll与msvc和mingw10.dll与mingw)。
There is, however, the InstallRequiredSystemLibraries module, which you can use to get the system dlls (msvc[r|p]90.dll with msvc and mingw10.dll with mingw).
这篇关于CMake:如何确定所有需要可执行文件的.DLL / .SO文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!