[英]How to link an external library with cmake?
I am trying to build a project using CMake. 我正在尝试使用CMake构建项目。 One of the libraries that is required for the project is located on a path outside my project directory.
项目所需的库之一位于项目目录之外的路径上。 The header files are scattered in sub-directories as well as in the root of the folder.
头文件分散在子目录以及文件夹的根目录中。 A bit like this:
有点像这样:
/some_remote_path/packages/BOOX/
|-> foo.h
|-> banana.h
|-> orange.h
|-> timer
|-> lib0.h
|-> lib1.h
|-> lib2.h
|-> types
|-> type0.h
|-> type1.h
|-> type2.h
...
I am trying to link these using the following command: 我正在尝试使用以下命令链接这些链接:
include_directories (${SOME_OTHER_LIB_HEADERS} ${BOOX_HEADERS})
How can I store all the headers into the ${BOOX_HEADERS}
variable? 如何将所有标头存储到
${BOOX_HEADERS}
变量中? I tried many things such as various macros utilising the GLOB_RECURSE
feature: 我尝试了许多事情,例如利用
GLOB_RECURSE
功能的各种宏:
FILE(GLOB_RECURSE ${BOOX_HEADERS} ${path_to_boox_lib} *.h)
But without any success. 但是没有任何成功。 I would like to skip writing a complex
find.cmake
script. 我想跳过编写复杂的
find.cmake
脚本。 That would have helped me (probably?) to generate something like ${BOOX_INCLUDE_DIRS}. 那会帮助我(可能是?)生成类似$ {BOOX_INCLUDE_DIRS}的内容。 What would be the best solution to simply construct the header list and pass it to the compiler using CMake.
简单构造头列表并将其通过CMake传递给编译器的最佳解决方案是什么?
I am trying to link these using the following command:
我正在尝试使用以下命令链接这些链接:
you are including header with the command you have given how would you also need to define LIBs path for the library with link_directories(directory1 directory2 ...)
您在给定命令的命令中包含标头,还需要如何使用
link_directories(directory1 directory2 ...)
为库定义link_directories(directory1 directory2 ...)
路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.