CMake 在源文件附近找不到头文件

CMake cannot find header file near the source one

本文关键字:找不到 文件 源文件 CMake      更新时间:2023-10-16

我不想在我的系统中全局安装 sqlite,所以我从 https://www.sqlite.org/2018/sqlite-amalgamation-3240000.zip 下载了 sqlite3 文件,并将sqlite3.c和 sqlite3.h 复制到项目文件夹中。

CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)
project(learn_cpp)
set(CMAKE_CXX_STANDARD 11)
add_executable(learn_cpp main.cpp)

主要.cpp :

#include <iostream>
#include "sqlite3.h"
int main() {
return 0;
}

我没有按照CLion IDE中的建议从sqlite3.h获得任何函数。

默认情况下,CMake 不会搜索当前目录中的头文件。要启用此行为,请设置CMAKE_INCLUDE_CURRENT_DIR变量:

set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(learn_cpp main.cpp ...)