Skip to content

Commit

Permalink
Fix cmake and compiler warnings (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
zuckschwerdt authored Apr 12, 2024
1 parent e0358b5 commit 1be30c3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
# Build Soapy SDR support module for Airspy Devices
###################################################

cmake_minimum_required(VERSION 2.8.7)
cmake_minimum_required(VERSION 2.8.12)

project(SoapyAirspy CXX)

find_package(SoapySDR "0.4.0" NO_MODULE REQUIRED)
if (NOT SoapySDR_FOUND)
if(NOT SoapySDR_FOUND)
message(FATAL_ERROR "Soapy SDR development files not found...")
endif ()
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

find_package(LibAIRSPY)
find_package(LibAIRSPY REQUIRED)

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${LIBAIRSPY_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${LibAIRSPY_INCLUDE_DIRS})

#enable c++11 features
if(CMAKE_COMPILER_IS_GNUCXX)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
#C++11 is a required language feature for this project
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" HAS_STD_CXX11)
Expand All @@ -30,8 +30,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
#Thread support enabled (not the same as -lpthread)
list(APPEND AIRSPY_LIBS -pthread)
#disable warnings for unused parameters
add_definitions(-Wno-unused-parameter)
endif(CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-Wall -Wextra -Wno-unused-parameter)
endif()

if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wc++11-extensions")
Expand All @@ -45,7 +45,7 @@ endif(APPLE)
#SET (AIRSPY_LIBS ${COREFOUNDATION_LIBRARY} ${AIRSPY_LIBS} )
# ENDIF (APPLE)

list(APPEND AIRSPY_LIBS ${LIBAIRSPY_LIBRARIES})
list(APPEND AIRSPY_LIBS ${LibAIRSPY_LIBRARIES})

SOAPY_SDR_MODULE_UTIL(
TARGET airspySupport
Expand Down
46 changes: 33 additions & 13 deletions FindLibAIRSPY.cmake
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(PC_LIBAIRSPY libairspy)
# - Try to find LibAIRSPY
# Once done this will define
#
# LibAIRSPY_FOUND - System has libairspy
# LibAIRSPY_INCLUDE_DIRS - The libairspy include directories
# LibAIRSPY_LIBRARIES - The libraries needed to use libairspy
# LibAIRSPY_DEFINITIONS - Compiler switches required for using libairspy
# LibAIRSPY_VERSION - The librtlsdr version
#

FIND_PATH(
LIBAIRSPY_INCLUDE_DIRS
find_package(PkgConfig)
pkg_check_modules(PC_LibAIRSPY libairspy)
set(LibAIRSPY_DEFINITIONS ${PC_LibAIRSPY_CFLAGS_OTHER})

find_path(
LibAIRSPY_INCLUDE_DIRS
NAMES libairspy/airspy.h
HINTS $ENV{LIBAIRSPY_DIR}/include
${PC_LIBAIRSPY_INCLUDEDIR}
HINTS $ENV{LibAIRSPY_DIR}/include
${PC_LibAIRSPY_INCLUDEDIR}
PATHS /usr/local/include
/usr/include
)

FIND_LIBRARY(
LIBAIRSPY_LIBRARIES
find_library(
LibAIRSPY_LIBRARIES
NAMES airspy
HINTS $ENV{LIBAIRSPY_DIR}/lib
${PC_LIBAIRSPY_LIBDIR}
HINTS $ENV{LibAIRSPY_DIR}/lib
${PC_LibAIRSPY_LIBDIR}
PATHS /usr/local/lib
/usr/lib
)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBAIRSPY DEFAULT_MSG LIBAIRSPY_LIBRARIES LIBAIRSPY_INCLUDE_DIRS)
MARK_AS_ADVANCED(LIBAIRSPY_LIBRARIES LIBAIRSPY_INCLUDE_DIRS)
set(LibAIRSPY_VERSION ${PC_LibAIRSPY_VERSION})

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LibAIRSPY_FOUND to TRUE
# if all listed variables are TRUE
# Note that `FOUND_VAR LibAIRSPY_FOUND` is needed for cmake 3.2 and older.
find_package_handle_standard_args(LibAIRSPY
FOUND_VAR LibAIRSPY_FOUND
REQUIRED_VARS LibAIRSPY_LIBRARIES LibAIRSPY_INCLUDE_DIRS
VERSION_VAR LibAIRSPY_VERSION)

mark_as_advanced(LibAIRSPY_LIBRARIES LibAIRSPY_INCLUDE_DIRS)

0 comments on commit 1be30c3

Please sign in to comment.