我有一个库libA。结构如下:
libA
+ CMakeLists.txt
+ mySRC/headerA.h
+ mySRC/headerB.h
+ mySRC/moduleA/modA.h
+ mySRC/moduleB/modB.h
我的lib编译得很好,之后我想用这个cmake代码安装它:
SET(Source_dir mySRC)
SET(LIB_NAME libA)
...
INSTALL(TARGETS ${LIB_NAME} DESTINATION /usr/local/lib)
INSTALL(DIRECTORY ${Source_dir}
DESTINATION /usr/local/include/libA
FILES_MATCHING PATTERN "*.h")
结果:
libA.a结束于
/usr/local/lib/libA.a (which is fine)
标题最终在
/usr/local/include/libA/mySRC/*
/usr/local/include/libA/mySRC/moduleA
/usr/local/include/libA/mySRC/moduleB
什么不是我想要的。 我想删除" mySRC":
/usr/local/include/libA/*
/usr/local/include/libA/moduleA
/usr/local/include/libA/moduleB
如何从路径中删除mySRC?
答案 0 :(得分:2)
正如CMake documentation所说,你可以通过跟踪斜杠来阻止CMake附加目录名:
INSTALL(DIRECTORY ${Source_dir}/
DESTINATION /usr/local/include/libA
FILES_MATCHING PATTERN "*.h")