Files
pytorch/torch/headeronly/CMakeLists.txt
Jane Xu 30587195d3 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
2025-07-15 19:52:59 +00:00

35 lines
1.3 KiB
CMake

cmake_minimum_required(VERSION 3.27 FATAL_ERROR)
project(headeronly CXX)
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard whose features are requested to build this target.")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Main build file for torch/headeronly, except there's no build cuz this lib is header-only!
# ---[ Configure macro file.
set(C10_USE_GFLAGS ${USE_GFLAGS}) # used in cmake_macros.h.in
set(C10_USE_GLOG ${USE_GLOG}) # used in cmake_macros.h.in
set(C10_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) # used in cmake_macros.h.in
set(C10_USE_NUMA ${USE_NUMA}) # used in cmake_macros.h.in
set(C10_USE_MSVC_STATIC_RUNTIME ${CAFFE2_USE_MSVC_STATIC_RUNTIME}) # used in cmake_macros.h.in
set(C10_USE_ROCM_KERNEL_ASSERT ${USE_ROCM_KERNEL_ASSERT}) # used in cmake_macros.h.in
configure_file(
${CMAKE_CURRENT_LIST_DIR}/macros/cmake_macros.h.in
${CMAKE_BINARY_DIR}/torch/headeronly/macros/cmake_macros.h)
file(GLOB HEADERONLY_HEADERS
*.h
macros/*.h
)
add_library(headeronly INTERFACE ${HEADERONLY_HEADERS})
install(FILES ${CMAKE_BINARY_DIR}/torch/headeronly/macros/cmake_macros.h
DESTINATION include/torch/headeronly/macros)
if(NOT BUILD_LIBTORCHLESS)
# ---[ Installation copied from c10/CMakeLists.txt
install(TARGETS headeronly EXPORT Caffe2Targets DESTINATION lib)
endif()