Migrate c10/macros/cmake_macros.h.in to torch/headeronly (#158035)

Summary: As above, also changes a bunch of the build files to be better

Test Plan:
internal and external CI

did run buck2 build fbcode//caffe2:torch and it succeeded

Rollback Plan:

Reviewed By: swolchok

Differential Revision: D78016591

Pull Request resolved: https://github.com/pytorch/pytorch/pull/158035
Approved by: https://github.com/swolchok
This commit is contained in:
Jane Xu
2025-07-15 19:52:53 +00:00
committed by PyTorch MergeBot
parent 250ae2531c
commit 30587195d3
20 changed files with 184 additions and 103 deletions

View File

@ -0,0 +1,28 @@
def define_targets(rules):
rules.cc_library(
name = "macros",
srcs = [":cmake_macros_h"],
hdrs = [
# Following the example from c10
"Export.h",
],
linkstatic = True,
local_defines = ["C10_BUILD_MAIN_LIB"],
visibility = ["//visibility:public"],
)
rules.cmake_configure_file(
name = "cmake_macros_h",
src = "cmake_macros.h.in",
out = "cmake_macros.h",
definitions = [
"C10_BUILD_SHARED_LIBS",
"C10_USE_MSVC_STATIC_RUNTIME",
] + rules.select({
"//c10:using_gflags": ["C10_USE_GFLAGS"],
"//conditions:default": [],
}) + rules.select({
"//c10:using_glog": ["C10_USE_GLOG"],
"//conditions:default": [],
}),
)