公共标头未找到其他公共标头
Public headers not finding other public headers
本文关键字:其他 更新时间:2023-10-16
我已经使用cmake创建了一个静态库,并且我正在以/usr/local/include/include//includ/。库及其测试单独编译,但是当在另一个项目中使用库时,我会遇到一个错误:
/usr/local/include/weftworks/common/network/tcp/acceptor.hpp:28:10: fatal error: utility.hpp: No such file or directory
#include "utility.hpp"
ancorpor.hpp和utility.hpp都是公共标题。
这是相关的文件夹结构:
root/
├ cmake/
├ external/
├ library/
│ ├─ include/
│ │ ├─ network/
│ │ │ └─ tcp/
│ │ │ └─ acceptor.hpp
│ │ └─ utility.hpp
│ ├─ src/
│ └─ CMakeLists.txt
├ test/
└ CMakeLists.txt
./library/cmakelists.txt:
# ./library/CMakeLists.txt
# Required CMake version
cmake_minimum_required(VERSION 3.13)
include(GNUInstallDirs)
# Project details
project(
weftworks-common-library
VERSION 0.4.0
DESCRIPTION "Internal Weftworks Common Library project."
)
# Library target sources
list(APPEND WEFTWORKS_COMMON_LIBRARY_PRIVATE_SOURCES)
list(APPEND WEFTWORKS_COMMON_LIBRARY_PUBLIC_SOURCES)
list(APPEND WEFTWORKS_COMMON_LIBRARY_INTERFACE_SOURCES)
include(src/CMakeLists.txt)
# A static library target
add_library(weftworks-common-library STATIC)
# Required compiler features
target_compile_features(
weftworks-common-library
PUBLIC
cxx_auto_type
cxx_constexpr
cxx_defaulted_functions
cxx_deleted_functions
cxx_final
cxx_lambdas
cxx_noexcept
cxx_override
cxx_range_for
cxx_static_assert
cxx_std_17
cxx_strong_enums
cxx_trailing_return_types
cxx_uniform_initialization
cxx_variadic_macros
)
target_compile_options(
weftworks-common-library
PRIVATE
-Wall
-Wextra
-pedantic
)
target_include_directories(
weftworks-common-library
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(
weftworks-common-library
PUBLIC
Boost::boost
Boost::system
Boost::program_options
spdlog::spdlog
Threads::Threads
)
target_sources(
weftworks-common-library
PUBLIC ${WEFTWORKS_COMMON_LIBRARY_PUBLIC_SOURCES}
INTERFACE ${WEFTWORKS_COMMON_LIBRARY_INTERFACE_SOURCES}
PRIVATE ${WEFTWORKS_COMMON_LIBRARY_PRIVATE_SOURCES}
)
# Create alias target
add_library(weftworks::common-library ALIAS weftworks-common-library)
# Install library target
install(
TARGETS weftworks-common-library
EXPORT weftworks-common-library-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
EXPORT weftworks-common-library-config
NAMESPACE weftworks::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/weftworks/common-library
)
# Install public headers
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/weftworks/common
)
现在,我不知道要做这项工作需要做什么。我想避免在项目结构(即library/include/weftworks/common/
)中具有"库前缀",以使其保持简单。
您需要包括"weftworks/common/network/utility.hpp"
。
这还将确保您实际上包括您的标题,而不是某人写的其他标题,而这些标题很通用名称"utility.hpp"
。
相关文章:
- 在执行其他功能的同时播放动画(LED矩阵和Arduino/ESP8266)
- 将数组作为参数传递给函数安全吗?作为第三方职能部门,可以探索他们想要的之外的其他元素
- 有没有什么方法可以使用一个函数中定义的常量变量,也可以由c++中同一程序中的其他函数使用
- GL_SHADERSTORAGE_BUFFER位置是否与其他着色器位置冲突
- 为什么我不能在 C++ 中的特定函数重载中调用同一函数的任何其他重载?
- 在其他文件中创建类时在 c++ 项目中不起作用
- 类与私有变量的其他类之间的线程安全性
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- GlobalAlloc而不是其他分配方法
- C++从其他 constexpr 创建 lambda 不能按顺序执行 Constexpr
- 断言中的Fold表达式在某些计算机上编译,但在其他计算机上不编译
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 结构和双指针隐藏在其他结构中,多层混淆
- UE4在OnComponentBeginOverlap上铸造其他actor
- 当我在其中一个线程执行中(在activemq-cpp中)捕获到特定值时,我如何终止/停止所有其他线程
- MESI协议和std::atomic-它是否确保所有写入立即对其他线程可见?
- 保留对其他类的成员函数的引用
- 为什么将值返回函数传递给重载=运算符对运算符函数有效,而对其他运算符无效
- 具有包含其他对象的类的对象创建顺序
- 让bool方法返回其他整数