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

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

**例1****：**

目录结构：

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/1f/v3/4968LehMTmWVFUT7E4Lz4g/zh-cn_image_0000002654835209.png?HW-CC-KV=V1&HW-CC-Date=20260709T133832Z&HW-CC-Expire=86400&HW-CC-Sign=5D1D2EA18F424123CF91ECCCA28215DADE7A927ADB16CB2E8F21CCC15DAACDB5)

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/CuXexY7sSHeYsB5hAw_-Mg/zh-cn_image_0000002654795275.png?HW-CC-KV=V1&HW-CC-Date=20260709T133832Z&HW-CC-Expire=86400&HW-CC-Sign=554D0624DAFB8E5B585B86A9FF6DFE970C8804CCD19F9FC30098A298007998B5)

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/3c/v3/iebElMdJSZmdXhdhOPOEJw/zh-cn_image_0000002624635808.png?HW-CC-KV=V1&HW-CC-Date=20260709T133832Z&HW-CC-Expire=86400&HW-CC-Sign=1D6B7F3C1ACBD8509E2D70A54F57B128EE707DC3AB928947944521CDD9F8E65C)

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/19/v3/eXZbWmZKRTCntr6JDrcQKg/zh-cn_image_0000002624475906.png?HW-CC-KV=V1&HW-CC-Date=20260709T133832Z&HW-CC-Expire=86400&HW-CC-Sign=5253E455A7241CBB6EE25BC96C32272E89F401042787A8DB545CCB061A27F2C9)

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

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

cpp文件中引用头文件:

#include 'test.h'