没有使用 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个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
clion中能不能设置变量,供cmake使用?
1
android studio NDK cmake创建的demo例子无法正常运行错误如下,如何解决该问题 求助求助
2
cmake报错No CMAKE_C_COMPILER could be found该怎么解决?
4
android studio3.1.4 建C++新项目时cmake报的问题
1
使用cmake将.cpp与.h分开,为什么会提示redefination?
1
Android studio JNI 使用 CMakeLists 如何让import的so库 生成到输出目录?
0
在ubuntu系统下使用cmake构建依赖Qt第三方库的项目的问题
2
vs2019配置opencv3.4.5和opencv_contrib-3.4.5编译成功后生成install报错
0
vs2019+opencv3.4.5+opencv_contrib3.4.5,cmake成功但是重新生成时有大量失败的情况
2
error MSB3073: 命令“setlocal "C:\Program Files\CMake\bin\cmake.exe" -DBUILD_
4
为什么Opencv3.4.0使用make编译时出现错误?
1
linux使用clion进行c++和python的交叉编译,无法导入python的第三方库
1
CentOS编译LLVM遇到的HOST GCC版本问题
1
Android Studio的项目运行时报错:Error configuring CMake server
1
用完cmake后原本可以运行的opengl程序报错“(ig9icd32.dll)处引发的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突。”
1
android中CMake文件同步失败,请问到底该如何解决
0
CMake Error at volk/CMakeLists.txt:93 (message): Mako templates required to build VOLK
2
3d slicer在编译loadable module时出错 The CMAKE_CXX_COMPILER: ...cl.exe is not a full path to an existing compiler tool.
0
windows环境下codeblocks17.12 用cmake配置opencv3.4.7出现如下错误
2
Android 编译 apk内有so文件 点运行按钮他就不生成 把编译拿出来的包只接运行也没问题 studio3.5.1