如何制作CMake包装? [英] How to make a CMake package?
问题描述
我正在尝试为CMake项目中的Crypto ++包含创建CMake程序包,这将最终在 noloader / cryptopp-cmake存储库(如果已完成)。
I'm attempting to make a CMake package for Crypto++ inclusion in CMake projects, this will end up in the noloader/cryptopp-cmake repo if it gets done.
最终目标是提出一个可运行的跨平台 FindCryptoPP.cmake
文件,可以将其拖放到Crypto ++源目录中以执行以下操作:
The ultimate goal is to come up with a working cross-platform FindCryptoPP.cmake
file which can be dropped in the Crypto++ source directory to do things like:
find_package(CryptoPP REQUIRED)
target_link_libraries(libbiocoin cryptopp-static)
或:
find_package(CryptoPP REQUIRED)
target_link_libraries(libbiocoin cryptopp-shared)
在完成的应用程序中,使其正常工作。
In a finished application and have it "just work."
我目前在CMake中最好的解决方案应用程序是为平台构建Crypto ++,将生成的归档文件或库粘贴到lib目录中,在CMakeLists.txt中引用该文件或将其拉出这样,但当然需要为应用程序所针对的每个平台打包编译后的Crypto ++的二进制发行版,这样维护起来很麻烦,即使不是加密代码也很糟糕。
My current best solution within a CMake application is to build Crypto++ for the platform, stick the resulting archive or library in a lib directory, reference that within the CMakeLists.txt and pull it in that way, but of course that requires packaging a binary distribution of the compiled Crypto++ for every platform targeted by the application, which would be nasty to maintain and generally bad even if it weren't crypto code.
推荐答案
最好提供CMake配置文件。如果没有提供 FindFoo.cmake
查找脚本, find_package
将查找配置文件。与查找脚本相比,优点之一是您不会以查找脚本的不同版本(也许有冲突的版本)结尾。
It's better to provide a CMake configuration file. find_package
will look for a configuration file if no FindFoo.cmake
find script is provided. One advantage over a find script is that you won't end with different, maybe conflicting versions of the find script.
请参见 https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html ,尤其是创建布局。
这篇关于如何制作CMake包装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!