Updated CMake finders and changes to build map65 on Linux

This commit is contained in:
Bill Somerville 2021-04-11 15:29:15 +01:00
parent 74bd3c1d0c
commit 56c92c55fb
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
14 changed files with 232 additions and 100 deletions

View File

@ -0,0 +1,87 @@
# Findlibusb
# =======
#
# Find the usb library
#
# This will define the following variables::
#
# libusb_FOUND - True if the system has the usb library
# libusb_VERSION - The verion of the usb library which was found
#
# and the following imported targets::
#
# libusb::libusb - The libusb library
#
# If libusb_STATIC is TRUE then static linking will be assumed
#
function(dump_cmake_variables)
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
if (ARGV0)
unset(MATCHED)
string(REGEX MATCH ${ARGV0} MATCHED ${_variableName})
if (NOT MATCHED)
continue()
endif()
endif()
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
endfunction()
include (LibFindMacros)
# Use pkg-config to get hints about paths, libs and, flags
libfind_pkg_check_modules (libusb_PC libusb-1.0)
# Include dir
find_path (libusb_INCLUDE_DIR
NAMES libusb.h
PATHS ${libusb_PC_INCLUDE_DIRS}
)
# Library
if (libusb_STATIC)
find_library (libusb_LIBRARY
NAMES usb-1.0
PATHS ${libusb_PC_STATIC_LIBRARY_DIRS}
)
else ()
find_library (libusb_LIBRARY
NAMES usb-1.0
PATHS ${libusb_PC_LIBRARY_DIRS}
)
endif ()
set (libusb_PROCESS_INCLUDES libusb_INCLUDE_DIR)
set (libusb_PROCESS_LIBS libusb_LIBRARY)
libfind_process (libusb)
#dump_cmake_variables ("[lL][iI][bB][uU][sS]")
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (libusb
REQUIRED_VARS
libusb_LIBRARY
libusb_INCLUDE_DIR
VERSION_VAR libusb_VERSION
)
if (libusb_FOUND)
set (libusb_LIBRARIES ${libusb_LIBRARY})
set (libusb_INCLUDE_DIRS ${libusb_INCLUDE_DIR})
set (libusb_DEFINITIONS ${libusb_CFLAGS_OTHER})
endif ()
if (libusb_FOUND AND NOT TARGET libusb::libusb)
add_library (libusb::libusb UNKNOWN IMPORTED)
set_target_properties (libusb::libusb PROPERTIES
IMPORTED_LOCATION "${libusb_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${libusb_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${libusb_INCLUDE_DIR}"
)
endif ()
mark_as_advanced (
libusb_INCLUDE_DIR
libusb_LIBRARY
)

View File

@ -3,45 +3,83 @@
# Once done, this will define: # Once done, this will define:
# #
# portaudio_FOUND - system has portaudio # portaudio_FOUND - system has portaudio
# portaudio_INCLUDE_DIRS - the portaudio include directories # portaudio_VERSION - The version of the portaudio library which was found
# portaudio_LIBRARIES - link these to use portaudio #
# portaudio_LIBRARY_DIRS - required shared/dynamic libraries are here # and the following imported targets::
#
# portaudio::portaudio - The portaudio library
# #
# If portaudio_STATIC is TRUE then static linking will be assumed # If portaudio_STATIC is TRUE then static linking will be assumed
# #
function(dump_cmake_variables)
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
if (ARGV0)
unset(MATCHED)
string(REGEX MATCH ${ARGV0} MATCHED ${_variableName})
if (NOT MATCHED)
continue()
endif()
endif()
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
endfunction()
include (LibFindMacros) include (LibFindMacros)
set (portaudio_LIBRARY_DIRS)
# pkg-config?
find_path (__portaudio_pc_path NAMES portaudio-2.0.pc
PATH_SUFFIXES lib/pkgconfig lib64/pkgconfig
)
if (__portaudio_pc_path)
set (__pc_path $ENV{PKG_CONFIG_PATH})
list (APPEND __pc_path "${__portaudio_pc_path}")
set (ENV{PKG_CONFIG_PATH} "${__pc_path}")
unset (__pc_path CACHE)
endif ()
unset (__portaudio_pc_path CACHE)
# Use pkg-config to get hints about paths, libs and, flags # Use pkg-config to get hints about paths, libs and, flags
unset (__pkg_config_checked_hamlib CACHE) libfind_pkg_check_modules (portaudio_PC portaudio-2.0)
libfind_pkg_check_modules (PORTAUDIO portaudio-2.0)
# Include dir
find_path (portaudio_INCLUDE_DIR
NAMES portaudio.h
PATHS ${portaudio_PC_INCLUDE_DIRS}
)
# Library
if (portaudio_STATIC) if (portaudio_STATIC)
set (portaudio_PROCESS_INCLUDES PORTAUDIO_STATIC_INCLUDE_DIRS) find_library (portaudio_LIBRARY
set (portaudio_PROCESS_LIBS PORTAUDIO_STATIC_LDFLAGS) NAMES portaudio
set (portaudio_LIBRARY_DIRS ${PORTAUDIO_STATIC_LIBRARY_DIRS}) PATHS ${portaudio_PC_STATIC_LIBRARY_DIRS}
)
else () else ()
set (portaudio_PROCESS_INCLUDES PORTAUDIO_INCLUDE_DIRS) find_library (portaudio_LIBRARY
set (portaudio_PROCESS_LIBS PORTAUDIO_LDFLAGS) NAMES portaudio
set (portaudio_LIBRARY_DIRS ${PORTAUDIO_LIBRARY_DIRS}) PATHS ${portaudio_PC_LIBRARY_DIRS}
)
endif () endif ()
set (portaudio_PROCESS_INCLUDES portaudio_INCLUDE_DIR)
set (portaudio_PROCESS_LIBS portaudio_LIBRARY)
libfind_process (portaudio) libfind_process (portaudio)
# Handle the QUIETLY and REQUIRED arguments and set PORTAUDIO_FOUND to # Handle the QUIETLY and REQUIRED arguments and set PORTAUDIO_FOUND to
# TRUE if all listed variables are TRUE # TRUE if all listed variables are TRUE
include (FindPackageHandleStandardArgs) include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (portaudio DEFAULT_MSG portaudio_INCLUDE_DIRS portaudio_LIBRARIES portaudio_LIBRARY_DIRS) find_package_handle_standard_args (portaudio
REQUIRED_VARS
portaudio_LIBRARY
portaudio_INCLUDE_DIR
VERSION_VAR portaudio_VERSION
)
if (portaudio_FOUND)
set (portaudio_LIBRARIES ${portaudio_LIBRARY})
set (portaudio_INCLUDE_DIRS ${portaudio_INCLUDE_DIR})
set (portaudio_DEFINITIONS ${portaudio_CFLAGS_OTHER})
endif ()
if (portaudio_FOUND AND NOT TARGET portaudio::portaudio)
add_library (portaudio::portaudio UNKNOWN IMPORTED)
set_target_properties (portaudio::portaudio PROPERTIES
IMPORTED_LOCATION "${portaudio_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${portaudio_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${portaudio_INCLUDE_DIR}"
)
endif ()
mark_as_advanced (
portaudio_INCLUDE_DIR
portaudio_LIBRARY
)

View File

@ -1,57 +0,0 @@
# Findusb
# =======
#
# Find the usb library
#
# This will define the following variables::
#
# usb_FOUND - True if the system has the usb library
# usb_VERSION - The verion of the usb library which was found
#
# and the following imported targets::
#
# usb::usb - The libusb library
find_package (PkgConfig)
pkg_check_modules (PC_usb QUIET usb)
find_path (usb_INCLUDE_DIR
NAMES libusb.h
PATHS ${PC_usb_INCLUDE_DIRS}
PATH_SUFFIXES libusb-1.0
)
find_library (usb_LIBRARY
NAMES libusb-1.0
PATHS $PC_usb_LIBRARY_DIRS}
)
set (usb_VERSION ${PC_usb_VERSION})
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (usb
FOUND_VAR usb_FOUND
REQUIRED_VARS
usb_LIBRARY
usb_INCLUDE_DIR
VERSION_VAR usb_VERSION
)
if (usb_FOUND)
set (usb_LIBRARIES ${usb_LIBRARY})
set (usb_INCLUDE_DIRS ${usb_INCLUDE_DIR})
set (usb_DEFINITIONS ${PC_usb_CFLAGS_OTHER})
endif ()
if (usb_FOUND AND NOT TARGET usb::usb)
add_library (usb::usb UNKNOWN IMPORTED)
set_target_properties (usb::usb PROPERTIES
IMPORTED_LOCATION "${usb_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_usb_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${usb_INCLUDE_DIR}"
)
endif ()
mark_as_advanced (
usb_INCLUDE_DIR
usb_LIBRARY
)

