diff --git a/extension/llm/custom_ops/CMakeLists.txt b/extension/llm/custom_ops/CMakeLists.txt index 8a43a5ddf5c..a0ba0a2eb42 100644 --- a/extension/llm/custom_ops/CMakeLists.txt +++ b/extension/llm/custom_ops/CMakeLists.txt @@ -130,6 +130,8 @@ if(EXECUTORCH_BUILD_KERNELS_LLM_AOT) ${CMAKE_CURRENT_SOURCE_DIR}/op_tile_crop.cpp ${CMAKE_CURRENT_SOURCE_DIR}/op_tile_crop_aot.cpp ) + # This lib compiles real PyTorch headers, which require C++20. + set_target_properties(custom_ops_aot_lib PROPERTIES CXX_STANDARD 20) target_include_directories( custom_ops_aot_lib PRIVATE "${_common_include_directories}" ) diff --git a/tools/cmake/Codegen.cmake b/tools/cmake/Codegen.cmake index 4253fa44dc5..05d1af9725a 100644 --- a/tools/cmake/Codegen.cmake +++ b/tools/cmake/Codegen.cmake @@ -254,6 +254,8 @@ function(gen_custom_ops_aot_lib) find_package_torch() # This lib uses ATen lib, so we explicitly enable rtti and exceptions. target_compile_options(${GEN_LIB_NAME} PRIVATE -frtti -fexceptions) + # ATen headers require C++20. + set_target_properties(${GEN_LIB_NAME} PROPERTIES CXX_STANDARD 20) target_compile_definitions(${GEN_LIB_NAME} PRIVATE USE_ATEN_LIB=1) include_directories(${TORCH_INCLUDE_DIRS}) target_link_libraries(${GEN_LIB_NAME} PRIVATE torch)