1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
From 1be30c33b394fc4d2aeea4287e8df8701adad5a0 Mon Sep 17 00:00:00 2001
From: "Christian W. Zuckschwerdt" <zany@triq.net>
Date: Fri, 12 Apr 2024 16:24:09 +0200
Subject: [PATCH 2/5] Fix cmake and compiler warnings (#29)
---
CMakeLists.txt | 18 +++++++++---------
FindLibAIRSPY.cmake | 46 ++++++++++++++++++++++++++++++++-------------
2 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca4f06b..b5a3cb4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
@@ -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")
@@ -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
diff --git a/FindLibAIRSPY.cmake b/FindLibAIRSPY.cmake
index 221edcc..32bb770 100644
--- a/FindLibAIRSPY.cmake
+++ b/FindLibAIRSPY.cmake
@@ -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)
--
2.47.3
|