-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于 CMakeLists.txt 改进问题 #479
Labels
DIPU
DIPU related
Comments
LeungChiNan
pushed a commit
to DeepLink-org/deeplink.framework.dev
that referenced
this issue
Dec 8, 2023
* fix fork ci * fix fork bug
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
背景
目前各个
CMakeLists.txt
仅仅是可以编译,但埋下的坑比较多。CMake 本身存在一些奇怪设计以及一些历史问题,这里补充一些背景知识,比如说 CMake 的大量 command (主要是 CMake 2.x 之前的指令) 的影响范围是全局的:
set
构造的变量 (除非它在 function 内) 将会影响当前CMakeLists.txt
及其全部 subdirectory;add_definitions
会影响该行之后的全部 target,因此 modern CMake 建议废除这些 commands,并且使用现在范围的target_*
版本。当前问题
dipu/CMakeLists.txt
引入的 CMake 变量、compile-flags 很容易引起污染,这些变量、flag 等会影响全部的 subdriectory 中的 targets,后续很可能会影响 third_party 中的内容的编译:deeplink.framework/dipu/CMakeLists.txt
Lines 27 to 33 in 55df57b
deeplink.framework/dipu/CMakeLists.txt
Line 98 in 55df57b
deeplink.framework/dipu/CMakeLists.txt
Line 104 in 55df57b
deeplink.framework/dipu/CMakeLists.txt
Line 123 in 55df57b
deeplink.framework/dipu/CMakeLists.txt
Lines 126 to 127 in 55df57b
ExternalProject_Add
:deeplink.framework/dipu/third_party/CMakeLists.txt
Lines 55 to 64 in 55df57b
add_subdirectory
引入 kineto,后续继续新增全局的 flag 容易导致问题CMakeLists.txt
的option
中加入前缀 (例如DIPU_BUILD_TESTS
)deeplink.framework/dipu/CMakeLists.txt
Lines 5 to 6 in 55df57b
option
默认作用域也是全局,此类命名容易与上下游项目发生冲突CMakeLists.txt
文件,移除这类旧版 command:deeplink.framework/dipu/torch_dipu/csrc_dipu/CMakeLists.txt
Line 13 in 55df57b
deeplink.framework/dipu/torch_dipu/csrc_dipu/CMakeLists.txt
Lines 69 to 70 in 55df57b
file(GLOB *)
并不可靠,CMake 的官方文档有提到最好不要这样做deeplink.framework/dipu/torch_dipu/csrc_dipu/CMakeLists.txt
Lines 44 to 47 in 6d80677
GLOB_RECURSE
简化写法CMakeLists.txt
加入平台相关判断及警告,如果只支持 *unix 平台,应该向非该类平台的用户提醒错误信息。目前的各种 command 都默认使用 GCCThe text was updated successfully, but these errors were encountered: