mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 05:38:46 -05:00
Updated CMake finders, working on Windows & supporting dynamic hamlib
This commit is contained in:
parent
3f98270681
commit
63e485e819
@ -1,45 +1,25 @@
|
||||
# - Try to find hamlib
|
||||
#
|
||||
# Once done, this will define:
|
||||
# Find the hamlib library
|
||||
#
|
||||
# hamlib_FOUND - system has Hamlib
|
||||
# hamlib_INCLUDE_DIRS - the Hamlib include directories
|
||||
# hamlib_LIBRARIES - link these to use Hamlib
|
||||
# hamlib_LIBRARY_DIRS - required shared/dynamic libraries are here
|
||||
# This will define the following variables::
|
||||
#
|
||||
# If hamlib_STATIC is TRUE then static linking will be assumed
|
||||
# hamlib_FOUND - True if the system has the usb library
|
||||
# hamlib_VERSION - The verion of the usb library which was found
|
||||
#
|
||||
# and the following imported targets::
|
||||
#
|
||||
# hamlib::hamlib - The hamlib library
|
||||
#
|
||||
|
||||
# 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)
|
||||
|
||||
libfind_pkg_detect (hamlib hamlib FIND_PATH hamlib/rig.h PATH_SUFFIXES hamlib FIND_LIBRARY hamlib)
|
||||
libfind_pkg_detect (hamlib hamlib
|
||||
FIND_PATH hamlib/rig.h PATH_SUFFIXES hamlib
|
||||
FIND_LIBRARY hamlib
|
||||
)
|
||||
|
||||
libfind_package (hamlib libusb)
|
||||
if (hamlib_STATIC)
|
||||
if (hamlib_PKGCONF_FOUND)
|
||||
set (hamlib_PROCESS_LIBS hamlib_PKGCONF_STATIC_LIBRARY)
|
||||
else ()
|
||||
endif ()
|
||||
else ()
|
||||
if (hamlib_PKGCONF_FOUND)
|
||||
set (hamlib_PROCESS_LIBS hamlib_PKGCONF_LIBRARY)
|
||||
else ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
libfind_process (hamlib)
|
||||
|
||||
if (NOT hamlib_PKGCONF_FOUND)
|
||||
@ -49,3 +29,19 @@ if (NOT hamlib_PKGCONF_FOUND)
|
||||
set (hamlib_LIBRARIES ${hamlib_LIBRARIES};m;dl)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (hamlib_FOUND AND NOT TARGET hamlib::hamlib)
|
||||
add_library (hamlib::hamlib UNKNOWN IMPORTED)
|
||||
set_target_properties (hamlib::hamlib PROPERTIES
|
||||
IMPORTED_LOCATION "${hamlib_LIBRARY}"
|
||||
INTERFACE_COMPILE_OPTIONS "${hamlib_PKGCONF_CFLAGS_OTHER}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${hamlib_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${hamlib_LIBRARIES}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (
|
||||
hamlib_INCLUDE_DIR
|
||||
hamlib_LIBRARY
|
||||
hamlib_LIBRARIES
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Findlibusb
|
||||
# =======
|
||||
# ==========
|
||||
#
|
||||
# Find the usb library
|
||||
#
|
||||
@ -12,75 +12,31 @@
|
||||
#
|
||||
# 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()
|
||||
if (WIN32)
|
||||
# Use path suffixes on MS Windows as we probably shouldn't
|
||||
# trust the PATH envvar. PATH will still be searched to find the
|
||||
# library as last resort.
|
||||
if (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
set (_library_options PATH_SUFFIXES MinGW64/dll MinGW64/static)
|
||||
else ()
|
||||
set (_library_options PATH_SUFFIXES MinGW32/dll MinGW32/static)
|
||||
endif ()
|
||||
endif ()
|
||||
libfind_pkg_detect (libusb libusb-1.0
|
||||
FIND_PATH libusb.h PATH_SUFFIXES libusb-1.0
|
||||
FIND_LIBRARY libusb-1.0 ${_library_options}
|
||||
)
|
||||
|
||||
include (LibFindMacros)
|
||||
libfind_pkg_detect (libusb libusb-1.0 FIND_PATH libusb.h PATH_SUFFIXES libusb-1.0 FIND_LIBRARY libusb-1.0)
|
||||
set (libusb_LIBRARY C:/Tools/libusb-1.0.24/MinGW64/dll/libusb-1.0.dll.a)
|
||||
# # 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
|
||||
# libusb.h
|
||||
# PATHS ${libusb_PC_INCLUDE_DIRS}
|
||||
# PATH_SUFFIXES libusb-1.0
|
||||
# )
|
||||
|
||||
# # Library
|
||||
# if (libusb_STATIC)
|
||||
# find_library (libusb_LIBRARY
|
||||
# NAMES usb-1.0
|
||||
# PATHS ${libusb_PC_STATIC_LIBRARY_DIRS}
|
||||
# PATH_SUFFIXES static
|
||||
# )
|
||||
# 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)
|
||||
|
||||
# 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_COMPILE_OPTIONS "${libusb_PKGCONF_CFLAGS_OTHER}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${libusb_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARAIES "${libusb_LIBRARIES}"
|
||||
INTERFACE_LINK_LIBRARIES "${libusb_LIBRARIES}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
@ -9,39 +9,23 @@
|
||||
#
|
||||
# portaudio::portaudio - The portaudio library
|
||||
#
|
||||
# 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)
|
||||
|
||||
libfind_pkg_detect (portaudio portaudio-2.0 FIND_PATH portaudio.h FIND_LIBRARY portaudio)
|
||||
set (portaudio_PROCESS_LIBS portaudio_PKGCONF_LDFLAGS)
|
||||
libfind_process (portaudio)
|
||||
libfind_pkg_detect (portaudio portaudio-2.0
|
||||
FIND_PATH portaudio.h
|
||||
FIND_LIBRARY portaudio
|
||||
)
|
||||
|
||||
#dump_cmake_variables ("^portaudio_")
|
||||
libfind_process (portaudio)
|
||||
|
||||
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_OTHERS}"
|
||||
INTERFACE_COMPILE_OPTIONS "${portaudio_PKGCONF_CFLAGS_OTHER}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${portaudio_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${portaudio_LIBRARIES}"
|
||||
INTERFACE_LINK_LIBRARIES "${portaudio_PKGCONF_LDFLAGS}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
@ -872,19 +872,11 @@ find_package (FFTW3 COMPONENTS single threads REQUIRED)
|
||||
#
|
||||
# libhamlib setup
|
||||
#
|
||||
set (hamlib_STATIC 1)
|
||||
find_package (hamlib REQUIRED)
|
||||
find_program (RIGCTL_EXE rigctl)
|
||||
find_program (RIGCTLD_EXE rigctld)
|
||||
find_program (RIGCTLCOM_EXE rigctlcom)
|
||||
|
||||
message (STATUS "hamlib_INCLUDE_DIRS: ${hamlib_INCLUDE_DIRS}")
|
||||
message (STATUS "hamlib_LIBRARIES: ${hamlib_LIBRARIES}")
|
||||
message (STATUS "hamlib_LIBRARY_DIRS: ${hamlib_LIBRARY_DIRS}")
|
||||
|
||||
set (CMAKE_REQUIRED_INCLUDES "${hamlib_INCLUDE_DIRS}")
|
||||
set (CMAKE_REQUIRED_LIBRARIES "${hamlib_LIBRARIES}")
|
||||
set (CMAKE_EXTRA_INCLUDE_FILES "hamlib/rig.h")
|
||||
check_type_size (CACHE_ALL HAMLIB_OLD_CACHING)
|
||||
check_symbol_exists (rig_set_cache_timeout_ms "hamlib/rig.h" HAVE_HAMLIB_CACHING)
|
||||
|
||||
@ -1332,8 +1324,7 @@ target_link_libraries (qcp Qt5::Widgets Qt5::PrintSupport)
|
||||
add_library (wsjt_qt STATIC ${wsjt_qt_CXXSRCS} ${wsjt_qt_GENUISRCS} ${GENAXSRCS})
|
||||
# set wsjtx_udp exports to static variants
|
||||
target_compile_definitions (wsjt_qt PUBLIC UDP_STATIC_DEFINE)
|
||||
target_link_libraries (wsjt_qt Boost::log qcp Qt5::Widgets Qt5::Network Qt5::Sql)
|
||||
target_include_directories (wsjt_qt BEFORE PRIVATE ${hamlib_INCLUDE_DIRS})
|
||||
target_link_libraries (wsjt_qt hamlib::hamlib Boost::log qcp Qt5::Widgets Qt5::Network Qt5::Sql)
|
||||
if (WIN32)
|
||||
target_link_libraries (wsjt_qt Qt5::AxContainer Qt5::AxBase)
|
||||
endif (WIN32)
|
||||
@ -1450,7 +1441,7 @@ else ()
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
target_link_libraries (wsjtx Qt5::SerialPort wsjt_cxx wsjt_qt wsjt_qtmm ${hamlib_LIBRARIES} ${FFTW3_LIBRARIES} ${LIBM_LIBRARIES})
|
||||
target_link_libraries (wsjtx Qt5::SerialPort wsjt_cxx wsjt_qt wsjt_qtmm ${FFTW3_LIBRARIES} ${LIBM_LIBRARIES})
|
||||
|
||||
# make a library for WSJT-X UDP servers
|
||||
# add_library (wsjtx_udp SHARED ${UDP_library_CXXSRCS})
|
||||
|
Loading…
Reference in New Issue
Block a user