summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2014-11-16 21:02:07 +0100
committerBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2014-11-16 21:02:39 +0100
commit1ddfdc1a880279ce07b2c43f60b7aa138d4ad315 (patch)
tree4ea142d9013a6dfdf84cab401f561d45ff8ccad4 /cmake
parentMore empty transfer craziness, this time when receving packets (diff)
downloadHeimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.gz
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.bz2
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.lz
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.xz
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.zst
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.zip
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Findlibusb-1.0.cmake98
-rw-r--r--cmake/LargeFiles.c15
-rw-r--r--cmake/LargeFiles.cmake87
-rw-r--r--cmake/LargeFiles64.c16
-rw-r--r--cmake/LargeFilesWindows.c8
5 files changed, 224 insertions, 0 deletions
diff --git a/cmake/Findlibusb-1.0.cmake b/cmake/Findlibusb-1.0.cmake
new file mode 100644
index 0000000..bc63763
--- /dev/null
+++ b/cmake/Findlibusb-1.0.cmake
@@ -0,0 +1,98 @@
+# - Try to find libusb-1.0
+# Once done this will define
+#
+# LIBUSB_1_FOUND - system has libusb
+# LIBUSB_1_INCLUDE_DIRS - the libusb include directory
+# LIBUSB_1_LIBRARIES - Link these to use libusb
+# LIBUSB_1_DEFINITIONS - Compiler switches required for using libusb
+#
+# Adapted from cmake-modules Google Code project
+#
+# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
+#
+# (Changes for libusb) Copyright (c) 2008 Kyle Machulis <kyle@nonpolynomial.com>
+#
+# Redistribution and use is allowed according to the terms of the New BSD license.
+#
+# CMake-Modules Project New BSD License
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# * Neither the name of the CMake-Modules Project nor the names of its
+# contributors may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+
+if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
+ # in cache already
+ set(LIBUSB_FOUND TRUE)
+else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
+ find_path(LIBUSB_1_INCLUDE_DIR
+ NAMES
+ libusb.h
+ PATHS
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ /sw/include
+ PATH_SUFFIXES
+ libusb-1.0
+ )
+
+ find_library(LIBUSB_1_LIBRARY
+ NAMES
+ usb-1.0 usb
+ PATHS
+ /usr/lib
+ /usr/local/lib
+ /opt/local/lib
+ /sw/lib
+ )
+
+ set(LIBUSB_1_INCLUDE_DIRS
+ ${LIBUSB_1_INCLUDE_DIR}
+ )
+ set(LIBUSB_1_LIBRARIES
+ ${LIBUSB_1_LIBRARY}
+)
+
+ if (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
+ set(LIBUSB_1_FOUND TRUE)
+ endif (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
+
+ if (LIBUSB_1_FOUND)
+ if (NOT libusb_1_FIND_QUIETLY)
+ message(STATUS "Found libusb-1.0:")
+ message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
+ message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
+ endif (NOT libusb_1_FIND_QUIETLY)
+ else (LIBUSB_1_FOUND)
+ if (libusb_1_FIND_REQUIRED)
+ message(FATAL_ERROR "Could not find libusb")
+ endif (libusb_1_FIND_REQUIRED)
+ endif (LIBUSB_1_FOUND)
+
+ # show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
+ mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
+
+endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) \ No newline at end of file
diff --git a/cmake/LargeFiles.c b/cmake/LargeFiles.c
new file mode 100644
index 0000000..d11ea97
--- /dev/null
+++ b/cmake/LargeFiles.c
@@ -0,0 +1,15 @@
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define VALID_ARRAY_LENGTH 1
+#define INVALID_ARRAY_LENGTH -1
+
+int main(int argc, const char **argv)
+{
+ int a[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? VALID_ARRAY_LENGTH : INVALID_ARRAY_LENGTH];
+ off_t offset = ftello(NULL);
+ fseeko(NULL, offset, SEEK_SET);
+ return 0;
+}
diff --git a/cmake/LargeFiles.cmake b/cmake/LargeFiles.cmake
new file mode 100644
index 0000000..b59295a
--- /dev/null
+++ b/cmake/LargeFiles.cmake
@@ -0,0 +1,87 @@
+macro(test_large_files VARIABLE USE_64_SUFFIX)
+ if(NOT DEFINED ${VARIABLE})
+ message(STATUS "Checking if large (64-bit) file support is available...")
+
+ if(${USE_64_SUFFIX})
+ set(SUFFIX_64 "64")
+ else(${USE_64_SUFFIX})
+ set(SUFFIX_64 "")
+ endif(${USE_64_SUFFIX})
+
+ # First try without any macros defined
+ try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}"
+ "${CMAKE_MODULE_PATH}/LargeFiles${SUFFIX_64}.c")
+
+ if(NOT LARGE_FILES_SUPPORTED)
+ # Try with C macro _FILE_OFFSET_BITS=64
+ try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}"
+ "${CMAKE_MODULE_PATH}/LargeFiles${SUFFIX_64}.c"
+ COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
+
+ if(LARGE_FILES_SUPPORTED)
+ set(_FILE_OFFSET_BITS=64 CACHE INTERNAL "C macro _FILE_OFFSET_BITS=64 is required for 64-bit file support")
+ endif(LARGE_FILES_SUPPORTED)
+ endif(NOT LARGE_FILES_SUPPORTED)
+
+ if(NOT LARGE_FILES_SUPPORTED)
+ # Try with C macro _LARGEFILE_SOURCE
+
+ try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}"
+ "${CMAKE_MODULE_PATH}/LargeFiles${SUFFIX_64}.c"
+ COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE${SUFFIX_64}")
+
+ if(LARGE_FILES_SUPPORTED)
+ set(_LARGEFILE_SOURCE${SUFFIX_64}=1 CACHE INTERNAL "C macro _LARGEFILE_SOURCE${SUFFIX_64} is required for 64-bit file support")
+ endif(LARGE_FILES_SUPPORTED)
+ endif(NOT LARGE_FILES_SUPPORTED)
+
+ if(NOT LARGE_FILES_SUPPORTED)
+ # Try with both C macro _FILE_OFFSET_BITS=64 and _LARGEFILE_SOURCE
+ try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}"
+ "${CMAKE_MODULE_PATH}/LargeFiles${SUFFIX_64}.c"
+ COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" "-D_LARGEFILE_SOURCE${SUFFIX_64}")
+
+ if(LARGE_FILES_SUPPORTED)
+ set(_FILE_OFFSET_BITS=64 CACHE INTERNAL "C macro _FILE_OFFSET_BITS=64 is required for 64-bit file support")
+ set(_LARGEFILE_SOURCE${SUFFIX_64}=1 CACHE INTERNAL "C macro _LARGEFILE_SOURCE${SUFFIX_64} is required for 64-bit file support")
+ endif(LARGE_FILES_SUPPORTED)
+ endif(NOT LARGE_FILES_SUPPORTED)
+
+ if(NOT LARGE_FILES_SUPPORTED)
+ # Maybe we are using the Windows C standard library
+ try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}"
+ "${CMAKE_MODULE_PATH}/LargeFilesWindows.c")
+ endif(NOT LARGE_FILES_SUPPORTED)
+
+ if(LARGE_FILES_SUPPORTED)
+ message(STATUS "Checking if large (64-bit) file support is available - yes")
+ set(${VARIABLE} 1 CACHE INTERNAL "Is large file support available?")
+ else(LARGE_FILES_SUPPORTED)
+ message(STATUS "Checking if large (64-bit) file support is available - no")
+ set(${VARIABLE} 0 CACHE INTERNAL "Is large file support available?")
+ endif(LARGE_FILES_SUPPORTED)
+ endif(NOT DEFINED ${VARIABLE})
+endmacro(test_large_files VARIABLE USE_64_SUFFIX)
+
+macro(use_large_files TARGET USE_64_SUFFIX)
+ test_large_files(USING_LARGE_FILES ${USE_64_SUFFIX})
+
+ if(USING_LARGE_FILES)
+ if(DEFINED _FILE_OFFSET_BITS)
+ set_property(TARGET ${TARGET}
+ APPEND PROPERTY COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
+ endif(DEFINED _FILE_OFFSET_BITS)
+
+ if(DEFINED _LARGEFILE_SOURCE)
+ set_property(TARGET ${TARGET}
+ APPEND PROPERTY COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE")
+ endif(DEFINED _LARGEFILE_SOURCE)
+
+ if(DEFINED _LARGEFILE_SOURCE64)
+ set_property(TARGET ${TARGET}
+ APPEND PROPERTY COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE64")
+ endif(DEFINED _LARGEFILE_SOURCE64)
+ else(USING_LARGE_FILES)
+ message(FATAL_ERROR "Large file support not available")
+ endif(USING_LARGE_FILES)
+endmacro(use_large_files TARGET USE_64_SUFFIX)
diff --git a/cmake/LargeFiles64.c b/cmake/LargeFiles64.c
new file mode 100644
index 0000000..57826b7
--- /dev/null
+++ b/cmake/LargeFiles64.c
@@ -0,0 +1,16 @@
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define VALID_ARRAY_LENGTH 1
+#define INVALID_ARRAY_LENGTH -1
+
+int main(int argc, const char **argv)
+{
+ int a[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? VALID_ARRAY_LENGTH : INVALID_ARRAY_LENGTH];
+ off_t offset = ftello64(NULL);
+ fseeko64(NULL, offset, SEEK_SET);
+ return 0;
+}
diff --git a/cmake/LargeFilesWindows.c b/cmake/LargeFilesWindows.c
new file mode 100644
index 0000000..85fadd8
--- /dev/null
+++ b/cmake/LargeFilesWindows.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main()
+{
+ __int64 off = 0;
+ _fseeki64(NULL, off, SEEK_SET);
+ return 0;
+}