onnxruntime

Форк
0
/
precompiled_header.cmake 
29 строк · 1.7 Кб
1
# Copyright (c) Microsoft Corporation. All rights reserved.
2
# Licensed under the MIT License.
3

4
# Configures sources on a target to use a precompiled header. This function takes a target and
5
# header name as input. The function will generate a .cpp file that includes the header and is used
6
# to generate the precompiled header; this source file is added to the target's sources.
7
function(target_precompiled_header target_name header_name)
8
    if (MSVC AND CMAKE_VS_PLATFORM_TOOLSET)
9
        # The input precompiled header source (i.e. the '.h' file used for the precompiled header).
10
        set(pch_header_path ${header_name})
11
        get_filename_component(header_base_name ${header_name} NAME_WE)
12

13
        # Generate the source file that builds the precompiled header. The generated file will have
14
        # the same base name as the input header name, but has the .cpp extension.
15
        set(pch_source_path ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_${header_base_name}.cpp)
16
        set(pch_source_content "// THIS FILE IS GENERATED BY CMAKE\n#include \"${pch_header_path}\"")
17
        file(WRITE ${pch_source_path} ${pch_source_content})
18
        set_source_files_properties(${pch_source_path} PROPERTIES COMPILE_FLAGS "/Yc${pch_header_path}")
19

20
        # The target's C++ sources use the precompiled header (/Yu). Source-level properties will
21
        # take precedence over target-level properties, so this will not change the generated source
22
        # file's property to create the precompiled header (/Yc).
23
        target_compile_options(${target_name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/Yu${header_name}>)
24

25
        # Append generated precompiled source to target's sources.
26
        target_sources(${target_name} PRIVATE ${pch_source_path})
27

28
    endif()
29
endfunction()
30

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.