summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-11-09 12:59:32 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-11-09 13:01:37 (GMT)
commitb1bc99d34a73c6bb42860742939e69fbe5e2e021 (patch)
tree0427294fbb9985fb47ef6dbdbf913785bcf26354 /Modules
parentd0391599a85b41cb94b6785bfcd29db8021a2052 (diff)
parentfcc89bda1d726e59e2f021f8d094ab6159b48e57 (diff)
downloadCMake-b1bc99d34a73c6bb42860742939e69fbe5e2e021.zip
CMake-b1bc99d34a73c6bb42860742939e69fbe5e2e021.tar.gz
CMake-b1bc99d34a73c6bb42860742939e69fbe5e2e021.tar.bz2
Merge topic 'TestBigEndian-use-abi-result'
fcc89bda1d TestBigEndian: Re-implement using byte order detected from ABI check 412ce907a2 Tests: Prepare RunCMake.ABI cases to run more checks Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5477
Diffstat (limited to 'Modules')
-rw-r--r--Modules/TestBigEndian.cmake36
1 files changed, 28 insertions, 8 deletions
diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake
index 8a769b7..ea8ca73 100644
--- a/Modules/TestBigEndian.cmake
+++ b/Modules/TestBigEndian.cmake
@@ -5,19 +5,41 @@
TestBigEndian
-------------
-Define macro to determine endian type
+.. deprecated:: 3.20
-Check if the system is big endian or little endian
+ Supserseded by the :variable:`CMAKE_<LANG>_BYTE_ORDER` variable.
-::
+Check if the target architecture is big endian or little endian.
+
+.. command:: test_big_endian
+
+ .. code-block:: cmake
+
+ test_big_endian(<var>)
+
+ Stores in variable ``<var>`` either 1 or 0 indicating whether the
+ target architecture is big or little endian.
- TEST_BIG_ENDIAN(VARIABLE)
- VARIABLE - variable to store the result to
#]=======================================================================]
+include_guard()
include(CheckTypeSize)
-macro(TEST_BIG_ENDIAN VARIABLE)
+function(TEST_BIG_ENDIAN VARIABLE)
+ if(";${CMAKE_C_BYTE_ORDER};${CMAKE_CXX_BYTE_ORDER};${CMAKE_CUDA_BYTE_ORDER};${CMAKE_OBJC_BYTE_ORDER};${CMAKE_OBJCXX_BYTE_ORDER};" MATCHES ";(BIG_ENDIAN|LITTLE_ENDIAN);")
+ set(order "${CMAKE_MATCH_1}")
+ if(order STREQUAL "BIG_ENDIAN")
+ set("${VARIABLE}" 1 PARENT_SCOPE)
+ else()
+ set("${VARIABLE}" 0 PARENT_SCOPE)
+ endif()
+ else()
+ __TEST_BIG_ENDIAN_LEGACY_IMPL(is_big)
+ set("${VARIABLE}" "${is_big}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+macro(__TEST_BIG_ENDIAN_LEGACY_IMPL VARIABLE)
if(NOT DEFINED HAVE_${VARIABLE})
message(CHECK_START "Check if the system is big endian")
message(CHECK_START "Searching 16 bit integer")
@@ -119,5 +141,3 @@ macro(TEST_BIG_ENDIAN VARIABLE)
endif()
endif()
endmacro()
-
-