From 01631893cdeb92afdf7c16ffe2a9a7e64774dc48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Tue, 5 Apr 2022 07:28:34 +0800 Subject: [PATCH] [cmake] Re-factor pre-compile header usage (#11093) --- cmake/onnxruntime_providers.cmake | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake index 38b331c64d..2c0e09fdef 100644 --- a/cmake/onnxruntime_providers.cmake +++ b/cmake/onnxruntime_providers.cmake @@ -332,6 +332,12 @@ if (onnxruntime_USE_CUDA) "${ONNXRUNTIME_ROOT}/core/providers/cuda/*.h" "${ONNXRUNTIME_ROOT}/core/providers/cuda/*.cc" ) + # Remove pch files + list(REMOVE_ITEM onnxruntime_providers_cuda_cc_srcs + "${ONNXRUNTIME_ROOT}/core/providers/cuda/cuda_pch.h" + "${ONNXRUNTIME_ROOT}/core/providers/cuda/cuda_pch.cc" + ) + # The shared_library files are in a separate list since they use precompiled headers, and the above files have them disabled. file(GLOB_RECURSE onnxruntime_providers_cuda_shared_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.h" @@ -465,22 +471,11 @@ if (onnxruntime_USE_CUDA) if (WIN32) # *.cu cannot use PCH - foreach(src_file ${onnxruntime_providers_cuda_cc_srcs}) - set_source_files_properties(${src_file} - PROPERTIES - COMPILE_FLAGS "/Yucuda_pch.h /FIcuda_pch.h") - endforeach() - if(NOT onnxruntime_DISABLE_CONTRIB_OPS) - foreach(src_file ${onnxruntime_cuda_contrib_ops_cc_srcs}) - set_source_files_properties(${src_file} - PROPERTIES - COMPILE_FLAGS "/Yucuda_pch.h /FIcuda_pch.h") - endforeach() - endif() - set_source_files_properties("${ONNXRUNTIME_ROOT}/core/providers/cuda/cuda_pch.cc" - PROPERTIES - COMPILE_FLAGS "/Yccuda_pch.h" + target_precompile_headers(onnxruntime_providers_cuda PUBLIC + "${ONNXRUNTIME_ROOT}/core/providers/cuda/cuda_pch.h" + "${ONNXRUNTIME_ROOT}/core/providers/cuda/cuda_pch.cc" ) + # disable a warning from the CUDA headers about unreferenced local functions #target_compile_options(onnxruntime_providers_cuda PRIVATE /wd4505) if (onnxruntime_USE_NUPHAR_TVM)