Additional cleanup and support for LLVM MinGW.

pull/305/head
Mooneer Salem 2022-11-26 08:30:45 -08:00
parent 60e569f878
commit 9ef899fdd5
7 changed files with 59 additions and 67 deletions

View File

@ -14,6 +14,9 @@ set(PROJECT_VERSION 1.8.4)
set(PROJECT_DESCRIPTION "HF Digital Voice for Radio Amateurs")
set(PROJECT_HOMEPAGE_URL "https://freedv.org")
# Makes FreeDV overridden CMake platform available for ARM MinGW builds.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
if(APPLE)
project(
${PROJECT_NAME}
@ -368,12 +371,8 @@ if(NOT USE_STATIC_SAMPLERATE)
list(APPEND FREEDV_LINK_LIBS ${LIBSAMPLERATE})
include_directories(${LIBSAMPLERATE_INCLUDE_DIR})
else(LIBSTAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR)
message(FATAL_ERROR "samplerate library not found.
On Linux systems try installing:
samplerate-devel (RPM based systems)
libsamplerate-dev (DEB based systems)
On Windows it's easiest to use the cmake option: USE_STATIC_SAMPLERATE"
)
message(STATUS "Will attempt static build of samplerate.")
include(cmake/BuildSamplerate.cmake)
endif(LIBSAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR)
else(NOT USE_STATIC_SAMPLERATE)
message(STATUS "Will attempt static build of samplerate.")
@ -392,12 +391,8 @@ if(NOT USE_STATIC_SNDFILE)
if(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR)
list(APPEND FREEDV_LINK_LIBS ${LIBSNDFILE})
else(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR)
message(FATAL_ERROR "sndfile library not found.
On Linux systems try installing:
libsndfile-devel (RPM based systems)
libsndfile-dev (DEB based systems)
On Windows it's easiest to use the cmake option: USE_STATIC_SNDFILE"
)
message(STATUS "Will attempt static build of sndfile.")
include(cmake/BuildSndfile.cmake)
endif(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR)
else(NOT USE_STATIC_SNDFILE)
message(STATUS "Will attempt static build of sndfile.")
@ -510,13 +505,6 @@ add_subdirectory(contrib)
message(STATUS "Build type will be: ${CMAKE_BUILD_TYPE}")
# Adds support for "make dist" target.
set(ARCHIVE_NAME "freedv-${FREEDV_VERSION_MAJOR}.${FREEDV_VERSION_MINOR}.${FREEDV_VERSION_PATCH}")
add_custom_target(dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
| bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# CPack configuration for Windows and Linux.
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HF Digital Voice for Radio Amateurs")
set(CPACK_PACKAGE_VENDOR "CMake")

View File

@ -11,7 +11,7 @@ endif(BUILD_OSX_UNIVERSAL)
# Bootstrap lpcnetfreedv library
include(cmake/BuildLPCNet.cmake)
# Build final codec2 library with lpcnetfreedv
# Build codec2 library with lpcnetfreedv
set(CODEC2_CMAKE_ARGS ${CODEC2_CMAKE_ARGS} -DLPCNET_BUILD_DIR=${CMAKE_BINARY_DIR}/LPCNet_build)
include(ExternalProject)
ExternalProject_Add(build_codec2
@ -19,7 +19,7 @@ ExternalProject_Add(build_codec2
BINARY_DIR codec2_build
GIT_REPOSITORY https://github.com/drowe67/codec2.git
GIT_TAG origin/master
CMAKE_ARGS ${CODEC2_CMAKE_ARGS} ${SPEEXDSP_CMAKE_ARGS}
CMAKE_ARGS ${CODEC2_CMAKE_ARGS}
CMAKE_CACHE_ARGS -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
INSTALL_COMMAND ""
)

View File

@ -1,3 +1,6 @@
if(MINGW AND CMAKE_CROSSCOMPILING)
set(CONFIGURE_COMMAND ./configure --host=${HOST} --target=${HOST} --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist)
else(MINGW AND CMAKE_CROSSCOMPILING)
if(APPLE)
if(BUILD_OSX_UNIVERSAL)
set(CONFIGURE_COMMAND ./configure --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist CFLAGS=-g\ -O2\ -mmacosx-version-min=10.9\ -arch\ x86_64\ -arch\ arm64 CXXFLAGS=-g\ -O2\ -mmacosx-version-min=10.9\ -arch\ x86_64\ -arch\ arm64)
@ -5,8 +8,9 @@ else()
set(CONFIGURE_COMMAND ./configure --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist CFLAGS=-g\ -O2\ -mmacosx-version-min=10.9 CXXFLAGS=-g\ -O2\ -mmacosx-version-min=10.9)
endif(BUILD_OSX_UNIVERSAL)
else()
set(CONFIGURE_COMMAND ./configure --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist)
set(CONFIGURE_COMMAND ./configure --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER})
endif()
endif(MINGW AND CMAKE_CROSSCOMPILING)
include(ExternalProject)
ExternalProject_Add(hamlib

View File

@ -1,35 +1,21 @@
set(SAMPLERATE_TARBALL "libsamplerate-0.1.9")
set(SAMPLERATE_VERSION "0.2.2")
set(PATCH_COMMAND patch -p0 < ${CMAKE_BINARY_DIR}/../patch-samplerate.diff)
if(MINGW AND CMAKE_CROSSCOMPILING)
set(CONFIGURE_COMMAND ./configure --host=${HOST} --target=${HOST} --prefix=${CMAKE_BINARY_DIR}/external/dist --disable-sndfile --disable-fftw)
elseif(APPLE)
if(BUILD_OSX_UNIVERSAL)
set(CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/external/dist CFLAGS=-g\ -O2\ -mmacosx-version-min=10.9\ -arch\ arm64\ -arch\ x86_64)
else()
set(CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/external/dist CFLAGS=-g\ -O2\ -mmacosx-version-min=10.9)
endif(BUILD_OSX_UNIVERSAL)
else()
set(CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/external/dist)
include(FetchContent)
FetchContent_Declare(
samplerate
GIT_REPOSITORY https://github.com/libsndfile/libsamplerate.git
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
GIT_TAG master
)
FetchContent_GetProperties(samplerate)
if(NOT samplerate_POPULATED)
FetchContent_Populate(samplerate)
add_subdirectory(${samplerate_SOURCE_DIR} ${samplerate_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
include(ExternalProject)
ExternalProject_Add(samplerate
URL http://www.mega-nerd.com/SRC/${SAMPLERATE_TARBALL}.tar.gz
BUILD_IN_SOURCE 1
INSTALL_DIR external/dist
PATCH_COMMAND ${PATCH_COMMAND}
CONFIGURE_COMMAND ${CONFIGURE_COMMAND}
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND $(MAKE) install
)
if(WIN32)
set(SAMPLERATE_LIBRARIES
${CMAKE_BINARY_DIR}/external/dist/lib/libsamplerate.a)
else(WIN32)
set(SAMPLERATE_LIBRARIES
${CMAKE_BINARY_DIR}/external/dist/lib/libsamplerate.a)
endif(WIN32)
include_directories(${CMAKE_BINARY_DIR}/external/dist/include)
list(APPEND FREEDV_LINK_LIBS ${SAMPLERATE_LIBRARIES})
list(APPEND FREEDV_STATIC_DEPS samplerate)
list(APPEND FREEDV_LINK_LIBS samplerate)
target_include_directories(samplerate BEFORE PRIVATE ${samplerate_BINARY_DIR})
include_directories(${samplerate_SOURCE_DIR}/include)

View File

@ -1,21 +1,20 @@
set(SPEEXDSP_TARBALL "speexdsp-1.2rc3.tar.gz")
if(MINGW AND CMAKE_CROSSCOMPILING)
include(cmake/MinGW.cmake)
set(CONFIGURE_COMMAND ./configure --host=${HOST} --prefix=${CMAKE_BINARY_DIR}/external/dist --disable-examples)
set(CONFIGURE_COMMAND ./autogen.sh && ./configure --host=${HOST} --prefix=${CMAKE_BINARY_DIR}/external/dist --disable-examples)
elseif(APPLE)
if(BUILD_OSX_UNIVERSAL)
set(CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/../configure_speexdsp_osx_universal.sh ${CMAKE_BINARY_DIR}/external/dist)
set(CONFIGURE_COMMAND ./autogen.sh && ${CMAKE_BINARY_DIR}/../configure_speexdsp_osx_universal.sh ${CMAKE_BINARY_DIR}/external/dist)
else()
set(CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/../configure_speexdsp_osx.sh ${CMAKE_BINARY_DIR}/external/dist)
set(CONFIGURE_COMMAND ./autogen.sh && ${CMAKE_BINARY_DIR}/../configure_speexdsp_osx.sh ${CMAKE_BINARY_DIR}/external/dist)
endif(BUILD_OSX_UNIVERSAL)
else()
set(CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/external/dist --disable-examples)
set(CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_BINARY_DIR}/external/dist --disable-examples)
endif()
include(ExternalProject)
ExternalProject_Add(speex
URL http://downloads.xiph.org/releases/speex/${SPEEXDSP_TARBALL}
GIT_REPOSITORY https://gitlab.xiph.org/xiph/speexdsp.git
GIT_TAG origin/master
BUILD_IN_SOURCE 1
INSTALL_DIR external/dist
CONFIGURE_COMMAND ${CONFIGURE_COMMAND}

View File

@ -1,10 +1,14 @@
# If we're cross-compiling then we need to set the target host manually.
if(MINGW AND CMAKE_CROSSCOMPILING)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(HOST x86_64-w64-mingw32)
set(BUILD x86_64-redhat-linux-gnu)
else()
set(HOST i686-w64-mingw32)
set(BUILD i686-redhat-linux-gnu)
if(CMAKE_C_COMPILER_TARGET)
set(HOST ${CMAKE_C_COMPILER_TARGET})
else()
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(HOST x86_64-w64-mingw32)
set(BUILD x86_64-redhat-linux-gnu)
else()
set(HOST i686-w64-mingw32)
set(BUILD i686-redhat-linux-gnu)
endif()
endif()
endif()

View File

@ -0,0 +1,11 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(triple ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32)
set(CMAKE_C_COMPILER ${triple}-clang)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER ${triple}-clang++)
set(CMAKE_CXX_COMPILER_TARGET ${triple})
SET(CMAKE_RC_COMPILER ${triple}-windres)