aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChristian Andersen <csandersen3@gmail.com>2024-02-04 19:16:14 +0100
committerChristian Andersen <csandersen3@gmail.com>2024-02-04 22:24:10 +0100
commit5bd332ec20ea1c66e769f841b510a76320b995c3 (patch)
tree1f3c556953bdbe1c3f3461097c0550c691ccc1d7 /CMakeLists.txt
parent3d30672656b840756910809a52ac5fe54c24ec01 (diff)
downloadportable-5bd332ec20ea1c66e769f841b510a76320b995c3.tar.gz
portable-5bd332ec20ea1c66e769f841b510a76320b995c3.tar.bz2
portable-5bd332ec20ea1c66e769f841b510a76320b995c3.zip
Windows: Improve the check for endianness when using Visual Studio.
Visual studio does not define __BYTE_ORDER__ so all architectures were detected as LITTLE_ENDIAN since both __BYTE_ORDER__ and __ORDER_LITTLE_ENDIAN__ would evaluate to 0 and compare equal. This updates the checks to use CMakes detection of endianness, with a hard error, if this also fails.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt9
1 files changed, 9 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b8c1aa..730b84d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -142,6 +142,15 @@ endif()
142if(MSVC) 142if(MSVC)
143 add_definitions(-Dinline=__inline) 143 add_definitions(-Dinline=__inline)
144 message(STATUS "Using [${CMAKE_C_COMPILER_ID}] compiler") 144 message(STATUS "Using [${CMAKE_C_COMPILER_ID}] compiler")
145
146 include(TestBigEndian)
147 TEST_BIG_ENDIAN(HAVE_BIG_ENDIAN)
148 if(HAVE_BIG_ENDIAN)
149 add_definitions(-DHAVE_BIG_ENDIAN)
150 else()
151 add_definitions(-DHAVE_LITTLE_ENDIAN)
152 endif()
153
145 if(CMAKE_C_COMPILER_ID MATCHES "MSVC" OR CMAKE_C_COMPILER_ID MATCHES "Clang") 154 if(CMAKE_C_COMPILER_ID MATCHES "MSVC" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
146 set(MSVC_DISABLED_WARNINGS_LIST 155 set(MSVC_DISABLED_WARNINGS_LIST
147 "C4018" # 'expression' : signed/unsigned mismatch 156 "C4018" # 'expression' : signed/unsigned mismatch