Skip to content

Commit

Permalink
Fix builds on FreeBSD
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xanderio committed Aug 14, 2021
1 parent c8185c9 commit a884a45
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:https://cmake.3232098.n2.nabble.com/RFC-cmake-analog-to-AC-SEARCH-LIBS-td7585423.html
INCLUDE (CheckFunctionExists)
Expand All @@ -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})
Expand Down
6 changes: 3 additions & 3 deletions cmake/modules/LibnfcDrivers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)")

Expand Down
12 changes: 6 additions & 6 deletions libnfc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a884a45

Please sign in to comment.