乱世@小熊 2018-11-02 00:12 采纳率: 25%
浏览 963

没有使用 CMAKE 生成目标的规则来添加库。 图书馆自己编译就行了

I'm trying to use this library in my source code. I can't show you my code base, so I made a simple hello world project that tries to utilize this library. Following the instructions to install the library using CMake works perfectly, fine, the problem is I'm trying to put it into my project directory and compile it from there using my own CmakeLists.txt.

Here is the library download: ftp://ftp.unidata.ucar.edu/pub/udunits/

I'm using udunits-2.2.26.tar.gz

This is my project structure:

   proj/
    |-- CMakeLists.txt
    |-- ext
    |   `-- udunits-2.2.26/
    `-- src
        `-- main.cpp

My CMakeLists.txt:

cmake_minimum_required(VERSION 3.1)

project(proj)

add_subdirectory("ext/udunits-2.2.26")

add_executable(app src/main.cpp)

install(TARGETS app DESTINATION bin)

My main.cpp:

#include <iostream>

int main() {
  std::cout << "Hello World" << std::endl;
  return 0;
}

What I'm doing is I'm making a build/ directory within proj and calling CMake like so: ccmake ..

I run the configuration, then generate the files, and finally I call make.

Here is my output:

[  8%] Built target app
Scanning dependencies of target udunits2_doc
[ 13%] Built target udunits2_doc
Scanning dependencies of target udunits2lib_doc
make[2]: *** No rule to make target `../COPYRIGHT', needed by `../ext/udunits-2.2.26/lib/udunits2lib.info'.  Stop.
make[1]: *** [ext/udunits-2.2.26/lib/CMakeFiles/udunits2lib_doc.dir/all] Error 2
make: *** [all] Error 2

There's a COPYRIGHT file in the library that contains the license details for this library. Their CMake checks to see if it exists. I'm not sure why I'm having issues compiling it adding it into my own CMakeLists as a sub directory.

If I grep all the make files for COPYRIGHT and remove all dependencies to it, it compiles just fine. So it's something to do with the .texi files depending on it, and I'm not sure how to fix this.

I've spent all day googling and trying different things, I'd appreciate any help! Thanks!

转载于:https://stackoverflow.com/questions/53111095/no-rule-to-make-target-using-cmake-to-add-a-library-library-compiles-just-fine

  • 写回答

1条回答

  • dabocaiqq 2018-11-03 15:59
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题