From a884a45ab16700e426a30c5b78583c9193658760 Mon Sep 17 00:00:00 2001 From: Alexander Sieg Date: Sat, 14 Aug 2021 11:58:54 +0200 Subject: [PATCH] Fix builds on FreeBSD Without this patch the cmake config assume that every UNIX system that is not APPLE is automatically a linux system. This however causes problems on FreeBSD and properly on other BSD systems. We now explicitly check if the CMAKE_SYSTEM_NAME is set to Linux. --- CMakeLists.txt | 4 ++-- cmake/modules/LibnfcDrivers.cmake | 6 +++--- libnfc/CMakeLists.txt | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05104a4..019fb7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,7 @@ ENDIF(NOT WIN32) INCLUDE(LibnfcDrivers) -IF(UNIX AND NOT APPLE) +IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") IF(I2C_REQUIRED) # Inspired from http://cmake.3232098.n2.nabble.com/RFC-cmake-analog-to-AC-SEARCH-LIBS-td7585423.html INCLUDE (CheckFunctionExists) @@ -172,7 +172,7 @@ IF(UNIX AND NOT APPLE) ENDIF (HAVE_CLOCK_GETTIME_IN_RT) ENDIF (NOT HAVE_CLOCK_GETTIME) ENDIF(I2C_REQUIRED) -ENDIF(UNIX AND NOT APPLE) + ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") IF(PCSC_INCLUDE_DIRS) INCLUDE_DIRECTORIES(${PCSC_INCLUDE_DIRS}) diff --git a/cmake/modules/LibnfcDrivers.cmake b/cmake/modules/LibnfcDrivers.cmake index 7dc2503..ee0a46c 100644 --- a/cmake/modules/LibnfcDrivers.cmake +++ b/cmake/modules/LibnfcDrivers.cmake @@ -3,13 +3,13 @@ SET(LIBNFC_DRIVER_ACR122_PCSC OFF CACHE BOOL "Enable ACR122 support (Depends on SET(LIBNFC_DRIVER_ACR122_USB ON CACHE BOOL "Enable ACR122 support (Direct USB connection)") SET(LIBNFC_DRIVER_ACR122S ON CACHE BOOL "Enable ACR122S support (Use serial port)") SET(LIBNFC_DRIVER_ARYGON ON CACHE BOOL "Enable ARYGON support (Use serial port)") -IF(UNIX AND NOT APPLE) +IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") SET(LIBNFC_DRIVER_PN532_I2C ON CACHE BOOL "Enable PN532 I2C support (Use I2C bus)") SET(LIBNFC_DRIVER_PN532_SPI ON CACHE BOOL "Enable PN532 SPI support (Use SPI bus)") -ELSE(UNIX AND NOT APPLE) +ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Linux") SET(LIBNFC_DRIVER_PN532_I2C OFF CACHE BOOL "Enable PN532 I2C support (Use I2C bus)") SET(LIBNFC_DRIVER_PN532_SPI OFF CACHE BOOL "Enable PN532 SPI support (Use SPI bus)") -ENDIF(UNIX AND NOT APPLE) +ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") SET(LIBNFC_DRIVER_PN532_UART ON CACHE BOOL "Enable PN532 UART support (Use serial port)") SET(LIBNFC_DRIVER_PN53X_USB ON CACHE BOOL "Enable PN531 and PN531 USB support (Depends on libusb)") diff --git a/libnfc/CMakeLists.txt b/libnfc/CMakeLists.txt index 2867d4e..2b4c39c 100644 --- a/libnfc/CMakeLists.txt +++ b/libnfc/CMakeLists.txt @@ -29,23 +29,23 @@ IF(UART_REQUIRED) ENDIF(UART_REQUIRED) IF(I2C_REQUIRED) - IF(UNIX AND NOT APPLE) + IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") LIST(APPEND BUSES_SOURCES buses/i2c) - ELSE(UNIX AND NOT APPLE) + ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # Only Linux is supported at the moment #LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/i2c) MESSAGE( FATAL_ERROR "I2C is only (yet) supported in Linux!" ) - ENDIF(UNIX AND NOT APPLE) + ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") ENDIF(I2C_REQUIRED) IF(SPI_REQUIRED) - IF(UNIX AND NOT APPLE) + IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") LIST(APPEND BUSES_SOURCES buses/spi) - ELSE(UNIX AND NOT APPLE) + ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # Only Linux is supported at the moment #LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/spi) MESSAGE( FATAL_ERROR "SPI is only (yet) supported in Linux!" ) - ENDIF(UNIX AND NOT APPLE) + ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") ENDIF(SPI_REQUIRED) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/buses)