Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在Qt Creator中的CMakeLists.txt中包含头文件?_C++_Qt_Cmake - Fatal编程技术网

C++ 如何在Qt Creator中的CMakeLists.txt中包含头文件?

C++ 如何在Qt Creator中的CMakeLists.txt中包含头文件?,c++,qt,cmake,C++,Qt,Cmake,此文件不是任何项目的一部分 我知道它一定是CMakeLists.txt的内容,但我不知道如何做,或者为什么它没有自动包含 cmake_minimum_required(VERSION 2.8) project(S13V140_implementing_member_method) add_executable(${PROJECT_NAME} "main.cpp") ??? 以下CMakeLists.txt应适用于您: cmake_minimum_required(VERSION 2.8)

此文件不是任何项目的一部分

我知道它一定是CMakeLists.txt的内容,但我不知道如何做,或者为什么它没有自动包含

cmake_minimum_required(VERSION 2.8)

project(S13V140_implementing_member_method)
add_executable(${PROJECT_NAME} "main.cpp")

???

以下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})

要使CMake和Qt协同工作,请确保将所有头文件添加到源文件列表中

set(sources "main.cpp" "my_header.h")
add_executable(${PROJECT_NAME} ${sources})