mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
* Remove APIs unavailable in Store in #8349, #8178, #8065 * Add UWP stubs of C runtime functions * Remove UWP incompatible tests from UWP build * Remove incompatible tests from Store * Use UWP stubs in store only * Skip partition check outside of Windows * Remove unused WRL include * Workaround Windows header not including what it uses * Fix precompiled header name clash * Workaround SDK bugs * DXCore workaround in Win7 * Fix warning * Fix more warnings * Bump WinML to target Windows 8 * Fix more warnings * Remove unnecessary workarounds * Remove Desktop only APIs from DML adapter
29 lines
1.7 KiB
CMake
29 lines
1.7 KiB
CMake
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
|
|
# Configures sources on a target to use a precompiled header. This function takes a target and
|
|
# header name as input. The function will generate a .cpp file that includes the header and is used
|
|
# to generate the precompiled header; this source file is added to the target's sources.
|
|
function(target_precompiled_header target_name header_name)
|
|
if (MSVC AND CMAKE_VS_PLATFORM_TOOLSET)
|
|
# The input precompiled header source (i.e. the '.h' file used for the precompiled header).
|
|
set(pch_header_path ${header_name})
|
|
get_filename_component(header_base_name ${header_name} NAME_WE)
|
|
|
|
# Generate the source file that builds the precompiled header. The generated file will have
|
|
# the same base name as the input header name, but has the .cpp extension.
|
|
set(pch_source_path ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_${header_base_name}.cpp)
|
|
set(pch_source_content "// THIS FILE IS GENERATED BY CMAKE\n#include \"${pch_header_path}\"")
|
|
file(WRITE ${pch_source_path} ${pch_source_content})
|
|
set_source_files_properties(${pch_source_path} PROPERTIES COMPILE_FLAGS "/Yc${pch_header_path}")
|
|
|
|
# The target's C++ sources use the precompiled header (/Yu). Source-level properties will
|
|
# take precedence over target-level properties, so this will not change the generated source
|
|
# file's property to create the precompiled header (/Yc).
|
|
target_compile_options(${target_name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/Yu${header_name}>)
|
|
|
|
# Append generated precompiled source to target's sources.
|
|
target_sources(${target_name} PRIVATE ${pch_source_path})
|
|
|
|
endif()
|
|
endfunction()
|