summaryrefslogtreecommitdiffstats
path: root/third_party/aom/build/cmake/compiler_tests.cmake
diff options
context:
space:
mode:
authortrav90 <travawine@palemoon.org>2018-10-15 21:45:30 -0500
committertrav90 <travawine@palemoon.org>2018-10-15 21:45:30 -0500
commit68569dee1416593955c1570d638b3d9250b33012 (patch)
treed960f017cd7eba3f125b7e8a813789ee2e076310 /third_party/aom/build/cmake/compiler_tests.cmake
parent07c17b6b98ed32fcecff15c083ab0fd878de3cf0 (diff)
downloadUXP-68569dee1416593955c1570d638b3d9250b33012.tar
UXP-68569dee1416593955c1570d638b3d9250b33012.tar.gz
UXP-68569dee1416593955c1570d638b3d9250b33012.tar.lz
UXP-68569dee1416593955c1570d638b3d9250b33012.tar.xz
UXP-68569dee1416593955c1570d638b3d9250b33012.zip
Import aom library
This is the reference implementation for the Alliance for Open Media's av1 video code. The commit used was 4d668d7feb1f8abd809d1bca0418570a7f142a36.
Diffstat (limited to 'third_party/aom/build/cmake/compiler_tests.cmake')
-rw-r--r--third_party/aom/build/cmake/compiler_tests.cmake133
1 files changed, 133 insertions, 0 deletions
diff --git a/third_party/aom/build/cmake/compiler_tests.cmake b/third_party/aom/build/cmake/compiler_tests.cmake
new file mode 100644
index 000000000..e763597a2
--- /dev/null
+++ b/third_party/aom/build/cmake/compiler_tests.cmake
@@ -0,0 +1,133 @@
+##
+## Copyright (c) 2016, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+include(CheckCSourceCompiles)
+include(CheckCXXSourceCompiles)
+
+# The basic main() function used in all compile tests.
+set(AOM_C_MAIN "\nint main(void) { return 0; }")
+set(AOM_CXX_MAIN "\nint main() { return 0; }")
+
+# Strings containing the names of passed and failed tests.
+set(AOM_C_PASSED_TESTS)
+set(AOM_C_FAILED_TESTS)
+set(AOM_CXX_PASSED_TESTS)
+set(AOM_CXX_FAILED_TESTS)
+
+function(aom_push_var var new_value)
+ set(SAVED_${var} ${var} PARENT_SCOPE)
+ set(${var} ${new_value} PARENT_SCOPE)
+endfunction ()
+
+function(aom_pop_var var)
+ set(var ${SAVED_${var}} PARENT_SCOPE)
+ unset(SAVED_${var} PARENT_SCOPE)
+endfunction ()
+
+# Confirms $test_source compiles and stores $test_name in one of
+# $AOM_C_PASSED_TESTS or $AOM_C_FAILED_TESTS depending on out come. When the
+# test passes $result_var is set to 1. When it fails $result_var is unset.
+# The test is not run if the test name is found in either of the passed or
+# failed test variables.
+function(aom_check_c_compiles test_name test_source result_var)
+ unset(C_TEST_PASSED CACHE)
+ unset(C_TEST_FAILED CACHE)
+ string(FIND "${AOM_C_PASSED_TESTS}" "${test_name}" C_TEST_PASSED)
+ string(FIND "${AOM_C_FAILED_TESTS}" "${test_name}" C_TEST_FAILED)
+ if (${C_TEST_PASSED} EQUAL -1 AND ${C_TEST_FAILED} EQUAL -1)
+ unset(C_TEST_COMPILED CACHE)
+ message("Running C compiler test: ${test_name}")
+ check_c_source_compiles("${test_source} ${AOM_C_MAIN}" C_TEST_COMPILED)
+ set(${result_var} ${C_TEST_COMPILED} PARENT_SCOPE)
+
+ if (C_TEST_COMPILED)
+ set(AOM_C_PASSED_TESTS "${AOM_C_PASSED_TESTS} ${test_name}" CACHE STRING
+ "" FORCE)
+ else ()
+ set(AOM_C_FAILED_TESTS "${AOM_C_FAILED_TESTS} ${test_name}" CACHE STRING
+ "" FORCE)
+ message("C Compiler test ${test_name} failed.")
+ endif ()
+ elseif (NOT ${C_TEST_PASSED} EQUAL -1)
+ set(${result_var} 1 PARENT_SCOPE)
+ else () # ${C_TEST_FAILED} NOT EQUAL -1
+ unset(${result_var} PARENT_SCOPE)
+ endif ()
+endfunction ()
+
+# Confirms $test_source compiles and stores $test_name in one of
+# $AOM_CXX_PASSED_TESTS or $AOM_CXX_FAILED_TESTS depending on out come. When the
+# test passes $result_var is set to 1. When it fails $result_var is unset.
+# The test is not run if the test name is found in either of the passed or
+# failed test variables.
+function(aom_check_cxx_compiles test_name test_source result_var)
+ unset(CXX_TEST_PASSED CACHE)
+ unset(CXX_TEST_FAILED CACHE)
+ string(FIND "${AOM_CXX_PASSED_TESTS}" "${test_name}" CXX_TEST_PASSED)
+ string(FIND "${AOM_CXX_FAILED_TESTS}" "${test_name}" CXX_TEST_FAILED)
+ if (${CXX_TEST_PASSED} EQUAL -1 AND ${CXX_TEST_FAILED} EQUAL -1)
+ unset(CXX_TEST_COMPILED CACHE)
+ message("Running CXX compiler test: ${test_name}")
+ check_cxx_source_compiles("${test_source} ${AOM_CXX_MAIN}"
+ CXX_TEST_COMPILED)
+ set(${result_var} ${CXX_TEST_COMPILED} PARENT_SCOPE)
+
+ if (CXX_TEST_COMPILED)
+ set(AOM_CXX_PASSED_TESTS "${AOM_CXX_PASSED_TESTS} ${test_name}" CACHE
+ STRING "" FORCE)
+ else ()
+ set(AOM_CXX_FAILED_TESTS "${AOM_CXX_FAILED_TESTS} ${test_name}" CACHE
+ STRING "" FORCE)
+ message("CXX Compiler test ${test_name} failed.")
+ endif ()
+ elseif (NOT ${CXX_TEST_PASSED} EQUAL -1)
+ set(${result_var} 1 PARENT_SCOPE)
+ else () # ${CXX_TEST_FAILED} NOT EQUAL -1
+ unset(${result_var} PARENT_SCOPE)
+ endif ()
+endfunction ()
+
+# Convenience function that confirms $test_source compiles as C and C++.
+# $result_var is set to 1 when both tests are successful, and 0 when one or both
+# tests fail.
+# Note: This function is intended to be used to write to result variables that are
+# expanded via configure_file(). $result_var is set to 1 or 0 to allow direct
+# usage of the value in generated source files.
+function(aom_check_source_compiles test_name test_source result_var)
+ unset(C_PASSED)
+ unset(CXX_PASSED)
+ aom_check_c_compiles(${test_name} ${test_source} C_PASSED)
+ aom_check_cxx_compiles(${test_name} ${test_source} CXX_PASSED)
+ if (C_PASSED AND CXX_PASSED)
+ set(${result_var} 1 PARENT_SCOPE)
+ else ()
+ set(${result_var} 0 PARENT_SCOPE)
+ endif ()
+endfunction ()
+
+# When inline support is detected for the current compiler the supported
+# inlining keyword is written to $result in caller scope.
+function (aom_get_inline result)
+ aom_check_source_compiles("inline_check_1"
+ "static inline void function(void) {}"
+ HAVE_INLINE_1)
+ if (HAVE_INLINE_1 EQUAL 1)
+ set(${result} "inline" PARENT_SCOPE)
+ return()
+ endif ()
+
+ # Check __inline.
+ aom_check_source_compiles("inline_check_2"
+ "static __inline void function(void) {}"
+ HAVE_INLINE_2)
+ if (HAVE_INLINE_2 EQUAL 1)
+ set(${result} "__inline" PARENT_SCOPE)
+ endif ()
+endfunction ()