如何正确地在CMakeLists.txt文件中配置头文件搜索路径
================================

请按照以下示例进行配置：

**例1****：**

目录结构：

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/da/v3/j0ai1nunQguZcnDjpY7y2Q/zh-cn_image_0000002199836868.png?HW-CC-KV=V1&HW-CC-Date=20260612T074658Z&HW-CC-Expire=86400&HW-CC-Sign=DAA76D38A5D4087F1FC2CCA229BB48504F685F36F49419A4374EE466AA24EAC2)

CMakeLists.txt配置头文件搜索路径：

include\_directories(${NATIVERENDER\_ROOT\_PATH}/include)

cpp文件中引用头文件:

#include 'test.h'

**例2****：**

目录结构：

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/c5/v3/QWNlxneqRlucyBeVHZEduA/zh-cn_image_0000002234797125.png?HW-CC-KV=V1&HW-CC-Date=20260612T074658Z&HW-CC-Expire=86400&HW-CC-Sign=D75CC912824EA8CF2CC205EB24F9409D859388E1A1AC2CF532E370F8933160CA)

CMakeLists.txt配置头文件搜索路径：

include\_directories(${NATIVERENDER\_ROOT\_PATH})

cpp文件中引用头文件:

#include 'include/test/test.h'

**例3：**

目录结构：

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/b2/v3/9LggSEdvQjSygmgj96sY7g/zh-cn_image_0000002234956969.png?HW-CC-KV=V1&HW-CC-Date=20260612T074658Z&HW-CC-Expire=86400&HW-CC-Sign=D950B3306740DD70EAE05D8B47614009C558538CCED493EF1D9CF6C797A7BBBF)

CMakeLists.txt配置头文件搜索路径：

include\_directories(${NATIVERENDER\_ROOT\_PATH}/include)

cpp文件中引用头文件:

#include 'test/test.h'

**例4:**

目录结构：

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/72/v3/MzYsy-YwRPChLid3PljZ9w/zh-cn_image_0000002199996680.png?HW-CC-KV=V1&HW-CC-Date=20260612T074658Z&HW-CC-Expire=86400&HW-CC-Sign=2DD56A4499147AFDB433699B5EAD3EA1BFFD2D17E04E22937309CF5B047C1248)

CMakeLists.txt配置头文件搜索路径:

include\_directories(${NATIVERENDER\_ROOT\_PATH}/include/test)

cpp文件中引用头文件:

#include 'test.h'