小编cza*_*ppa的帖子

cmake install(FILES ...)似乎不起作用

我有一个用C++编写的项目,我正在使用cmake来构建它.该项目有许多子项目,其中一个是其他子项目所需的库.我可以使用add_library和INSTALL(TARGETS ...)编译并将.so移动到构建目录

但是我还需要将lib的头文件安装在build dir的include目录下.我使用install(FILES ...)来做它,但它似乎根本不做任何事情.

为了演示它,我通过qtcreator创建了一个测试项目,

& ls test
CMakeLists.txt empty.hh main.cpp

$ cat test/CMakeLists.txt
project(test)
cmake_minimum_required(VERSION 2.8)
install(FILES empty.hh DESTINATION include)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})

$ cat test/main.cpp
#include

using namespace std;

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

$ cat test/empty.hh
#ifndef EMPTY_HH
#define EMPTY_HH

#endif // EMPTY_HH

If the files under "test" qtcreator will compile (by default) the files to test-build.
$ ls test-build/
CMakeCache.txt CMakeFiles Makefile cmake_install.cmake test test.cbp
$ ./test-build/test …
Run Code Online (Sandbox Code Playgroud)

c++ install cmake

4
推荐指数
1
解决办法
4749
查看次数

标签 统计

c++ ×1

cmake ×1

install ×1