如何在 CMakeLists.txt Qt Creator 中包含头文件?
How to include header files in CMakeLists.txt in Qt Creator?
我正在使用Qt Creator来学习C++,没有使用Qt库的任何内容,我只是使用IDE。我创建了一个头文件,但它一直说
此文件不是任何项目的一部分
我知道它一定是CMakeList的东西.txt但是我不知道该怎么做,或者为什么它没有自动包含。
cmake_minimum_required(VERSION 2.8)
project(S13V140_implementing_member_method)
add_executable(${PROJECT_NAME} "main.cpp")
???
为了使 CMake 和 Qt 协同工作,请确保将所有标头添加到源文件列表中。
set(sources "main.cpp" "my_header.h")
add_executable(${PROJECT_NAME} ${sources})
以下CMakeLists.txt应该适合您:
cmake_minimum_required(VERSION 2.8)
# define the project name
project(S13V140_implementing_member_method)
# find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# C++11 support - else we run into issues with the non-static nullptr-assignment
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# put all sources into one variable: no distinction between h, cpp and ui (or qrc)
set(SOURCES
main.cpp
)
# create the final result
add_executable(S13V140_implementing_member_method ${SOURCES})
相关文章:
- 使用mongocxx驱动程序时包含头文件问题
- 如何为包含头文件的目标编写生成文件?
- 如何在 CMakeLists.txt Qt Creator 中包含头文件?
- 当包含头文件的文件不在根项目文件夹中时,如何包含它
- 在生成文件先决条件中包含头文件的原因
- My Project的属性配置正确,但Visual Studio仍然无法打开包含头文件
- 在 PostgreSQL C 扩展中包含头文件
- 是否可以在C++中以间接方式包含头文件
- 是否需要包含头文件?
- 我收到未声明的标识符错误,但我已包含头文件?
- 为什么我们需要构建一个提升库,仅仅包含头文件还不够吗,因为提升是模板
- C++:当顺序真正重要时,如何保证在项目中包含头文件的顺序
- 如何在C++中包含头文件时错误地重载
- 我在C++中无效使用不完整的类型类错误,如何正确包含头文件?
- 虚幻引擎4.16,C++包含头文件
- C++多次包含头文件
- 令牌之前的预期类名 '{' - 包含头文件和 CPP 文件
- 在.cpp中包含头文件会导致令人讨厌的错误
- 如何列出用于在Qt项目中包含头文件的所有路径
- 尽管包含头文件,但仍找不到嵌套命名空间