cmake指定到install的include/src等路径

list(APPEND UTILS_EXT_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ext/rpclib/include)

cmake_minimum_required(VERSION 3.16) # 声明该项目的名称和版本号 project(MyLib VERSION 1.0) # 添加库代码文件到该库 add_library(mylib STATIC src/header.cpp) target_include_directories(mylib INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> ) add_library(mylib_shared SHARED src/header.cpp) target_include_directories(mylib_shared INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> ) # include_directories(include) # 指定install路径,以便于其他项目找到该库 install(TARGETS mylib mylib_shared EXPORT MyLibTargets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) install(FILES include/header.h DESTINATION include) # 生成MyLibConfig.cmake文件 include(CMakePackageConfigHelpers) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/MyLibConfigVersion.cmake" VERSION ${MyLib_VERSION} COMPATIBILITY AnyNewerVersion ) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/MyLibConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/MyLibConfig.cmake" INSTALL_DESTINATION cmake ) install( EXPORT MyLibTargets NAMESPACE MyLib:: DESTINATION cmake ) # export(EXPORT MyLibTargets # NAMESPACE MyLib:: # FILE MyLibTargets.cmake) # install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MyLibTargets.cmake DESTINATION cmake) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/MyLibConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/MyLibConfigVersion.cmake" DESTINATION cmake )为什么执行时,提醒/home/czl/cmake_lib/src/header.cpp:1:10: fatal error: header.h: 没有那个文件或目录
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值