aboutsummaryrefslogtreecommitdiffhomepage
path: root/CMakeModules/TargetArchitectureSpecificSources.cmake
blob: f08911c6f2ab4b7493477cfc729005b68d01db94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function(target_architecture_specific_sources project arch)
    if (NOT DYNARMIC_MULTIARCH_BUILD)
        target_sources("${project}" PRIVATE ${ARGN})
        return()
    endif()

    foreach(input_file IN LISTS ARGN)
        if(input_file MATCHES ".cpp$")
            if(NOT IS_ABSOLUTE ${input_file})
                set(input_file "${CMAKE_CURRENT_SOURCE_DIR}/${input_file}")
            endif()

            set(output_file "${CMAKE_CURRENT_BINARY_DIR}/arch_gen/${input_file}")
            add_custom_command(
                OUTPUT "${output_file}"
                COMMAND ${CMAKE_COMMAND} "-Darch=${arch}"
                                         "-Dinput_file=${input_file}"
                                         "-Doutput_file=${output_file}"
                                         -P "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/impl/TargetArchitectureSpecificSourcesWrapFile.cmake"
                DEPENDS "${input_file}"
                VERBATIM
            )
            target_sources(${project} PRIVATE "${output_file}")
        endif()
    endforeach()
endfunction()