summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorDonovan Baarda <abo@minkirri.apana.org.au>2019-09-17 17:32:31 +1000
committerGitHub <noreply@github.com>2019-09-17 17:32:31 +1000
commitd723fd19f399789bc2f819ee74bd90d7f9cd5360 (patch)
tree7eacc5cbf1dc55fe25de8a0b6baf98be8684a8d6 /CMakeLists.txt
parent96c33db9ec558dbe54b6a1339f446e3709695e76 (diff)
downloadlibrsync-d723fd19f399789bc2f819ee74bd90d7f9cd5360.tar.gz
Tidy logic for WIN32 "%zu" checking.
Re-arrange the logic to be a little less convoluted, and add comments explaining why it's done that way.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt23
1 files changed, 10 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11bb694..333f9cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,23 +109,20 @@ check_type_size ( "unsigned long" SIZEOF_UNSIGNED_LONG )
check_type_size ( "unsigned short" SIZEOF_UNSIGNED_SHORT )
# Check for printf "%zu" size_t formatting support.
-if(CMAKE_CROSSCOMPILING)
- if(WIN32)
- set(HAVE_PRINTF_Z OFF)
- message (STATUS "Cross compiling to Win32 - printf \"%zu\" size_t formatting support disabled")
- else()
+if(WIN32)
+ # CheckCSourceRuns checking for "%zu" succeeds but still gives warnings on win32.
+ set(HAVE_PRINTF_Z OFF)
+ message (STATUS "Compiling to Win32 - printf \"%zu\" size_t formatting support disabled")
+else(WIN32)
+ if(CMAKE_CROSSCOMPILING)
+ # CheckCSourceRuns doesn't work when cross-compiling.
set(HAVE_PRINTF_Z ON)
message (STATUS "Cross compiling - assuming printf \"%zu\" size_t formatting support")
- endif()
-else()
- if(WIN32)
- set(HAVE_PRINTF_Z OFF)
- message (STATUS "Compiling on Win32 - printf \"%zu\" size_t formatting support disabled")
- else()
+ else(CMAKE_CROSSCOMPILING)
include(CheckCSourceRuns)
check_c_source_runs("#include <stdio.h>\nint main(){char o[8];sprintf(o, \"%zu\", (size_t)7);return o[0] != '7';}" HAVE_PRINTF_Z)
- endif()
-endif()
+ endif(CMAKE_CROSSCOMPILING)
+endif(WIN32)
include (TestBigEndian)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)