【Windows 构建失败】启用 WITH_ONEMKL=ON 时因 CMake 脚本中 'win32' 大小写错误导致配置失败
envgap__PaddlePaddle__Paddle-77689
01 / FAILURE SIGNATURE
As reported upstream
Cannot specify include directories for target "phi_core" which is not built by this project.
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
9fa630b4249d46c43898ebf383f307c7fc9a03c6- Manifest
paddle/phi/CMakeLists.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
PaddlePaddle/Paddle #77689 · read the original issue
在 Windows 系统下从源码构建 Paddle 3.2.0 时,若启用 -DWITH_ONEMKL=ON 且关闭 GPU(-DWITH_GPU=OFF),CMake 配置阶段会失败,报错如下:
CMake Error at paddle/phi/CMakeLists.txt:326 (target_include_directories):
Cannot specify include directories for target "phi_core" which is not built by this project.
经排查,问题出在 paddle/phi/CMakeLists.txt 文件中的一处大小写错误:
if(win32) # ← 这里使用了小写的 win32
但 CMake 的内置平台变量应为 大写的 WIN32。由于 win32 未定义,该条件在 Windows 上恒为假,导致脚本错误地执行了 else() 分支:
target_include_directories(phi_core PRIVATE ${MKL_INCLUDE})
而在 Windows + WITH_GPU=OFF 的配置下,CMake 只创建了 phi 目标,并未创建 phi_core,因此对 phi_core 调用 target_include_directories 会触发 CMake 错误。
修复建议
将 paddle/phi/CMakeLists.txt 中的:if(win32) 修改为:if(WIN32)
已本地验证修复有效
复现步骤
系统:Windows 10/11
CMake 命令示例:
cmake .. -G "Visual Studio 16 2019" -A x64 ^
-DWITH_GPU=OFF ^
-DWITH_MKL=ON ^
-DWITH_ONEMKL=ON ^
-DWITH_PYTHON=OFF ^
-DON_INFER=ON ^
-DMSVC_STATIC_CRT=ON
结果:CMake 配置失败
影响范围
所有希望在 Windows CPU 环境下使用 Intel oneMKL 加速 FFT 计算 的用户都会遇到此问题,无法完成源码编译。
建议将此修复合入 v3.2.x 补丁版本,或至少在 develop 分支中修复,避免后续版本出现同样问题。04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]