View File

@ -813,12 +813,27 @@ endif (APPLE)
# #
include (CheckTypeSize) include (CheckTypeSize)
include (CheckCSourceCompiles) include (CheckCSourceCompiles)
include (CheckIncludeFiles)
include (CheckSymbolExists) include (CheckSymbolExists)
include (generate_version_info) include (generate_version_info)
find_program(CTAGS ctags) find_program(CTAGS ctags)
find_program(ETAGS etags) find_program(ETAGS etags)
#
# Platform checks
#
check_include_files ("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
check_include_files (stdio.h HAVE_STDIO_H)
check_include_files (stdlib.h HAVE_STDLIB_H)
check_include_files (unistd.h HAVE_UNISTD_H)
check_include_files (sys/ioctl.h HAVE_SYS_IOCTL_H)
check_include_files (sys/types.h HAVE_SYS_TYPES_H)
check_include_files (fcntl.h HAVE_FCNTL_H)
check_include_files (sys/stat.h HAVE_SYS_STAT_H)
check_include_files ("linux/ppdev.h;linux/parport.h" HAVE_LINUX_PPDEV_H)
check_include_files ("dev/ppbus/ppi.h;dev/ppbus/ppbconf.h" HAVE_DEV_PPBUS_PPI_H)
# #
# Standard C Math Library # Standard C Math Library
# #

View File

@ -1,6 +1,6 @@
find_package (portaudio REQUIRED) find_package (portaudio REQUIRED)
find_package (usb REQUIRED) find_package (libusb REQUIRED)
set (map65_CXXSRCS set (map65_CXXSRCS
about.cpp about.cpp
@ -43,6 +43,13 @@ set (map65_UISRCS
widegraph.ui widegraph.ui
) )
set (map65_C_and_CXXSRCS
${map65_CSRCS}
${map65_CXXSRCS}
)
set_property (SOURCE ${map65_C_and_CXXSRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -include wsjtx_config.h")
set_property (SOURCE ${map65_C_and_CXXSRCS} APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/wsjtx_config.h)
# build the subdirectories # build the subdirectories
add_subdirectory (libm65) add_subdirectory (libm65)
@ -51,7 +58,7 @@ qt5_wrap_ui (map65_GENUISRCS ${map65_UISRCS})
add_executable (map65 ${map65_CXXSRCS} ${map65_CSRCS} ${map65_GENUISRCS} map65.rc) add_executable (map65 ${map65_CXXSRCS} ${map65_CSRCS} ${map65_GENUISRCS} map65.rc)
target_include_directories (map65 PRIVATE ${PORTAUDIO_INCLUDE_DIRS}) target_include_directories (map65 PRIVATE ${PORTAUDIO_INCLUDE_DIRS})
target_link_libraries (map65 m65impl ${FFTW3_LIBRARIES} Qt5::Widgets Qt5::Network ${PORTAUDIO_STATIC_LDFLAGS} usb::usb) target_link_libraries (map65 m65impl ${FFTW3_LIBRARIES} Qt5::Widgets Qt5::Network portaudio::portaudio libusb::libusb)
install ( install (
TARGETS map65 TARGETS map65

View File

@ -1,5 +1,6 @@
#include "bandmap.h" #include "bandmap.h"
#include "ui_bandmap.h" #include "ui_bandmap.h"
#include "../qt_helpers.hpp"
#include <QDebug> #include <QDebug>
BandMap::BandMap(QWidget *parent) : BandMap::BandMap(QWidget *parent) :
@ -38,7 +39,7 @@ void BandMap::setText(QString t)
s3="<span style=color:"+m_color3+";>"; s3="<span style=color:"+m_color3+";>";
ui->bmTextBrowser->clear(); ui->bmTextBrowser->clear();
QStringList lines = t.split( "\n", Qt::SkipEmptyParts ); QStringList lines = t.split( "\n", SkipEmptyParts );
int nrows=(lines.length()+ncols-1)/ncols; int nrows=(lines.length()+ncols-1)/ncols;
for(int i=0; i<nrows; i++) { for(int i=0; i<nrows; i++) {

View File

@ -124,6 +124,14 @@ set (libm65_CXXSRCS
add_definitions (-DBIGSYM=1) add_definitions (-DBIGSYM=1)
set_source_files_properties (sec_midn.f90 PROPERTIES COMPILE_FLAGS -fno-second-underscore) set_source_files_properties (sec_midn.f90 PROPERTIES COMPILE_FLAGS -fno-second-underscore)
set (libm65_C_and_CXXSRCS
${libm65_CSRCS}
${libm65_CXXSRCS}
)
set_property (SOURCE ${libm65_C_and_CXXSRCS} APPEND_STRING PROPERTY COMPILE_FLAGS " -include wsjtx_config.h")
set_property (SOURCE ${libm65_C_and_CXXSRCS} APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/wsjtx_config.h)
# #
# build our targets # build our targets
# #

View File

@ -36,6 +36,9 @@
#if HAVE_UNISTD_H #if HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#endif #endif
#if HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#if HAVE_SYS_IOCTL_H #if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h> # include <sys/ioctl.h>
#endif #endif
@ -171,6 +174,7 @@ ptt_serial(int fd, int *ntx, int *iptt)
{ {
int control = TIOCM_RTS | TIOCM_DTR; int control = TIOCM_RTS | TIOCM_DTR;
#if defined (TIOCMBIS) && defined (TIOCMBIS)
if(*ntx) { if(*ntx) {
ioctl(fd, TIOCMBIS, &control); /* Set DTR and RTS */ ioctl(fd, TIOCMBIS, &control); /* Set DTR and RTS */
*iptt = 1; *iptt = 1;
@ -178,6 +182,16 @@ ptt_serial(int fd, int *ntx, int *iptt)
ioctl(fd, TIOCMBIC, &control); ioctl(fd, TIOCMBIC, &control);
*iptt = 0; *iptt = 0;
} }
#else
unsigned y;
ioctl(fd, TIOCMGET, &y);
if (*ntx) {
y |= control;
} else {
y &= ~control;
}
ioctl(fd, TIOCMSET, &y);
#endif
return(0); return(0);
} }

View File

@ -1520,7 +1520,13 @@ void MainWindow::guiUpdate()
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
QTextStream out(&f); QTextStream out(&f);
out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm") out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
<< " Tx message: " << QString::fromLatin1(msgsent) << Qt::endl; << " Tx message: " << QString::fromLatin1(msgsent)
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f.close(); f.close();
} }
@ -1543,7 +1549,13 @@ void MainWindow::guiUpdate()
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
QTextStream out(&f); QTextStream out(&f);
out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm") out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
<< " Tx message: " << QString::fromLatin1(msgsent) << Qt::endl; << " Tx message: " << QString::fromLatin1(msgsent)
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f.close(); f.close();
} }
@ -1885,7 +1897,13 @@ void MainWindow::on_addButton_clicked() //Add button
if(f1.size()==0) { if(f1.size()==0) {
QTextStream out(&f1); QTextStream out(&f1);
out << "ZZZZZZ" << Qt::endl; out << "ZZZZZZ"
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f1.close(); f1.close();
f1.open(QIODevice::ReadOnly | QIODevice::Text); f1.open(QIODevice::ReadOnly | QIODevice::Text);
} }

View File

@ -1,6 +1,7 @@
#include "messages.h" #include "messages.h"
#include "ui_messages.h" #include "ui_messages.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "../qt_helpers.hpp"
Messages::Messages(QWidget *parent) : Messages::Messages(QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -31,7 +32,7 @@ void Messages::setText(QString t, QString t2)
ui->messagesTextBrowser->setStyleSheet(s); ui->messagesTextBrowser->setStyleSheet(s);
ui->messagesTextBrowser->clear(); ui->messagesTextBrowser->clear();
QStringList lines = t.split( "\n", Qt::SkipEmptyParts ); QStringList lines = t.split( "\n", SkipEmptyParts );
foreach( QString line, lines ) { foreach( QString line, lines ) {
QString t1=line.mid(0,50); QString t1=line.mid(0,50);
int ncq=t1.indexOf(" CQ "); int ncq=t1.indexOf(" CQ ");

View File

@ -298,7 +298,6 @@ void WideGraph::on_fCenterLineEdit_editingFinished()
void WideGraph::on_pbSetRxHardware_clicked() void WideGraph::on_pbSetRxHardware_clicked()
{ {
#ifdef WIN32
int iret=set570(m_mult570*(1.0+0.000001*m_cal570)*m_dForceCenterFreq); int iret=set570(m_mult570*(1.0+0.000001*m_cal570)*m_dForceCenterFreq);
if(iret != 0) { if(iret != 0) {
QMessageBox mb; QMessageBox mb;
@ -306,12 +305,10 @@ void WideGraph::on_pbSetRxHardware_clicked()
if(iret==-2) mb.setText("Frequency out of permitted range."); if(iret==-2) mb.setText("Frequency out of permitted range.");
mb.exec(); mb.exec();
} }
#endif
} }
void WideGraph::initIQplus() void WideGraph::initIQplus()
{ {
#ifdef WIN32
int iret=set570(288.0); int iret=set570(288.0);
if(iret != 0) { if(iret != 0) {
QMessageBox mb; QMessageBox mb;
@ -321,7 +318,6 @@ void WideGraph::initIQplus()
} else { } else {
on_pbSetRxHardware_clicked(); on_pbSetRxHardware_clicked();
} }
#endif
} }
void WideGraph::on_cbSpec2d_toggled(bool b) void WideGraph::on_cbSpec2d_toggled(bool b)
@ -348,7 +344,6 @@ void WideGraph::on_cbLockTxRx_stateChanged(int n)
void WideGraph::rx570() void WideGraph::rx570()
{ {
double f=m_mult570*(1.0+0.000001*m_cal570)*m_dForceCenterFreq; double f=m_mult570*(1.0+0.000001*m_cal570)*m_dForceCenterFreq;
#ifdef WIN32
int iret=set570(f); int iret=set570(f);
if(iret != 0) { if(iret != 0) {
QMessageBox mb; QMessageBox mb;
@ -356,7 +351,6 @@ void WideGraph::rx570()
if(iret==-2) mb.setText("Frequency out of permitted range."); if(iret==-2) mb.setText("Frequency out of permitted range.");
mb.exec(); mb.exec();
} }
#endif
} }
void WideGraph::tx570() void WideGraph::tx570()
@ -367,7 +361,6 @@ void WideGraph::tx570()
// double f1=m_mult570Tx*(1.0+0.000001*m_cal570) * f; // double f1=m_mult570Tx*(1.0+0.000001*m_cal570) * f;
double f1=m_mult570Tx*(1.0+0.000001*m_cal570) * (f - m_TxOffset); double f1=m_mult570Tx*(1.0+0.000001*m_cal570) * (f - m_TxOffset);
#ifdef WIN32
int iret=set570(f1); int iret=set570(f1);
if(iret != 0) { if(iret != 0) {
QMessageBox mb; QMessageBox mb;
@ -375,7 +368,6 @@ void WideGraph::tx570()
if(iret==-2) mb.setText("Frequency out of permitted range."); if(iret==-2) mb.setText("Frequency out of permitted range.");
mb.exec(); mb.exec();
} }
#endif
} }
void WideGraph::updateFreqLabel() void WideGraph::updateFreqLabel()

View File

@ -84,8 +84,6 @@ private:
Ui::WideGraph *ui; Ui::WideGraph *ui;
}; };
#ifdef WIN32
extern int set570(double freq_MHz); extern int set570(double freq_MHz);
#endif
#endif // WIDEGRAPH_H #endif // WIDEGRAPH_H

View File

@ -32,6 +32,16 @@ extern "C" {
#cmakedefine01 HAVE_HAMLIB_OLD_CACHING #cmakedefine01 HAVE_HAMLIB_OLD_CACHING
#cmakedefine01 HAVE_HAMLIB_CACHING #cmakedefine01 HAVE_HAMLIB_CACHING
#cmakedefine HAVE_STDIO_H 1
#cmakedefine STDC_HEADERS 1
#cmakedefine HAVE_STDLIB_H 1
#cmakedefine HAVE_UNISTD_H 1
#cmakedefine HAVE_SYS_IOCTL_H 1
#cmakedefine HAVE_FCNTL_H 1
#cmakedefine HAVE_SYS_STAT_H 1
#cmakedefine HAVE_LINUX_PPDEV_H 1
#cmakedefine HAVE_DEV_PPBUS_PPI_H 1
#cmakedefine01 WSJT_SHARED_RUNTIME #cmakedefine01 WSJT_SHARED_RUNTIME
#cmakedefine01 WSJT_SOFT_KEYING #cmakedefine01 WSJT_SOFT_KEYING
#cmakedefine01 WSJT_ENABLE_EXPERIMENTAL_FEATURES #cmakedefine01 WSJT_ENABLE_EXPERIMENTAL_FEATURES