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.
This commit is contained in:
Jon Szymaniak 2014-10-30 13:01:32 -04:00
commit 2cfb00173e
2 changed files with 9 additions and 9 deletions

View file

@ -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)

View file

@ -3,7 +3,7 @@
#include <string.h>
#include <libusb.h>
#if WIN32
#if defined(WIN32) && !defined(__CYGWIN__)
#include <winbase.h>
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;