乱世@小熊 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 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题