简体   繁体   English

适用于C ++ Azure的CMake包含

[英]CMake include for C++ Azure

This is about how to integrate the azure-storage C++ toolkit in CMake. 这是关于如何在CMake中集成Azure存储C ++工具包。

I try to build a tool in our application that connects to Azure blob storage, lists files/containers, reads data, etc., I work on Linux (Ubuntu 17.04). 我尝试在我们的应用程序中构建一个工具,该工具可以连接到Azure blob存储,列出文件/容器,读取数据等,我在Linux上工作(Ubuntu 17.04)。 I have built both the cpprestsdk and azure-storage tools from source. 我已经从源代码构建了cpprestsdk和Azure存储工具。

I am able to compile some things because I literally add 我能够编译一些东西,因为我确实添加了

-I/apps/azure/inst/include

to the CMAKE_CXX_FLAGS . CMAKE_CXX_FLAGS As you can see I used CMAKE_INSTALL_PREFIX=/apps/azure/inst , used it for both cpprest and azure-storage. 如您所见,我使用了CMAKE_INSTALL_PREFIX=/apps/azure/inst ,将其用于cpprest和azure-storage。

In the lib subdirectory there is a cpprestsdk/ directory that contains .cmake files. lib子目录中,有一个cpprestsdk/目录,其中包含.cmake文件。 But I need a .cmake file for azure-storage that I can include in my own CMakeLists.txt , which adds stuff I need (flags, libs, etc.). 但是我需要一个.cmake文件来存储蔚蓝存储,我可以将其包含在自己的CMakeLists.txt ,该文件会添加我需要的内容(标志,库等)。 Looking at the samples reveals that these are built in a way that will only work during the build of the sdk. 查看样本可以发现,这些样本的构建方式仅在sdk的生成期间有效。

Does anyone know if there is such a .cmake include file, and if so .... where is it installed? 有谁知道是否有这样的.cmake包含文件,如果有的话....安装在哪里?

OK well, I could find nothing and nobody posts an answer, so I've been experimenting. 好的,我什么也找不到,没有人发布答案,所以我一直在尝试。 The short answer is: use the cpprest stuff and add some azure-storage directives yourself. 简短的答案是:使用cpprest东西,并自己添加一些azure-storage指令。

The only thing I could find is CMake code in the README.md of cpprest . 我唯一能找到的是README.mdcpprest中的CMake代码。 I took that in and added my own azure storage dir name where that could be needed. 我接受了它,并在可能需要的地方添加了自己的天蓝色存储目录名称。

Added: 添加:

find_path( AZURE_INST_DIR "" HINTS /apps/azure/inst REQUIRED )

The whole thing works because the big bulk of dependencies is under cpprest, azure-storage itself does not have extra dependencies (thank god!). 整个事情起作用了,因为大部分依赖项都在cpprest下,而azure存储本身没有额外的依赖项(谢天谢地!)。

Note gcc users: turn off -Wshadow and -Woverloaded-virtual because the cpprest and azure-storage code is riddled with those (apparently these are not available in Visual studio). 注意gcc用户:请关闭-Wshadow和-Woverloaded-virtual,因为cpprest和azure-storage代码中充斥着这些代码(显然,这些代码在Visual Studio中不可用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM