From 2cfb00173efc028c73cd87df0b22506db8885182 Mon Sep 17 00:00:00 2001 From: Jon Szymaniak Date: Thu, 30 Oct 2014 13:01:32 -0400 Subject: [PATCH] cmake: Fixes for version check helper programs (Cygwin) It appears that although CMake no longer defines WIN32 for Cygwin, the libusb headers may be defining this macro, causing the code intended for MSVC builds to be used in libusb_version.c and fail to compile. Hence, we need to explicitly check for __CYGWIN__ in this program. Thank you to Jeremy Quirke for pointing out this issue and providing fixes. The libc version check doesn't make sense for Cygwin builds, so it is now skipped. --- host/CMakeLists.txt | 14 +++++++------- host/cmake/helpers/libusb_version.c | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 8c65e940..d20b605c 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -125,19 +125,19 @@ endif(MSVC) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "BSD" OR CYGWIN) set(BLADERF_OS_LINUX 1) - if(NOT CMAKE_CROSSCOMPILING) + if(NOT CMAKE_CROSSCOMPILING AND NOT CYGWIN) message(STATUS "Checking libc version...") try_run(LIBC_VERSION_RUN_RESULT LIBC_VERSION_COMPILE_RESULT ${CMAKE_HELPERS_BINARY_DIR} ${CMAKE_HELPERS_SOURCE_DIR}/libc_version.c RUN_OUTPUT_VARIABLE LIBC_VERSION) - endif(NOT CMAKE_CROSSCOMPILING) - if(LIBC_VERSION) - message(STATUS "libc version: ${LIBC_VERSION}") - else() - message(WARNING "Unable to determine libc version") - endif() + if(LIBC_VERSION) + message(STATUS "libc version: ${LIBC_VERSION}") + else() + message(WARNING "Unable to determine libc version") + endif() + endif(NOT CMAKE_CROSSCOMPILING AND NOT CYGWIN) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(BLADERF_OS_OSX 1) diff --git a/host/cmake/helpers/libusb_version.c b/host/cmake/helpers/libusb_version.c index a5b48fbc..b777cdb2 100644 --- a/host/cmake/helpers/libusb_version.c +++ b/host/cmake/helpers/libusb_version.c @@ -3,7 +3,7 @@ #include #include -#if WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) #include typedef const struct libusb_version * (__stdcall * version_fn)(void); #endif @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) int status = 0; const struct libusb_version *ver; -#if WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) if (argc > 1) { HINSTANCE dll; version_fn get_version;