1*77c1e3ccSAndroid Build Coastguard Worker# 2*77c1e3ccSAndroid Build Coastguard Worker# Copyright (c) 2017, Alliance for Open Media. All rights reserved. 3*77c1e3ccSAndroid Build Coastguard Worker# 4*77c1e3ccSAndroid Build Coastguard Worker# This source code is subject to the terms of the BSD 2 Clause License and the 5*77c1e3ccSAndroid Build Coastguard Worker# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was 6*77c1e3ccSAndroid Build Coastguard Worker# not distributed with this source code in the LICENSE file, you can obtain it 7*77c1e3ccSAndroid Build Coastguard Worker# at www.aomedia.org/license/software. If the Alliance for Open Media Patent 8*77c1e3ccSAndroid Build Coastguard Worker# License 1.0 was not distributed with this source code in the PATENTS file, you 9*77c1e3ccSAndroid Build Coastguard Worker# can obtain it at www.aomedia.org/license/patent. 10*77c1e3ccSAndroid Build Coastguard Worker# 11*77c1e3ccSAndroid Build Coastguard Workerif(AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_) 12*77c1e3ccSAndroid Build Coastguard Worker return() 13*77c1e3ccSAndroid Build Coastguard Workerendif() # AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_ 14*77c1e3ccSAndroid Build Coastguard Workerset(AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_ 1) 15*77c1e3ccSAndroid Build Coastguard Worker 16*77c1e3ccSAndroid Build Coastguard Workerinclude("${AOM_ROOT}/build/cmake/util.cmake") 17*77c1e3ccSAndroid Build Coastguard Worker 18*77c1e3ccSAndroid Build Coastguard Worker# Translate $flag to one which MSVC understands, and write the new flag to the 19*77c1e3ccSAndroid Build Coastguard Worker# variable named by $translated_flag (or unset it, when MSVC needs no flag). 20*77c1e3ccSAndroid Build Coastguard Workerfunction(get_msvc_intrinsic_flag flag translated_flag) 21*77c1e3ccSAndroid Build Coastguard Worker if("${flag}" STREQUAL "-mavx") 22*77c1e3ccSAndroid Build Coastguard Worker set(${translated_flag} "/arch:AVX" PARENT_SCOPE) 23*77c1e3ccSAndroid Build Coastguard Worker elseif("${flag}" STREQUAL "-mavx2") 24*77c1e3ccSAndroid Build Coastguard Worker set(${translated_flag} "/arch:AVX2" PARENT_SCOPE) 25*77c1e3ccSAndroid Build Coastguard Worker else() 26*77c1e3ccSAndroid Build Coastguard Worker 27*77c1e3ccSAndroid Build Coastguard Worker # MSVC does not need flags for intrinsics flavors other than AVX/AVX2. 28*77c1e3ccSAndroid Build Coastguard Worker unset(${translated_flag} PARENT_SCOPE) 29*77c1e3ccSAndroid Build Coastguard Worker endif() 30*77c1e3ccSAndroid Build Coastguard Workerendfunction() 31*77c1e3ccSAndroid Build Coastguard Worker 32*77c1e3ccSAndroid Build Coastguard Worker# Adds an object library target. Terminates generation if $flag is not supported 33*77c1e3ccSAndroid Build Coastguard Worker# by the current compiler. $flag is the intrinsics flag required by the current 34*77c1e3ccSAndroid Build Coastguard Worker# compiler, and is added to the compile flags for all sources in $sources. 35*77c1e3ccSAndroid Build Coastguard Worker# $opt_name is used to name the target. $target_to_update is made dependent upon 36*77c1e3ccSAndroid Build Coastguard Worker# the created target. 37*77c1e3ccSAndroid Build Coastguard Worker# 38*77c1e3ccSAndroid Build Coastguard Worker# Note: this function always updates the aom, and aom_static targets because 39*77c1e3ccSAndroid Build Coastguard Worker# OBJECT libraries have rules that disallow the direct addition of .o files to 40*77c1e3ccSAndroid Build Coastguard Worker# them as dependencies. Static and shared libraries do not have this limitation. 41*77c1e3ccSAndroid Build Coastguard Workerfunction(add_intrinsics_object_library flag opt_name target_to_update sources) 42*77c1e3ccSAndroid Build Coastguard Worker if("${${sources}}" STREQUAL "") 43*77c1e3ccSAndroid Build Coastguard Worker return() 44*77c1e3ccSAndroid Build Coastguard Worker endif() 45*77c1e3ccSAndroid Build Coastguard Worker set(target_name ${target_to_update}_${opt_name}_intrinsics) 46*77c1e3ccSAndroid Build Coastguard Worker add_library(${target_name} OBJECT ${${sources}}) 47*77c1e3ccSAndroid Build Coastguard Worker set_property(TARGET ${target_name} PROPERTY FOLDER ${AOM_TARGET_CPU}) 48*77c1e3ccSAndroid Build Coastguard Worker 49*77c1e3ccSAndroid Build Coastguard Worker # MSVC does not need flags for intrinsics flavors other than AVX/AVX2. 50*77c1e3ccSAndroid Build Coastguard Worker # However, for clang-cl, the default is SSE2, and the MSVC frontend does not 51*77c1e3ccSAndroid Build Coastguard Worker # provide any flags to enable SSE3 up to SSE4.1. So we need to restrict the 52*77c1e3ccSAndroid Build Coastguard Worker # usage of MSVC-style flags to only the real MSVC. 53*77c1e3ccSAndroid Build Coastguard Worker if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") 54*77c1e3ccSAndroid Build Coastguard Worker get_msvc_intrinsic_flag("${flag}" "flag") 55*77c1e3ccSAndroid Build Coastguard Worker endif() 56*77c1e3ccSAndroid Build Coastguard Worker 57*77c1e3ccSAndroid Build Coastguard Worker if("${flag}" STREQUAL "-mavx2") 58*77c1e3ccSAndroid Build Coastguard Worker unset(FLAG_SUPPORTED) 59*77c1e3ccSAndroid Build Coastguard Worker check_c_compiler_flag("-mno-avx256-split-unaligned-load" FLAG_SUPPORTED) 60*77c1e3ccSAndroid Build Coastguard Worker if(${FLAG_SUPPORTED}) 61*77c1e3ccSAndroid Build Coastguard Worker set(flag "${flag} -mno-avx256-split-unaligned-load") 62*77c1e3ccSAndroid Build Coastguard Worker endif() 63*77c1e3ccSAndroid Build Coastguard Worker 64*77c1e3ccSAndroid Build Coastguard Worker unset(FLAG_SUPPORTED) 65*77c1e3ccSAndroid Build Coastguard Worker check_c_compiler_flag("-mno-avx256-split-unaligned-store" FLAG_SUPPORTED) 66*77c1e3ccSAndroid Build Coastguard Worker if(${FLAG_SUPPORTED}) 67*77c1e3ccSAndroid Build Coastguard Worker set(flag "${flag} -mno-avx256-split-unaligned-store") 68*77c1e3ccSAndroid Build Coastguard Worker endif() 69*77c1e3ccSAndroid Build Coastguard Worker endif() 70*77c1e3ccSAndroid Build Coastguard Worker 71*77c1e3ccSAndroid Build Coastguard Worker if(flag) 72*77c1e3ccSAndroid Build Coastguard Worker separate_arguments(flag) 73*77c1e3ccSAndroid Build Coastguard Worker target_compile_options(${target_name} PUBLIC ${flag}) 74*77c1e3ccSAndroid Build Coastguard Worker endif() 75*77c1e3ccSAndroid Build Coastguard Worker 76*77c1e3ccSAndroid Build Coastguard Worker target_sources(aom PRIVATE $<TARGET_OBJECTS:${target_name}>) 77*77c1e3ccSAndroid Build Coastguard Worker if(BUILD_SHARED_LIBS) 78*77c1e3ccSAndroid Build Coastguard Worker target_sources(aom_static PRIVATE $<TARGET_OBJECTS:${target_name}>) 79*77c1e3ccSAndroid Build Coastguard Worker endif() 80*77c1e3ccSAndroid Build Coastguard Worker 81*77c1e3ccSAndroid Build Coastguard Worker # Add the new lib target to the global list of aom library targets. 82*77c1e3ccSAndroid Build Coastguard Worker list(APPEND AOM_LIB_TARGETS ${target_name}) 83*77c1e3ccSAndroid Build Coastguard Worker set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE) 84*77c1e3ccSAndroid Build Coastguard Workerendfunction() 85*77c1e3ccSAndroid Build Coastguard Worker 86*77c1e3ccSAndroid Build Coastguard Worker# Adds sources in list named by $sources to $target and adds $flag to the 87*77c1e3ccSAndroid Build Coastguard Worker# compile flags for each source file. 88*77c1e3ccSAndroid Build Coastguard Workerfunction(add_intrinsics_source_to_target flag target sources) 89*77c1e3ccSAndroid Build Coastguard Worker target_sources(${target} PRIVATE ${${sources}}) 90*77c1e3ccSAndroid Build Coastguard Worker if(MSVC) 91*77c1e3ccSAndroid Build Coastguard Worker get_msvc_intrinsic_flag("${flag}" "flag") 92*77c1e3ccSAndroid Build Coastguard Worker endif() 93*77c1e3ccSAndroid Build Coastguard Worker if(flag) 94*77c1e3ccSAndroid Build Coastguard Worker foreach(source ${${sources}}) 95*77c1e3ccSAndroid Build Coastguard Worker set_property(SOURCE ${source} APPEND PROPERTY COMPILE_FLAGS ${flag}) 96*77c1e3ccSAndroid Build Coastguard Worker endforeach() 97*77c1e3ccSAndroid Build Coastguard Worker endif() 98*77c1e3ccSAndroid Build Coastguard Workerendfunction() 99*77c1e3ccSAndroid Build Coastguard Worker 100*77c1e3ccSAndroid Build Coastguard Worker# Writes object format for the current target to the var named by $out_format, 101*77c1e3ccSAndroid Build Coastguard Worker# or terminates the build when the object format for the current target is 102*77c1e3ccSAndroid Build Coastguard Worker# unknown. 103*77c1e3ccSAndroid Build Coastguard Workerfunction(get_asm_obj_format out_format) 104*77c1e3ccSAndroid Build Coastguard Worker if("${AOM_TARGET_CPU}" STREQUAL "x86_64") 105*77c1e3ccSAndroid Build Coastguard Worker if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") 106*77c1e3ccSAndroid Build Coastguard Worker set(objformat "macho64") 107*77c1e3ccSAndroid Build Coastguard Worker elseif("${AOM_TARGET_SYSTEM}" STREQUAL "MSYS" 108*77c1e3ccSAndroid Build Coastguard Worker OR "${AOM_TARGET_SYSTEM}" STREQUAL "CYGWIN" 109*77c1e3ccSAndroid Build Coastguard Worker OR "${AOM_TARGET_SYSTEM}" STREQUAL "Windows") 110*77c1e3ccSAndroid Build Coastguard Worker set(objformat "win64") 111*77c1e3ccSAndroid Build Coastguard Worker else() 112*77c1e3ccSAndroid Build Coastguard Worker set(objformat "elf64") 113*77c1e3ccSAndroid Build Coastguard Worker endif() 114*77c1e3ccSAndroid Build Coastguard Worker elseif("${AOM_TARGET_CPU}" STREQUAL "x86") 115*77c1e3ccSAndroid Build Coastguard Worker if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") 116*77c1e3ccSAndroid Build Coastguard Worker set(objformat "macho32") 117*77c1e3ccSAndroid Build Coastguard Worker elseif("${AOM_TARGET_SYSTEM}" STREQUAL "MSYS" 118*77c1e3ccSAndroid Build Coastguard Worker OR "${AOM_TARGET_SYSTEM}" STREQUAL "CYGWIN" 119*77c1e3ccSAndroid Build Coastguard Worker OR "${AOM_TARGET_SYSTEM}" STREQUAL "Windows") 120*77c1e3ccSAndroid Build Coastguard Worker set(objformat "win32") 121*77c1e3ccSAndroid Build Coastguard Worker else() 122*77c1e3ccSAndroid Build Coastguard Worker set(objformat "elf32") 123*77c1e3ccSAndroid Build Coastguard Worker endif() 124*77c1e3ccSAndroid Build Coastguard Worker else() 125*77c1e3ccSAndroid Build Coastguard Worker message( 126*77c1e3ccSAndroid Build Coastguard Worker FATAL_ERROR "Unknown obj format: ${AOM_TARGET_CPU}-${AOM_TARGET_SYSTEM}") 127*77c1e3ccSAndroid Build Coastguard Worker endif() 128*77c1e3ccSAndroid Build Coastguard Worker 129*77c1e3ccSAndroid Build Coastguard Worker set(${out_format} ${objformat} PARENT_SCOPE) 130*77c1e3ccSAndroid Build Coastguard Workerendfunction() 131*77c1e3ccSAndroid Build Coastguard Worker 132*77c1e3ccSAndroid Build Coastguard Worker# Adds library target named $lib_name for ASM files in variable named by 133*77c1e3ccSAndroid Build Coastguard Worker# $asm_sources. Builds an output directory path from $lib_name. Links $lib_name 134*77c1e3ccSAndroid Build Coastguard Worker# into the aom library target(s). Generates a C file with an unused no-op 135*77c1e3ccSAndroid Build Coastguard Worker# function to ensure that all cmake generators can determine the linker 136*77c1e3ccSAndroid Build Coastguard Worker# language, and that build tools don't complain that an object exposes no 137*77c1e3ccSAndroid Build Coastguard Worker# symbols. 138*77c1e3ccSAndroid Build Coastguard Worker# 139*77c1e3ccSAndroid Build Coastguard Worker# In Xcode-based builds every step described above happens twice, and 140*77c1e3ccSAndroid Build Coastguard Worker# directory/target/object names are updated to include _shared and _static 141*77c1e3ccSAndroid Build Coastguard Worker# suffixes. 142*77c1e3ccSAndroid Build Coastguard Workerfunction(add_asm_library lib_name asm_sources) 143*77c1e3ccSAndroid Build Coastguard Worker if("${${asm_sources}}" STREQUAL "") 144*77c1e3ccSAndroid Build Coastguard Worker return() 145*77c1e3ccSAndroid Build Coastguard Worker endif() 146*77c1e3ccSAndroid Build Coastguard Worker 147*77c1e3ccSAndroid Build Coastguard Worker if(XCODE) 148*77c1e3ccSAndroid Build Coastguard Worker # CMake's generator does not output a build rule for Nasm files. Moreover, 149*77c1e3ccSAndroid Build Coastguard Worker # it makes Xcode believe Nasm files are of type "sourcecode" instead of 150*77c1e3ccSAndroid Build Coastguard Worker # "sourcecode.nasm", which prevents even the default rule from applying. 151*77c1e3ccSAndroid Build Coastguard Worker # This default rule is broken, though, because it doesn't apply any of the 152*77c1e3ccSAndroid Build Coastguard Worker # flags specified for ASM_NASM. See https://discourse.cmake.org/t/building- 153*77c1e3ccSAndroid Build Coastguard Worker # nasm-files-with-xcode/7934 154*77c1e3ccSAndroid Build Coastguard Worker list(APPEND asm_configs "static") 155*77c1e3ccSAndroid Build Coastguard Worker if(BUILD_SHARED_LIBS) 156*77c1e3ccSAndroid Build Coastguard Worker list(APPEND asm_configs "shared") 157*77c1e3ccSAndroid Build Coastguard Worker endif() 158*77c1e3ccSAndroid Build Coastguard Worker 159*77c1e3ccSAndroid Build Coastguard Worker set(as_executable "${CMAKE_ASM_NASM_COMPILER}") 160*77c1e3ccSAndroid Build Coastguard Worker if(NOT as_executable) 161*77c1e3ccSAndroid Build Coastguard Worker set(as_executable "${CMAKE_ASM_COMPILER}") 162*77c1e3ccSAndroid Build Coastguard Worker endif() 163*77c1e3ccSAndroid Build Coastguard Worker 164*77c1e3ccSAndroid Build Coastguard Worker foreach(asm_config ${asm_configs}) 165*77c1e3ccSAndroid Build Coastguard Worker set(asm_lib_name ${lib_name}_${asm_config}) 166*77c1e3ccSAndroid Build Coastguard Worker set(asm_lib_obj_dir "${AOM_CONFIG_DIR}/asm_objects/${asm_lib_name}") 167*77c1e3ccSAndroid Build Coastguard Worker if(NOT EXISTS "${asm_lib_obj_dir}") 168*77c1e3ccSAndroid Build Coastguard Worker file(MAKE_DIRECTORY "${asm_lib_obj_dir}") 169*77c1e3ccSAndroid Build Coastguard Worker endif() 170*77c1e3ccSAndroid Build Coastguard Worker 171*77c1e3ccSAndroid Build Coastguard Worker foreach(asm_source ${${asm_sources}}) 172*77c1e3ccSAndroid Build Coastguard Worker get_filename_component(asm_source_name "${asm_source}" NAME) 173*77c1e3ccSAndroid Build Coastguard Worker set(asm_object "${asm_lib_obj_dir}/${asm_source_name}.o") 174*77c1e3ccSAndroid Build Coastguard Worker add_custom_command(OUTPUT "${asm_object}" 175*77c1e3ccSAndroid Build Coastguard Worker COMMAND ${as_executable} ARGS ${AOM_AS_FLAGS} 176*77c1e3ccSAndroid Build Coastguard Worker -I${AOM_ROOT}/ -I${AOM_CONFIG_DIR}/ -o 177*77c1e3ccSAndroid Build Coastguard Worker "${asm_object}" "${asm_source}" 178*77c1e3ccSAndroid Build Coastguard Worker DEPENDS "${asm_source}" 179*77c1e3ccSAndroid Build Coastguard Worker COMMENT "Building ASM object ${asm_object}" 180*77c1e3ccSAndroid Build Coastguard Worker WORKING_DIRECTORY "${AOM_CONFIG_DIR}" 181*77c1e3ccSAndroid Build Coastguard Worker VERBATIM) 182*77c1e3ccSAndroid Build Coastguard Worker if(BUILD_SHARED_LIBS AND "${asm_config}" STREQUAL "static") 183*77c1e3ccSAndroid Build Coastguard Worker target_sources(aom_static PRIVATE "${asm_object}") 184*77c1e3ccSAndroid Build Coastguard Worker else() 185*77c1e3ccSAndroid Build Coastguard Worker target_sources(aom PRIVATE "${asm_object}") 186*77c1e3ccSAndroid Build Coastguard Worker endif() 187*77c1e3ccSAndroid Build Coastguard Worker endforeach() 188*77c1e3ccSAndroid Build Coastguard Worker endforeach() 189*77c1e3ccSAndroid Build Coastguard Worker else() 190*77c1e3ccSAndroid Build Coastguard Worker # For non-Xcode generators, CMake does not need extra help. The language 191*77c1e3ccSAndroid Build Coastguard Worker # support takes care of it. 192*77c1e3ccSAndroid Build Coastguard Worker set(asm_lib_name ${lib_name}) 193*77c1e3ccSAndroid Build Coastguard Worker 194*77c1e3ccSAndroid Build Coastguard Worker add_library(${asm_lib_name} OBJECT ${${asm_sources}}) 195*77c1e3ccSAndroid Build Coastguard Worker target_include_directories(${asm_lib_name} 196*77c1e3ccSAndroid Build Coastguard Worker PRIVATE ${AOM_ROOT} ${AOM_CONFIG_DIR}) 197*77c1e3ccSAndroid Build Coastguard Worker target_compile_options(${asm_lib_name} PRIVATE ${AOM_AS_FLAGS}) 198*77c1e3ccSAndroid Build Coastguard Worker set_property(TARGET ${asm_lib_name} PROPERTY FOLDER ${AOM_TARGET_CPU}) 199*77c1e3ccSAndroid Build Coastguard Worker if(BUILD_SHARED_LIBS) 200*77c1e3ccSAndroid Build Coastguard Worker target_sources(aom_static PRIVATE "$<TARGET_OBJECTS:${asm_lib_name}>") 201*77c1e3ccSAndroid Build Coastguard Worker endif() 202*77c1e3ccSAndroid Build Coastguard Worker target_sources(aom PRIVATE "$<TARGET_OBJECTS:${asm_lib_name}>") 203*77c1e3ccSAndroid Build Coastguard Worker 204*77c1e3ccSAndroid Build Coastguard Worker # Add the new lib target to the global list of aom library targets. 205*77c1e3ccSAndroid Build Coastguard Worker list(APPEND AOM_LIB_TARGETS ${asm_lib_name}) 206*77c1e3ccSAndroid Build Coastguard Worker endif() 207*77c1e3ccSAndroid Build Coastguard Worker 208*77c1e3ccSAndroid Build Coastguard Worker set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE) 209*77c1e3ccSAndroid Build Coastguard Workerendfunction() 210*77c1e3ccSAndroid Build Coastguard Worker 211*77c1e3ccSAndroid Build Coastguard Worker# Terminates generation if nasm found in PATH does not meet requirements. 212*77c1e3ccSAndroid Build Coastguard Worker# Currently checks only for presence of required object formats and support for 213*77c1e3ccSAndroid Build Coastguard Worker# the -Ox argument (multipass optimization). 214*77c1e3ccSAndroid Build Coastguard Workerfunction(test_nasm) 215*77c1e3ccSAndroid Build Coastguard Worker execute_process(COMMAND ${CMAKE_ASM_NASM_COMPILER} -hf 216*77c1e3ccSAndroid Build Coastguard Worker OUTPUT_VARIABLE nasm_helptext) 217*77c1e3ccSAndroid Build Coastguard Worker 218*77c1e3ccSAndroid Build Coastguard Worker if(NOT "${nasm_helptext}" MATCHES "-Ox") 219*77c1e3ccSAndroid Build Coastguard Worker message( 220*77c1e3ccSAndroid Build Coastguard Worker FATAL_ERROR "Unsupported nasm: multipass optimization not supported.") 221*77c1e3ccSAndroid Build Coastguard Worker endif() 222*77c1e3ccSAndroid Build Coastguard Worker 223*77c1e3ccSAndroid Build Coastguard Worker if("${AOM_TARGET_CPU}" STREQUAL "x86") 224*77c1e3ccSAndroid Build Coastguard Worker if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") 225*77c1e3ccSAndroid Build Coastguard Worker if(NOT "${nasm_helptext}" MATCHES "macho32") 226*77c1e3ccSAndroid Build Coastguard Worker message( 227*77c1e3ccSAndroid Build Coastguard Worker FATAL_ERROR "Unsupported nasm: macho32 object format not supported.") 228*77c1e3ccSAndroid Build Coastguard Worker endif() 229*77c1e3ccSAndroid Build Coastguard Worker elseif("${AOM_TARGET_SYSTEM}" STREQUAL "MSYS" 230*77c1e3ccSAndroid Build Coastguard Worker OR "${AOM_TARGET_SYSTEM}" STREQUAL "Windows") 231*77c1e3ccSAndroid Build Coastguard Worker if(NOT "${nasm_helptext}" MATCHES "win32") 232*77c1e3ccSAndroid Build Coastguard Worker message( 233*77c1e3ccSAndroid Build Coastguard Worker FATAL_ERROR "Unsupported nasm: win32 object format not supported.") 234*77c1e3ccSAndroid Build Coastguard Worker endif() 235*77c1e3ccSAndroid Build Coastguard Worker else() 236*77c1e3ccSAndroid Build Coastguard Worker if(NOT "${nasm_helptext}" MATCHES "elf32") 237*77c1e3ccSAndroid Build Coastguard Worker message( 238*77c1e3ccSAndroid Build Coastguard Worker FATAL_ERROR "Unsupported nasm: elf32 object format not supported.") 239*77c1e3ccSAndroid Build Coastguard Worker endif() 240*77c1e3ccSAndroid Build Coastguard Worker endif() 241*77c1e3ccSAndroid Build Coastguard Worker else() 242*77c1e3ccSAndroid Build Coastguard Worker if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") 243*77c1e3ccSAndroid Build Coastguard Worker if(NOT "${nasm_helptext}" MATCHES "macho64") 244*77c1e3ccSAndroid Build Coastguard Worker message( 245*77c1e3ccSAndroid Build Coastguard Worker FATAL_ERROR "Unsupported nasm: macho64 object format not supported.") 246*77c1e3ccSAndroid Build Coastguard Worker endif() 247*77c1e3ccSAndroid Build Coastguard Worker elseif("${AOM_TARGET_SYSTEM}" STREQUAL "MSYS" 248*77c1e3ccSAndroid Build Coastguard Worker OR "${AOM_TARGET_SYSTEM}" STREQUAL "Windows") 249*77c1e3ccSAndroid Build Coastguard Worker if(NOT "${nasm_helptext}" MATCHES "win64") 250*77c1e3ccSAndroid Build Coastguard Worker message( 251*77c1e3ccSAndroid Build Coastguard Worker FATAL_ERROR "Unsupported nasm: win64 object format not supported.") 252*77c1e3ccSAndroid Build Coastguard Worker endif() 253*77c1e3ccSAndroid Build Coastguard Worker else() 254*77c1e3ccSAndroid Build Coastguard Worker if(NOT "${nasm_helptext}" MATCHES "elf64") 255*77c1e3ccSAndroid Build Coastguard Worker message( 256*77c1e3ccSAndroid Build Coastguard Worker FATAL_ERROR "Unsupported nasm: elf64 object format not supported.") 257*77c1e3ccSAndroid Build Coastguard Worker endif() 258*77c1e3ccSAndroid Build Coastguard Worker endif() 259*77c1e3ccSAndroid Build Coastguard Worker endif() 260*77c1e3ccSAndroid Build Coastguard Workerendfunction() 261*77c1e3ccSAndroid Build Coastguard Worker 262*77c1e3ccSAndroid Build Coastguard Worker# Adds build command for generation of rtcd C source files using 263*77c1e3ccSAndroid Build Coastguard Worker# build/cmake/rtcd.pl. $config is the input perl file, $output is the output C 264*77c1e3ccSAndroid Build Coastguard Worker# include file, $source is the C source file, and $symbol is used for the symbol 265*77c1e3ccSAndroid Build Coastguard Worker# argument passed to rtcd.pl. 266*77c1e3ccSAndroid Build Coastguard Workerfunction(add_rtcd_build_step config output source symbol) 267*77c1e3ccSAndroid Build Coastguard Worker add_custom_command( 268*77c1e3ccSAndroid Build Coastguard Worker OUTPUT ${output} 269*77c1e3ccSAndroid Build Coastguard Worker COMMAND ${PERL_EXECUTABLE} ARGS "${AOM_ROOT}/build/cmake/rtcd.pl" 270*77c1e3ccSAndroid Build Coastguard Worker --arch=${AOM_TARGET_CPU} 271*77c1e3ccSAndroid Build Coastguard Worker --sym=${symbol} ${AOM_RTCD_FLAGS} 272*77c1e3ccSAndroid Build Coastguard Worker --config=${AOM_CONFIG_DIR}/config/aom_config.h ${config} > ${output} 273*77c1e3ccSAndroid Build Coastguard Worker DEPENDS "${AOM_ROOT}/build/cmake/rtcd.pl" ${config} 274*77c1e3ccSAndroid Build Coastguard Worker COMMENT "Generating ${output}" 275*77c1e3ccSAndroid Build Coastguard Worker WORKING_DIRECTORY ${AOM_CONFIG_DIR} 276*77c1e3ccSAndroid Build Coastguard Worker VERBATIM) 277*77c1e3ccSAndroid Build Coastguard Worker set_property(SOURCE ${source} PROPERTY OBJECT_DEPENDS ${output}) 278*77c1e3ccSAndroid Build Coastguard Worker set_property(SOURCE ${output} PROPERTY GENERATED TRUE) 279*77c1e3ccSAndroid Build Coastguard Workerendfunction() 280